All Projects → pietropizzi → Gridstack

pietropizzi / Gridstack

Licence: mit
A flexible grid layout view for SwiftUI

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Gridstack

Swiftui Grid
🚀 SwiftUI Grid layout with custom styles
Stars: ✭ 872 (+83.97%)
Mutual labels:  tvos, watchos, grid
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (-37.76%)
Mutual labels:  tvos, watchos
Efqrcode
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.
Stars: ✭ 4,121 (+769.41%)
Mutual labels:  tvos, watchos
Solarized Dark For Xcode
Solarized Dark Theme for Xcode. Compatible with all modern versions of Xcode since 2013!
Stars: ✭ 358 (-24.47%)
Mutual labels:  tvos, watchos
Waterwheel.swift
The Waterwheel Swift SDK provides classes to natively connect iOS, macOS, tvOS, and watchOS applications to Drupal 7 and 8.
Stars: ✭ 415 (-12.45%)
Mutual labels:  tvos, watchos
Skeletonui
☠️ Elegant skeleton loading animation in SwiftUI and Combine
Stars: ✭ 275 (-41.98%)
Mutual labels:  tvos, watchos
Crypto
Swift CommonCrypto wrapper
Stars: ✭ 328 (-30.8%)
Mutual labels:  tvos, watchos
Swiftui Charts
🚀 SwiftUI Charts with custom styles
Stars: ✭ 272 (-42.62%)
Mutual labels:  tvos, watchos
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+682.7%)
Mutual labels:  tvos, watchos
Swiftuipager
Native Pager in SwiftUI
Stars: ✭ 430 (-9.28%)
Mutual labels:  tvos, watchos
Sentry Cocoa
The official Sentry SDK for iOS, tvOS, macOS, watchOS
Stars: ✭ 370 (-21.94%)
Mutual labels:  tvos, watchos
Userdefaultsstore
Why not use UserDefaults to store Codable objects 😉
Stars: ✭ 416 (-12.24%)
Mutual labels:  tvos, watchos
Nshipster.com
A journal of the overlooked bits in Objective-C, Swift, and Cocoa. Updated weekly.
Stars: ✭ 280 (-40.93%)
Mutual labels:  tvos, watchos
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-37.97%)
Mutual labels:  tvos, watchos
X
Easier cross platform Mac & iOS development with Swift
Stars: ✭ 270 (-43.04%)
Mutual labels:  tvos, watchos
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (-36.29%)
Mutual labels:  tvos, watchos
Json
Micro framework for easily parsing JSON in Swift with rich error messages in less than 100 lines of code
Stars: ✭ 395 (-16.67%)
Mutual labels:  tvos, watchos
Xestimonitors
An extensible monitoring framework written in Swift
Stars: ✭ 269 (-43.25%)
Mutual labels:  tvos, watchos
Wikipediakit
Wikipedia API Client Framework for Swift on macOS, iOS, watchOS, and tvOS
Stars: ✭ 270 (-43.04%)
Mutual labels:  tvos, watchos
Valet
Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works. It’s easy. We promise.
Stars: ✭ 3,712 (+683.12%)
Mutual labels:  tvos, watchos

📱GridStack

A flexible grid layout view for SwiftUI.

WWDC20 Update

Apple  released LazyVGrid and LazyHGrid at WWDC20.

If you are fine to only support i(Pad)OS 14, macOS 11, tvOS 14, watchOS 7 respectively those ^-- are definitely the way to go.

If you want to support i(Pad)OS 13, macOS 10.15, tvOS 13, watchOS 6 keep on reading.


Release Build & Test

📱 iOS 13+, 💻 macOS 10.15+, 📺 tvOS 13+, ⌚ watchOS 6+

Simply pass the minimum width the grid cells should have and the spacing between them and it will adjust depending on the available width.

So writing this:

Code

will give you you this:

Screenshot 2019-07-14 at 14 07 02

It also adjusts correctly when the device is rotated:

rotation

🗺 Usage Overview

Think of the grid in the way of what is the minimum width you want your cells to be. That way it is easy to adjust to any available space. The only other size you need to provide is the spacing between the cells.

To actually create the grid we need to know the numbers of items. Then the content view builder will be called with each index and the cellWidth that you can then pass to the frame of whatever you want to display inside.

👕 Sizing your views inside the cells

The grid will wrap each item you provide with in a view that gets the cellWidth set as width. No height constraint is put on the cell. That is so that you can size your content as flexible as possible. Here are just a couple of examples what you can do.

Height defined by content

GridStack(...) { index, cellWidth in
    Text("\(index)")
        // Don't pass any height to the frame to let it be defined by it's content
        .frame(width: cellWidth)
}

Square items

GridStack(...) { index, cellWidth in
    Text("\(index)")
        // Pass the cellWidth as width and height to the frame to make a square
        .frame(width: cellWidth, height: cellWidth)
}

Aspect Ratio items

GridStack(...) { index, cellWidth in
    Text("\(index)")
        // Pass the cellWidth as width and a portion of it as height to get a certain aspect ratio
        .frame(width: cellWidth, height: cellWidth * 0.75)
}

✍️ Signature

GridStack(
    minCellWidth: Length,
    spacing: Length,
    numItems: Int,
    alignment: HorizontalAlignment = .leading,
    content: (index: Int, cellWidth: CGFloat) -> Void
)

📝 Mentions

I created GridStack by taking ideas from FlowStack by John Susek.

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].