Skip to content

Commit 55fbc3b

Browse files
committed
update settings view
- add links section - update info section
1 parent fbacade commit 55fbc3b

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

CriticalMapsKit/Sources/SettingsFeature/SettingsForm.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public struct SettingsForm<Content>: View where Content: View {
2323

2424
// MARK: Row
2525

26-
struct SettingsRow<Content>: View where Content: View {
26+
struct SettingsRow<Content: View>: View {
2727
let content: () -> Content
2828

2929
init(@ViewBuilder content: @escaping () -> Content) {
@@ -51,7 +51,7 @@ struct SettingsRow<Content>: View where Content: View {
5151
// MARK: Section
5252

5353
/// A view to wrap a form section.
54-
public struct SettingsSection<Content>: View where Content: View {
54+
public struct SettingsSection<Content: View>: View {
5555
let content: () -> Content
5656
let padContents: Bool
5757
let title: String
@@ -84,13 +84,13 @@ public struct SettingsSection<Content>: View where Content: View {
8484
// MARK: SettingsNavigationLink
8585

8686
/// A view to that wraps the input view in a SettingsRow and NavigationLink
87-
public struct SettingsNavigationLink<Destination>: View where Destination: View {
87+
public struct SettingsNavigationLink<Destination: View, Label: View>: View {
8888
let destination: Destination
89-
let title: String
89+
let title: () -> Label
9090

9191
public init(
9292
destination: Destination,
93-
title: String
93+
@ViewBuilder title: @escaping () -> Label
9494
) {
9595
self.destination = destination
9696
self.title = title
@@ -107,7 +107,7 @@ public struct SettingsNavigationLink<Destination>: View where Destination: View
107107

108108
var content: some View {
109109
HStack {
110-
Text(self.title)
110+
title()
111111
.font(.titleOne)
112112
Spacer()
113113
Image(systemName: "chevron.forward")

CriticalMapsKit/Sources/SettingsFeature/SettingsView.swift

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public struct SettingsView: View {
5959
action: \.rideevent
6060
)
6161
),
62-
title: L10n.Settings.eventSettings
62+
title: { Text(L10n.Settings.eventSettings) }
6363
)
6464

6565
SettingsNavigationLink(
@@ -69,13 +69,20 @@ public struct SettingsView: View {
6969
action: \.appearance
7070
)
7171
),
72-
title: L10n.Settings.Theme.appearance
72+
title: { Text(L10n.Settings.Theme.appearance) }
7373
)
7474
}
7575

7676
supportSection
7777

7878
infoSection
79+
80+
linksSection
81+
82+
HStack {
83+
appVersionAndBuildView
84+
Spacer()
85+
}
7986
}
8087
}
8188
.navigationTitle(L10n.Settings.title)
@@ -184,8 +191,9 @@ public struct SettingsView: View {
184191
}
185192
}
186193

187-
var infoSection: some View {
188-
SettingsSection(title: L10n.Settings.Section.info) {
194+
@ViewBuilder
195+
var linksSection: some View {
196+
SettingsSection(title: "Links") {
189197
SettingsRow {
190198
Button(
191199
action: { viewStore.send(.infoSectionRowTapped(.website)) },
@@ -215,20 +223,28 @@ public struct SettingsView: View {
215223
)
216224
.accessibilityAddTraits(.isLink)
217225
}
218-
226+
}
227+
}
228+
229+
@ViewBuilder
230+
var infoSection: some View {
231+
SettingsSection(title: L10n.Settings.Section.info) {
219232
SettingsNavigationLink(
220233
destination: GuideView(),
221-
title: L10n.Rules.title
234+
title: {
235+
HStack(spacing: .grid(2)) {
236+
Text(L10n.Rules.title)
237+
Image(systemName: "exclamationmark.bubble")
238+
}
239+
}
222240
)
223241

224242
if let acknowledgementsPlistPath = viewStore.acknowledgementsPlistPath {
225243
SettingsNavigationLink(
226244
destination: AcknowListSwiftUIView(plistPath: acknowledgementsPlistPath),
227-
title: "Acknowledgements"
245+
title: { Text("Acknowledgements") }
228246
)
229247
}
230-
231-
appVersionAndBuildView
232248
}
233249
}
234250

@@ -279,14 +295,12 @@ struct SettingsInfoLink: View {
279295
}
280296

281297
#Preview {
282-
Preview {
283-
NavigationView {
284-
SettingsView(
285-
store: .init(
286-
initialState: .init(userSettings: .init()),
287-
reducer: { SettingsFeature() }
288-
)
298+
NavigationView {
299+
SettingsView(
300+
store: .init(
301+
initialState: .init(userSettings: .init()),
302+
reducer: { SettingsFeature() }
289303
)
290-
}
304+
)
291305
}
292306
}

0 commit comments

Comments
 (0)