Skip to content

Commit

Permalink
update settings view
Browse files Browse the repository at this point in the history
- add links section
- update info section
  • Loading branch information
mltbnz committed Oct 9, 2024
1 parent fbacade commit 55fbc3b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
12 changes: 6 additions & 6 deletions CriticalMapsKit/Sources/SettingsFeature/SettingsForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public struct SettingsForm<Content>: View where Content: View {

// MARK: Row

struct SettingsRow<Content>: View where Content: View {
struct SettingsRow<Content: View>: View {
let content: () -> Content

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

/// A view to wrap a form section.
public struct SettingsSection<Content>: View where Content: View {
public struct SettingsSection<Content: View>: View {
let content: () -> Content
let padContents: Bool
let title: String
Expand Down Expand Up @@ -84,13 +84,13 @@ public struct SettingsSection<Content>: View where Content: View {
// MARK: SettingsNavigationLink

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

public init(
destination: Destination,
title: String
@ViewBuilder title: @escaping () -> Label
) {
self.destination = destination
self.title = title
Expand All @@ -107,7 +107,7 @@ public struct SettingsNavigationLink<Destination>: View where Destination: View

var content: some View {
HStack {
Text(self.title)
title()
.font(.titleOne)
Spacer()
Image(systemName: "chevron.forward")
Expand Down
48 changes: 31 additions & 17 deletions CriticalMapsKit/Sources/SettingsFeature/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct SettingsView: View {
action: \.rideevent
)
),
title: L10n.Settings.eventSettings
title: { Text(L10n.Settings.eventSettings) }
)

SettingsNavigationLink(
Expand All @@ -69,13 +69,20 @@ public struct SettingsView: View {
action: \.appearance
)
),
title: L10n.Settings.Theme.appearance
title: { Text(L10n.Settings.Theme.appearance) }
)
}

supportSection

infoSection

linksSection

HStack {
appVersionAndBuildView
Spacer()
}
}
}
.navigationTitle(L10n.Settings.title)
Expand Down Expand Up @@ -184,8 +191,9 @@ public struct SettingsView: View {
}
}

var infoSection: some View {
SettingsSection(title: L10n.Settings.Section.info) {
@ViewBuilder
var linksSection: some View {
SettingsSection(title: "Links") {
SettingsRow {
Button(
action: { viewStore.send(.infoSectionRowTapped(.website)) },
Expand Down Expand Up @@ -215,20 +223,28 @@ public struct SettingsView: View {
)
.accessibilityAddTraits(.isLink)
}

}
}

@ViewBuilder
var infoSection: some View {
SettingsSection(title: L10n.Settings.Section.info) {
SettingsNavigationLink(
destination: GuideView(),
title: L10n.Rules.title
title: {
HStack(spacing: .grid(2)) {
Text(L10n.Rules.title)
Image(systemName: "exclamationmark.bubble")
}
}
)

if let acknowledgementsPlistPath = viewStore.acknowledgementsPlistPath {
SettingsNavigationLink(
destination: AcknowListSwiftUIView(plistPath: acknowledgementsPlistPath),
title: "Acknowledgements"
title: { Text("Acknowledgements") }
)
}

appVersionAndBuildView
}
}

Expand Down Expand Up @@ -279,14 +295,12 @@ struct SettingsInfoLink: View {
}

#Preview {
Preview {
NavigationView {
SettingsView(
store: .init(
initialState: .init(userSettings: .init()),
reducer: { SettingsFeature() }
)
NavigationView {
SettingsView(
store: .init(
initialState: .init(userSettings: .init()),
reducer: { SettingsFeature() }
)
}
)
}
}

0 comments on commit 55fbc3b

Please sign in to comment.