Skip to content

rdev/FlowGrid

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

FlowGrid

Flow layout type grid for SwiftUI that can fill available space.

Usage

Install

Install using Swift Package Manager:

dependencies: [
  .package(url: "https://github.com/rdev/FlowGrid.git")
]

Import and use

import SwiftUI
import FlowGrid

struct PhotoGrid: View {
  var images: [Identifiable]

  var body: some View {
    VStack {
       // It's a good idea to use GeometryReader on a parent VStack to get relative row height. We'll just use 200
      FlowGrid(items: images, rowHeight: 200) { image in
        Image(image.name)
          .resizable()
          .scaledToFit()
      }
    }
  }
}

Initializer Options

init(
  items: Data, // A Collection of Identifiable items to use as data
  rowHeight: CGFloat, // Baseline row height. Rows WILL end up slightly higher than this when scaled up if fill is enabled
  spacing: CGFloat, // Spacing between collection items. Defaults to zero cause it's obviously better looking that way
  disableFill: Bool, // Disables row scaling. Good for cases when you don't need to fill the view, i.e. a "tag cloud"
  content: @escaping (Data.Element) -> Content // Render you stuff here
) {}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages