APDynamicGrid is a SwiftUI package that helps you create consistent and animatable grids.

Overview

APDynamicGrid

License Badge iOS Version Badge iPadOS Version Badge Swift Version Badge

Package Presentation Image

Overview

APDynamicGrid is a SwiftUI package that helps you create consistent and animatable grids. The DynamicGrid View preserves the same width, adjusting the last elements consistently.

Usage

Define your model adopting the Hashable and Identifiable protocols

struct Entry : Identifiable, Hashable {
  let id = UUID()
  // ...
}

and wrap it with the @State decorator

var body : some View {
  
  private @State var entries : [Entry]
  // number of columns is a @State var too
  private @State var columns : Int
  
  ScrollView {
    DynamicGrid(columns: $columns, data: $entries) { entry in 
      MyCustomCell(entry: entry)
    }
  }
}

Entries can be animated registering a @Namespace with the unique id

var body : some View {
  
  private @State var entries : [Entry]
  private @State var columns : Int
  // add a namespace
  private @Namespace var namespace
  
  ScrollView {
    DynamicGrid(columns: $columns, data: $entries) { entry in 
      MyCustomCell(entry: entry)
      // register the namespace
      .matchedGeometryEffect(id: entry.id, in: namespace)
    }
    // apply animations
    .animation(.default)
  }
}

Installation

Xcode Project

You have to select File -> Swift Packages -> Add Package Dependency and enter the repository url https://github.com/antoniopantaleo/APDynamicGrid.git

Swift Package Manager

You have to add the package as a dependency in your Package.swift file

let package = Package(
    //...
    dependencies: [
        .package(url: "https://github.com/antoniopantaleo/APDynamicGrid.git", upToNextMajor(from: "1.0.0")),
    ],
    //...
)

License

MIT

You might also like...
Display list of Marvel comic Characters and its detail view
Display list of Marvel comic Characters and its detail view

Marvel Universe Display list of Marvel comic Characters and its detail view Installation Dependencies in this project are provided via Xcodegen (proje

Use Yelp API to fetch restuarants around a location and show them in a table view
Use Yelp API to fetch restuarants around a location and show them in a table view

Yelp Use Yelp API to fetch restuarants around a location and show them in a table view - Infinite scrolling, Prefetching, Image Caching. Design Patter

A PageView, which supporting scrolling to transition between a UIView and a UITableView
A PageView, which supporting scrolling to transition between a UIView and a UITableView

YXTPageView ##A Page View, which support scrolling to transition between a UIView and a UITableView UIView (at the top) UITableView (at the bottom) In

Simple and beautiful stacked UIView to use as a replacement for an UITableView, UIImageView or as a menu
Simple and beautiful stacked UIView to use as a replacement for an UITableView, UIImageView or as a menu

VBPiledView simple but highly effective animation and interactivity! By v-braun - viktor-braun.de. Preview Description Very simple and beautiful stack

Easy UITableView drag-and-drop cell reordering
Easy UITableView drag-and-drop cell reordering

SwiftReorder NOTE: Some users have encountered compatibility issues when using this library with recent versions of iOS. For apps targeting iOS 11 and

A cells of UITableView can be rearranged by drag and drop.
A cells of UITableView can be rearranged by drag and drop.

TableViewDragger This is a demo that uses a TableViewDragger. Appetize's Demo Requirements Swift 4.2 iOS 8.0 or later How to Install TableViewDragger

A no-nonsense way to write cleaner UITableViewDelegate and UITableViewDataSource in Swift.
A no-nonsense way to write cleaner UITableViewDelegate and UITableViewDataSource in Swift.

CascadingTableDelegate A no-nonsense way to write cleaner UITableViewDelegate and UITableViewDataSource. Why is this library made? In common iOS devel

Protocol-oriented UITableView management, powered by generics and associated types.

DTTableViewManager Features Powerful mapping system between data models and cells, headers and footers Automatic datasource and interface synchronizat

Elegant and easy way to integrate pagination with dummy views
Elegant and easy way to integrate pagination with dummy views

AZTableView Controller Features Automatic pagination handling No more awkward empty TableView screen AZ TableView controller give you advantage to con

Releases(1.0.0)
Owner
Antonio Pantaleo
Know how it works, do not reinvent the wheel.
Antonio Pantaleo
Swift package for easily rendering text tables. Inspired by the Python tabulate library.

TextTable Easily print textual tables in Swift. Inspired by the Python tabulate library. Upcoming Changes See details on an upcoming change.

Cristian Filipov 102 Jan 5, 2023
This framework allows you to build Table views using UIKit with syntax similar to SwiftUI

This framework allows you to build Table views using UIKit with syntax similar to SwiftUI

Fun 60 Dec 17, 2022
a TableView have thumbnail cell only, and you can use gesture let it expands other expansionView, all diy

ZYThumbnailTableView #####可展开型预览TableView,开放接口,完全自由定制 #####An expandable preview TableView, custom-made all the modules completely with open API you c

null 950 Oct 17, 2022
Framework to help you better manage UITableViews

UITableView made simple ?? Main Features ?? Skip the UITableViewDataSource & UITableViewDelegate boilerplate and get right to building your UITableVie

null 84 Feb 4, 2022
A waterfall grid layout view for SwiftUI.

WaterfallGrid A waterfall grid layout view for SwiftUI. Features Irregular grid of content. Columns number different per device orientation. Spacing a

Paolo Leonardi 1.9k Jan 7, 2023
🎛 QGrid: The missing SwiftUI collection view.

[NOTE] If you'd like to see QGrid in action, check out this demo of QDesigner (see video below). Install QDesigner: https://apps.apple.com/us/app/qdes

Q Mobile 1.5k Dec 23, 2022
A flexible grid layout view for SwiftUI

?? GridStack A flexible grid layout view for SwiftUI. WWDC20 Update Apple  released LazyVGrid and LazyHGrid at WWDC20. If you are fine to only suppor

Peter Minarik 620 Nov 11, 2022
SpanGrid is an enriched SwiftUI LazyVGrid that supports a number of extra features.

SpanGrid is an enriched SwiftUI LazyVGrid that supports a number of extra features.

James Sherlock 6 Dec 17, 2022
ClassicPhotos is a TableView App demos how to optimize image download and filter with operation queue.

ClassicPhotos ClassicPhotos is a TableView App demos how to optimize image download and filter with operation queue. With Operation and Operation Queu

Kushal Shingote 2 Dec 18, 2021