Skip to content

Commit a22444f

Browse files
Conjugate settings (#631)
* add conjugate Settings tab contents #609 * enable Conjugate Settings dark mode feature #609 * enable increase text size Conjugate Settings tab #609 * enable App language Conjugate Settings #609 --------- Co-authored-by: Andrew Tavis McAllister <andrew.t.mcallister@gmail.com>
1 parent 053ab95 commit a22444f

3 files changed

Lines changed: 164 additions & 96 deletions

File tree

Conjugate/ConjugateApp.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ import SwiftUI
44

55
@main
66
struct ConjugateApp: App {
7+
@AppStorage("isDarkMode") private var isDarkMode = false
8+
@AppStorage("increaseTextSize") private var increaseTextSize = false
79
var body: some Scene {
810
WindowGroup {
911
ContentView()
12+
.preferredColorScheme(isDarkMode ? .dark : .light)
13+
.dynamicTypeSize(increaseTextSize ? .xLarge : .medium)
1014
}
1115
}
1216
}

Conjugate/Views/Tabs/Settings/SettingsTab.swift

Lines changed: 160 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,168 @@
33
import SwiftUI
44

55
struct SettingsTab: View {
6+
@AppStorage("isDarkMode") private var isDarkMode = false
7+
@AppStorage("increaseTextSize") private var increaseTextSize = false
8+
@State private var isHighContrast = false
9+
10+
var language: String {
11+
let langId = Locale.preferredLanguages.first ?? ""
12+
let langCode = langId.components(separatedBy: "-").first ?? ""
13+
let langLocale = Locale(identifier: langCode)
14+
15+
return langLocale.localizedString(forIdentifier: langCode)?.capitalized
16+
?? ""
17+
}
18+
619
var body: some View {
720
AppNavigation {
8-
Text("Settings")
9-
.font(.largeTitle)
10-
.navigationTitle("Settings")
21+
ZStack(alignment: .top) {
22+
Color.scribeBlue
23+
.ignoresSafeArea()
24+
VStack(alignment: .leading) {
25+
Text(
26+
NSLocalizedString(
27+
"i18n.app.settings.menu.title",
28+
value: "App settings",
29+
comment: ""
30+
),
31+
)
32+
.padding(.horizontal)
33+
.padding(.top, 20)
34+
.font(.title3.weight(.semibold))
35+
VStack(spacing: 20) {
36+
SettingsNavigationRow(
37+
title: NSLocalizedString(
38+
"i18n.app.settings.menu.app_language",
39+
value: "App language",
40+
comment: "",
41+
),
42+
caption: NSLocalizedString(
43+
"i18n.app.settings.menu.app_language_description",
44+
value: "Change which language the Scribe app is in.",
45+
comment: "",
46+
),
47+
value: language
48+
)
49+
.onTapGesture {
50+
if let url = URL(string: UIApplication.openSettingsURLString) {
51+
UIApplication.shared.open(url)
52+
}
53+
}
54+
SettingsToggleRow(
55+
title: NSLocalizedString(
56+
"i18n.app.settings.menu.app_color_mode",
57+
value: "Dark mode",
58+
comment: "",
59+
),
60+
caption: NSLocalizedString(
61+
"i18n.app.settings.menu.app_color_mode_description",
62+
value: "Change the application display to dark mode.",
63+
comment: "",
64+
),
65+
isOn: $isDarkMode,
66+
)
67+
SettingsToggleRow(
68+
title: NSLocalizedString(
69+
"i18n.app.settings.menu.increase_text_size",
70+
value: "Increase app text size",
71+
comment: ""
72+
),
73+
caption: NSLocalizedString(
74+
"i18n.app.settings.menu.increase_text_size_description",
75+
value:
76+
"Increase the size of menu texts for better readability.",
77+
comment: ""
78+
),
79+
isOn: $increaseTextSize,
80+
)
81+
SettingsToggleRow(
82+
title: NSLocalizedString(
83+
"i18n.app.settings.menu.high_color_contrast",
84+
value: "High color contrast",
85+
comment: "",
86+
),
87+
caption: NSLocalizedString(
88+
"i18n.app.settings.menu.high_color_contrast_description",
89+
value:
90+
"Increase color contrast for improved accessibility and a clearer viewing experience.",
91+
comment: ""
92+
),
93+
isOn: $isHighContrast,
94+
)
95+
}
96+
.padding()
97+
.frame(maxWidth: .infinity)
98+
.background(Color(.systemBackground))
99+
.cornerRadius(16)
100+
.padding(.horizontal)
101+
}
102+
}
103+
.navigationTitle(
104+
NSLocalizedString(
105+
"i18n.app.settings.title",
106+
value: "Settings",
107+
comment: ""
108+
),
109+
)
110+
}
111+
}
112+
}
113+
114+
struct SettingsNavigationRow: View {
115+
let title: String
116+
let caption: String
117+
let value: String
118+
119+
var body: some View {
120+
VStack(alignment: .leading, spacing: 6) {
121+
122+
HStack {
123+
Text(title)
124+
.font(.body)
125+
126+
Spacer()
127+
128+
HStack {
129+
Text(value)
130+
.font(.body)
131+
.foregroundColor(.secondary)
132+
133+
Image(systemName: "chevron.right")
134+
.foregroundColor(.secondary)
135+
}
136+
}
137+
138+
Text(caption)
139+
.font(.caption)
140+
.foregroundColor(.secondary)
11141
}
12142
}
13143
}
144+
145+
struct SettingsToggleRow: View {
146+
let title: String
147+
let caption: String
148+
@Binding var isOn: Bool
149+
150+
var body: some View {
151+
VStack(alignment: .leading, spacing: 6) {
152+
153+
HStack {
154+
Text(title)
155+
.font(.body)
156+
157+
Spacer()
158+
159+
Toggle("", isOn: $isOn)
160+
.labelsHidden()
161+
.tint(Color.scribeCTA)
162+
}
163+
164+
Text(caption)
165+
.font(.caption)
166+
.foregroundColor(.secondary)
167+
}
168+
169+
}
170+
}

0 commit comments

Comments
 (0)