This repository has been archived by the owner on Dec 27, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sectioned grid ios * layout and examples
- Loading branch information
Showing
17 changed files
with
345 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import SwiftUI | ||
import Grid | ||
|
||
struct SectionedGridView: View { | ||
var body: some View { | ||
ScrollView { | ||
ForEach(1..<8) { section in | ||
Section { | ||
HStack { | ||
Text("Section \(section)").font(.headline).fontWeight(.bold) | ||
Spacer() | ||
} | ||
|
||
Grid(self.rangeFor(section: section), id: \.self) { index in | ||
Rectangle() | ||
.foregroundColor(.clear) | ||
.background( | ||
Image("\(index)") | ||
.renderingMode(.original) | ||
.resizable() | ||
.scaledToFill() | ||
) | ||
.clipped() | ||
.clipShape(RoundedRectangle(cornerRadius: 4)) | ||
} | ||
|
||
Spacer(minLength: 16) | ||
} | ||
} | ||
|
||
.padding(8) | ||
} | ||
.navigationBarTitle("Sectioned Grid", displayMode: .inline) | ||
.gridStyle( | ||
ModularGridStyle(columns: .min(80), rows: .fixed(80), spacing: 4) | ||
) | ||
} | ||
|
||
private func rangeFor(section: Int) -> Range<Int> { | ||
switch section { | ||
case 1: return Range(1...10) | ||
case 2: return Range(11...15) | ||
case 3: return Range(16...26) | ||
case 4: return Range(27...35) | ||
case 5: return Range(36...38) | ||
case 6: return Range(39...55) | ||
case 7: return Range(56...69) | ||
default: | ||
fatalError() | ||
} | ||
} | ||
} | ||
|
||
struct SectionedGridView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
SectionedGridView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import SwiftUI | ||
import Grid | ||
|
||
struct StaticGridView: View { | ||
var body: some View { | ||
ScrollView { | ||
Grid { | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
} | ||
.padding(16) | ||
.frame(height: 300) | ||
} | ||
.navigationBarTitle("Static Grid", displayMode: .inline) | ||
.gridStyle( | ||
ModularGridStyle(columns: 5, rows: 2, spacing: 16) | ||
) | ||
} | ||
} | ||
|
||
struct StaticGridView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
StaticGridView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import SwiftUI | ||
import Grid | ||
|
||
struct StaticGridView: View { | ||
var body: some View { | ||
ScrollView { | ||
Grid { | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
Capsule().foregroundColor(.random) | ||
} | ||
.padding(16) | ||
.frame(height: 300) | ||
} | ||
.gridStyle( | ||
ModularGridStyle(columns: 5, rows: 2, spacing: 16) | ||
) | ||
} | ||
} | ||
|
||
struct StaticGridView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
StaticGridView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.