APDynamicGrid
A SwiftUI Package for an easy grid management
Install / Use
/learn @antoniopantaleo/APDynamicGridREADME
APDynamicGrid

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.
Demo
<img src="Assets/demo.gif" width="300"/>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 using their unique id
var body : some View {
private @State var entries : [Entry]
private @State var columns : Int
// 1. add a namespace
private @Namespace var namespace
ScrollView {
DynamicGrid(columns: $columns, data: $entries) { entry in
MyCustomCell(entry: entry)
// 2. register the namespace
.matchedGeometryEffect(id: entry.id, in: namespace)
}
// 3. 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
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
