GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - krishkumar/FlowLayout: A flexible flow layout SwiftUI library

BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
Sources/FlowLayout
Sources/FlowLayout
 
 
Tests/FlowLayoutTests
Tests/FlowLayoutTests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Package.swift
Package.swift
 
 
README.md
README.md
 
 
flowlayout.jpg
flowlayout.jpg
 
 

Repository files navigation

FlowLayout

FlowLayout Diagram

A Swift library that provides a flexible flow layout. Arrange SwiftUI subviews in a "flow" style, wrapping items to the next line when necessary — similar to how text is arranged in a paragraph.

Features

  • Dynamic Wrapping: Subviews automatically wrap to a new row when there’s no more room in the current row.
  • Alignment Options: Supports different SwiftUI alignment options like leading, trailing, center, top, and bottom alignment.
  • Adjustable Spacing: Configurable horizontal and vertical spacing between subviews.
  • Fit Content: Optionally fit the layout’s width to the total width of the subviews, or use the parent's width as proposed by SwiftUI.

Usage

  1. Add FlowLayout as a dependency in your Swift Package Manager project:

    .package(
        name: "FlowLayout",
        url: "https://github.com/krishkumar/FlowLayout.git",
        .upToNextMajor(from: "1.0.0")
    )
  2. Import the FlowLayout module in your Swift code:

    import FlowLayout
  3. Use FlowLayout in your SwiftUI code:

     struct ContentView: View {
     	@State var allCities = ["Dallas", "Austin", "New York", "Singapore", "London", "Houston", "Washington DC", "San Francisco"]
     	var body: some View {
     		HStack {
     			FlowLayout {
     				ForEach(allCities, id: \.self) { city in
     					Text("\(city)")
     						.padding()
     						.background(Capsule().fill(.blue))
     				}
     			}
     		}
     	}
     }

Contributing

Contributions are welcome! Feel free to open issues and submit pull requests.

Implementation

FlowLayout uses SwiftUI’s PreferenceKeys to measure child views, making it easier to adapt dynamically to changes in content size. Combined with SwiftUI’s Layout protocol — flexibly arrange subviews that automatically reflows as needed.

License

This project is licensed under the MIT License. See LICENSE for details.

About

A flexible flow layout SwiftUI library

Topics

flexible-layoutflowlayouthstackiosswiftswift-package-managerswiftui

Resources

Readme
MIT license
Activity

Stars

2 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.