All Projects → spacenation → Swiftui Grid

spacenation / Swiftui Grid

Licence: mit
🚀 SwiftUI Grid layout with custom styles

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftui Grid

Swiftui Sliders
🚀 SwiftUI Sliders with custom styles
Stars: ✭ 241 (-72.36%)
Mutual labels:  apple, xcode, tvos, watchos
Swiftui Charts
🚀 SwiftUI Charts with custom styles
Stars: ✭ 272 (-68.81%)
Mutual labels:  apple, xcode, tvos, watchos
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (-11.24%)
Mutual labels:  apple, xcode, tvos, watchos
Swiftui Shapes
🚀 Collection of SwiftUI shapes
Stars: ✭ 137 (-84.29%)
Mutual labels:  apple, xcode, tvos, watchos
Wells
A lightweight diagnostics report submission system
Stars: ✭ 26 (-97.02%)
Mutual labels:  apple, tvos, watchos
TermiNetwork
🌏 A zero-dependency networking solution for building modern and secure iOS, watchOS, macOS and tvOS applications.
Stars: ✭ 80 (-90.83%)
Mutual labels:  apple, tvos, watchos
Open Source Ios Apps
📱 Collaborative List of Open-Source iOS Apps
Stars: ✭ 28,826 (+3205.73%)
Mutual labels:  apple, tvos, watchos
Objc Sdk
LeanCloud Objective-C SDK
Stars: ✭ 186 (-78.67%)
Mutual labels:  apple, tvos, watchos
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-66.28%)
Mutual labels:  apple, tvos, watchos
Rome
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Stars: ✭ 724 (-16.97%)
Mutual labels:  apple, tvos, watchos
Exhibit
Exhibit is a managed screensaver App for tvOS.
Stars: ✭ 19 (-97.82%)
Mutual labels:  apple, xcode, tvos
Stringz
A lightweight and powerful editor for localizing iOS, macOS, tvOS, and watchOS applications.
Stars: ✭ 440 (-49.54%)
Mutual labels:  xcode, tvos, watchos
Apprepositorytemplate
The easiest way to start a new application project without any manual configuration
Stars: ✭ 24 (-97.25%)
Mutual labels:  xcode, tvos, watchos
Wwdc
You don't have the time to watch all the WWDC session videos yourself? No problem me and many contributors extracted the gist for you 🥳
Stars: ✭ 2,561 (+193.69%)
Mutual labels:  apple, tvos, watchos
SwiftGenStrings
genstrings replacement for Swift that actually works
Stars: ✭ 29 (-96.67%)
Mutual labels:  apple, tvos, watchos
Human Interface Guidelines Extras
Community additions to Apple's Human Interface Guidelines
Stars: ✭ 225 (-74.2%)
Mutual labels:  apple, tvos, watchos
Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (-37.04%)
Mutual labels:  xcode, tvos, watchos
Apple Runtime Headers
Objective-C runtime headers for Apple's iOS, macOS, tvOS and watchOS frameworks
Stars: ✭ 174 (-80.05%)
Mutual labels:  apple, tvos, watchos
Wwdc Notes
WWDCNotes.com content ✨
Stars: ✭ 183 (-79.01%)
Mutual labels:  apple, tvos, watchos
Solarized Dark For Xcode
Solarized Dark Theme for Xcode. Compatible with all modern versions of Xcode since 2013!
Stars: ✭ 358 (-58.94%)
Mutual labels:  xcode, tvos, watchos

Build Status

SwiftUI Grid

SwiftUI Grid view layout with custom styles.

Features

  • ZStack based layout
  • Vertical and horizontal scrolling
  • Supports all apple platforms
  • Custom styles (ModularGridStyle, StaggeredGridStyle)
  • SwiftUI code patterns (StyleStructs, EnvironmentValues, ViewBuilder)
  • Active development for production apps

Open GridDemo.xcodeproj for more examples for iOS, macOS, watchOS and tvOS

Styles

ModularGridStyle (Default)

ScrollView {
    Grid(colors) {
        Rectangle()
            .foregroundColor($0)
    }
}
.gridStyle(
    ModularGridStyle(columns: .min(100), rows: .fixed(100))
)

StaggeredGridStyle

ScrollView {
    Grid(1...69, id: \.self) { index in
        Image("\(index)")
            .resizable()
            .scaledToFit()
    }
}
.gridStyle(
    StaggeredGridStyle(.horizontal, tracks: 8, spacing: 4)
)

Tracks

Tracks setting allows you to customize grid behaviour to your specific use-case. Both Modular and Staggered grid use tracks value to calculate layout. In Modular layout both columns and rows are tracks.

public enum Tracks: Hashable {
    case count(Int)
    case fixed(CGFloat)
    case min(CGFloat)
}

Count

Grid is split into equal fractions of size provided by a parent view.

ModularGridStyle(columns: 3, rows: 3)
StaggeredGridStyle(tracks: 8)

Fixed

Item size is fixed to a specific width or height.

ModularGridStyle(columns: .fixed(100), rows: .fixed(100))
StaggeredGridStyle(tracks: .fixed(100))

Min

Autolayout respecting a min item width or height.

ModularGridStyle(columns: .min(100), rows: .fixed(100))
StaggeredGridStyle(tracks: .min(100))

Preferences

Get item size and position with preferences

struct CardsView: View {
    @State var selection: Int = 0
    
    var body: some View {
        ScrollView {
            Grid(0..<100) { number in
                Card(title: "\(number)")
                    .onTapGesture {
                        self.selection = number
                    }
            }
            .padding()
            .overlayPreferenceValue(GridItemBoundsPreferencesKey.self) { preferences in
                RoundedRectangle(cornerRadius: 16)
                    .strokeBorder(lineWidth: 4)
                    .foregroundColor(.white)
                    .frame(
                        width: preferences[self.selection].width,
                        height: preferences[self.selection].height
                    )
                    .position(
                        x: preferences[self.selection].midX,
                        y: preferences[self.selection].midY
                    )
                    .animation(.linear)
            }
        }
    }
}

SDKs

  • iOS 13.1+
  • Mac Catalyst 13.1+
  • macOS 10.15+
  • watchOS 6+
  • Xcode 11.0+

Roadmap

  • Items span
  • 'CSS Grid'-like features

Code Contributions

Feel free to contribute via fork/pull request to master branch. If you want to request a feature or report a bug please start a new issue.

Coffee Contributions

If you find this project useful please consider becoming my GitHub sponsor.

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