Skip to content

Commit dafb9e8

Browse files
committed
feat: Readable content width sample
1 parent 01a2b97 commit dafb9e8

File tree

6 files changed

+49
-42
lines changed

6 files changed

+49
-42
lines changed

GoodSwiftUI-Sample/GoodSwiftUI-Sample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
09794E3A2C295F4600023CD1 /* InputFieldViewConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09794E392C295F4600023CD1 /* InputFieldViewConfiguration.swift */; };
1111
09794E3C2C2ADAFE00023CD1 /* InputFieldSampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09794E3B2C2ADAFE00023CD1 /* InputFieldSampleView.swift */; };
12+
09B493CD2C986F1800C66743 /* ReadableContentWidthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09B493CC2C986F1400C66743 /* ReadableContentWidthView.swift */; };
1213
3F9F28442A3AEC6000D92CA2 /* SamplesListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F9F28432A3AEC6000D92CA2 /* SamplesListView.swift */; };
1314
3F9F28462A3AEC8B00D92CA2 /* GRAsyncImageSampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F9F28452A3AEC8B00D92CA2 /* GRAsyncImageSampleView.swift */; };
1415
3F9F28482A3AECC700D92CA2 /* GRAsyncImage in Frameworks */ = {isa = PBXBuildFile; productRef = 3F9F28472A3AECC700D92CA2 /* GRAsyncImage */; };
@@ -21,6 +22,7 @@
2122
/* Begin PBXFileReference section */
2223
09794E392C295F4600023CD1 /* InputFieldViewConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputFieldViewConfiguration.swift; sourceTree = "<group>"; };
2324
09794E3B2C2ADAFE00023CD1 /* InputFieldSampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputFieldSampleView.swift; sourceTree = "<group>"; };
25+
09B493CC2C986F1400C66743 /* ReadableContentWidthView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReadableContentWidthView.swift; sourceTree = "<group>"; };
2426
3F9F28432A3AEC6000D92CA2 /* SamplesListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SamplesListView.swift; sourceTree = "<group>"; };
2527
3F9F28452A3AEC8B00D92CA2 /* GRAsyncImageSampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GRAsyncImageSampleView.swift; sourceTree = "<group>"; };
2628
5D740EA929B0BE0100975B8C /* GoodSwiftUI-Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "GoodSwiftUI-Sample.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -55,6 +57,7 @@
5557
3F9F28422A3AEC5200D92CA2 /* Screens */ = {
5658
isa = PBXGroup;
5759
children = (
60+
09B493CC2C986F1400C66743 /* ReadableContentWidthView.swift */,
5861
3F9F28432A3AEC6000D92CA2 /* SamplesListView.swift */,
5962
3F9F28452A3AEC8B00D92CA2 /* GRAsyncImageSampleView.swift */,
6063
09794E3B2C2ADAFE00023CD1 /* InputFieldSampleView.swift */,
@@ -182,6 +185,7 @@
182185
isa = PBXSourcesBuildPhase;
183186
buildActionMask = 2147483647;
184187
files = (
188+
09B493CD2C986F1800C66743 /* ReadableContentWidthView.swift in Sources */,
185189
5D740EAD29B0BE0100975B8C /* AppDelegate.swift in Sources */,
186190
09794E3A2C295F4600023CD1 /* InputFieldViewConfiguration.swift in Sources */,
187191
3F9F28462A3AEC8B00D92CA2 /* GRAsyncImageSampleView.swift in Sources */,

GoodSwiftUI-Sample/GoodSwiftUI-Sample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GoodSwiftUI-Sample/GoodSwiftUI-Sample/Screens/GRAsyncImageSampleView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct GRAsyncImageSampleView: View {
2929
.border(.red)
3030
}
3131
.padding()
32+
.navigationTitle("Async Image")
3233
}
3334

3435
}

GoodSwiftUI-Sample/GoodSwiftUI-Sample/Screens/InputFieldSampleView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ struct InputFieldSampleView: View {
8888
.padding()
8989
}
9090
.scrollDismissesKeyboard(.interactively)
91+
.navigationTitle("Input fields")
9192
}
9293

9394
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// ReadableContentWidth.swift
3+
// GoodSwiftUI-Sample
4+
//
5+
// Created by Filip Šašala on 16/09/2024.
6+
//
7+
8+
import GoodSwiftUI
9+
import SwiftUI
10+
11+
struct ReadableContentWidthView: View {
12+
13+
var body: some View {
14+
Rectangle()
15+
.foregroundStyle(.red.gradient)
16+
.fittingReadableWidth()
17+
.navigationTitle("Readable content width")
18+
}
19+
20+
}

GoodSwiftUI-Sample/GoodSwiftUI-Sample/Screens/SamplesListView.swift

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,6 @@
77

88
import SwiftUI
99

10-
// MARK: - Samples
11-
12-
enum Sample: CaseIterable, Identifiable, Hashable {
13-
14-
var id: String { UUID().uuidString }
15-
16-
case grAsyncImage
17-
case inputFields
18-
19-
var title: String {
20-
switch self {
21-
case .grAsyncImage:
22-
"Async Image"
23-
24-
case .inputFields:
25-
"Input fields"
26-
}
27-
}
28-
29-
var view: some View {
30-
Group {
31-
switch self {
32-
case .grAsyncImage:
33-
GRAsyncImageSampleView()
34-
35-
case .inputFields:
36-
InputFieldSampleView()
37-
}
38-
}
39-
.navigationTitle(self.title)
40-
}
41-
42-
}
43-
4410
// MARK: - Samples List View
4511

4612
struct SamplesListView: View {
@@ -49,11 +15,26 @@ struct SamplesListView: View {
4915

5016
var body: some View {
5117
NavigationStack {
52-
List(Sample.allCases) { example in
53-
NavigationLink(example.title, value: example)
18+
List {
19+
NavigationLink {
20+
GRAsyncImageSampleView()
21+
} label: {
22+
Text("Async Image")
23+
}
24+
25+
NavigationLink {
26+
InputFieldSampleView()
27+
} label: {
28+
Text("Input fields")
29+
}
30+
31+
NavigationLink {
32+
ReadableContentWidthView()
33+
} label: {
34+
Text("Readable content width")
35+
}
5436
}
5537
.navigationTitle("Samples")
56-
.navigationDestination(for: Sample.self) { $0.view }
5738
}
5839
}
5940

0 commit comments

Comments
 (0)