All Projects → paololeonardi → Waterfallgrid

paololeonardi / Waterfallgrid

Licence: mit
A waterfall grid layout view for SwiftUI.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Waterfallgrid

Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-85.45%)
Mutual labels:  tvos, watchos, swift-package-manager
Dots
Lightweight Concurrent Networking Framework
Stars: ✭ 35 (-96.78%)
Mutual labels:  tvos, watchos, swift-package-manager
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-83.7%)
Mutual labels:  tvos, watchos, swift-package-manager
Surmagic
🚀 The better way to deal with Binary Frameworks on iOS, Mac Catalyst, tvOS, macOS, and watchOS. Create XCFrameworks with ease.
Stars: ✭ 119 (-89.04%)
Mutual labels:  tvos, watchos, swift-package-manager
Queuer
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).
Stars: ✭ 964 (-11.23%)
Mutual labels:  tvos, watchos, swift-package-manager
Opencombine
Open source implementation of Apple's Combine framework for processing values over time.
Stars: ✭ 2,040 (+87.85%)
Mutual labels:  tvos, watchos, swift-package-manager
tracelog
TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS.
Stars: ✭ 52 (-95.21%)
Mutual labels:  tvos, watchos, swift-package-manager
SwiftCurrent
A library for managing complex workflows in Swift
Stars: ✭ 286 (-73.66%)
Mutual labels:  tvos, watchos, swift-package-manager
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (-72.84%)
Mutual labels:  tvos, watchos, swift-package-manager
Skeletonui
☠️ Elegant skeleton loading animation in SwiftUI and Combine
Stars: ✭ 275 (-74.68%)
Mutual labels:  tvos, watchos, swift-package-manager
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+885.82%)
Mutual labels:  tvos, watchos, swift-package-manager
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (-51.47%)
Mutual labels:  tvos, watchos, swift-package-manager
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+11.97%)
Mutual labels:  tvos, watchos, swift-package-manager
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-87.29%)
Mutual labels:  tvos, watchos, swift-package-manager
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (-97.51%)
Mutual labels:  tvos, watchos, swift-package-manager
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (-72.19%)
Mutual labels:  tvos, watchos, swift-package-manager
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (-40.98%)
Mutual labels:  tvos, watchos, swift-package-manager
Ratelimit
Simple utility for only executing code every so often.
Stars: ✭ 918 (-15.47%)
Mutual labels:  tvos, watchos
Swiftyrsa
RSA public/private key encryption in Swift
Stars: ✭ 894 (-17.68%)
Mutual labels:  tvos, watchos
Fontblaster
Programmatically load custom fonts into your iOS and tvOS app.
Stars: ✭ 1,000 (-7.92%)
Mutual labels:  tvos, swift-package-manager

WaterfallGrid

A waterfall grid layout view for SwiftUI.

Image Demo 1

Swift Package Manager Twitter: @paololeonardi

Features

  • [x] Irregular grid of content.
  • [x] Columns number different per device orientation.
  • [x] Spacing and grid padding customizable.
  • [x] Horizontal or vertical scroll direction.
  • [x] Items update can be animated.

Requirements

  • iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+
  • Xcode 11.0+
  • Swift 5.1+

Usage

Initialization

You can create a grid that displays the elements of collection by passing your collection of data and a closure that provides a view for each element in the collection. The grid transforms each element in the collection into a child view by using the supplied closure.

WaterfallGrid works with identifiable data (like SwiftUI.List). You can make your data identifiable in one of two ways: by passing along with your data a key path to a property that uniquely identifies each element, or by making your data type conform to the Identifiable protocol.

Example 1

A grid of views of type Image from a collection of data identified by a key path.

WaterfallGrid((0..<10), id: \.self) { index in
  Image("image\(index)")
    .resizable()
    .aspectRatio(contentMode: .fit)
}

Example 2

A grid of views of type RectangleView from a collection of Identifiable data.

WaterfallGrid(rectangles) { rectangle in
  RectangleView(rectangle: rectangle)
}

or, for simple cases like this, just:

WaterfallGrid(rectangles, content: RectangleView.init)

Grid Style

To customise the appearance of the grid call the gridStyle function and pass the parameters you want to customise.

Columns

WaterfallGrid(cards) { card in
  CardView(card: card)
}
.gridStyle(columns: 2)
WaterfallGrid(cards, content: CardView.init)
.gridStyle(
  columnsInPortrait: 2,
  columnsInLandscape: 3
)

Spacing and Padding

WaterfallGrid(rectangles, content: RectangleView.init)
.gridStyle(spacing: 8)
.padding(EdgeInsets(top: 16, leading: 8, bottom: 16, trailing: 8))

Animation

WaterfallGrid(rectangles, content: RectangleView.init)
.gridStyle(animation: .easeInOut(duration: 0.5))

Scroll Behaviour

Embed in ScrollView & Indicators option

ScrollView(showsIndicators: true) {
  WaterfallGrid(rectangles, content: RectangleView.init)
}

Horizontal Scroll Direction

ScrollView(.horizontal) {
  WaterfallGrid(rectangles, content: RectangleView.init)
  .scrollOptions(direction: .horizontal)
}

Animation Demo 4 Animation Demo 5

A Complete Example

ScrollView(.horizontal, showsIndicators: false) {
  WaterfallGrid(cards) { card in
    CardView(card: card)
  }
  .gridStyle(
    columnsInPortrait: 2,
    columnsInLandscape: 3,
    spacing: 8,
    animation: .easeInOut(duration: 0.5)
  )
  .scrollOptions(direction: .horizontal)
  .padding(EdgeInsets(top: 16, leading: 8, bottom: 16, trailing: 8))
}

Sample App

Explore the WaterfallGridSample app for some more detailed and interactive examples.

Animation Demo 1  Animation Demo 2  Animation Demo 3

Image Demo 3

Image Demo 2

Installation

Swift Package Manager

App dependency

select File > Swift Packages > Add Package Dependency and enter the repository URL (Adding Package Dependencies to Your App)

Package dependency

Add it as a dependency within your Package.swift manifest:

dependencies: [
  .package(url: "https://github.com/paololeonardi/WaterfallGrid.git", from: "1.0.0")
]

CocoaPods

You can install WaterfallGrid via CocoaPods by adding the following line to your Podfile:

pod 'WaterfallGrid', '~> 1.0.0'

Run the pod install command to download the library and integrate it into your Xcode project.

Migration Guides

Versioning

For the versions available, see the releases on this repository.

Contributing

Contributions are more than welcome. Please create a GitHub issue before submitting a pull request to plan and discuss implementation.

Author

Credits

WaterfallGrid was ispired by the following projects:

License

WaterfallGrid is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].