Skip to content

Commit a3a68e3

Browse files
committed
Fix background color
1 parent 19b5af4 commit a3a68e3

3 files changed

Lines changed: 27 additions & 28 deletions

File tree

Sources/SettingEnvironment.swift

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ private struct AccentColorKey: EnvironmentKey {
2020
static let defaultValue = Color.accentColor
2121
}
2222

23-
private struct SecondaryBackgroundColorKey: EnvironmentKey {
23+
private struct BackgroundColorKey: EnvironmentKey {
2424
static let defaultValue: Color = {
2525
#if os(iOS)
26-
return Color(uiColor: .secondarySystemGroupedBackground)
26+
return Color(uiColor: .systemGroupedBackground)
2727
#else
28-
return Color(nsColor: .textBackgroundColor)
28+
return Color(nsColor: .windowBackgroundColor)
2929
#endif
3030
}()
3131
}
3232

33-
private struct BackgroundColorKey: EnvironmentKey {
33+
private struct SecondaryBackgroundColorKey: EnvironmentKey {
3434
static let defaultValue: Color = {
3535
#if os(iOS)
36-
return Color(uiColor: .systemGroupedBackground)
36+
return Color(uiColor: .secondarySystemGroupedBackground)
3737
#else
38-
return Color(nsColor: .windowBackgroundColor)
38+
return Color(nsColor: .textBackgroundColor)
3939
#endif
4040
}()
4141
}
@@ -60,44 +60,43 @@ extension EnvironmentValues {
6060
}
6161

6262
/// For outer views.
63-
var settingSecondaryBackgroundColor: Color {
64-
get { self[SecondaryBackgroundColorKey.self] }
65-
set { self[SecondaryBackgroundColorKey.self] = newValue }
66-
}
67-
68-
/// For inner views.
6963
var settingBackgroundColor: Color {
7064
get { self[BackgroundColorKey.self] }
7165
set { self[BackgroundColorKey.self] = newValue }
7266
}
73-
}
7467

68+
/// For inner views.
69+
var settingSecondaryBackgroundColor: Color {
70+
get { self[SecondaryBackgroundColorKey.self] }
71+
set { self[SecondaryBackgroundColorKey.self] = newValue }
72+
}
73+
}
7574

76-
//var settingPrimaryColor: Color {
75+
// var settingPrimaryColor: Color {
7776
// get { self[PrimaryColorKey.self] }
7877
// set { self[PrimaryColorKey.self] = newValue }
79-
//}
78+
// }
8079
//
8180
///// For secondary labels.
82-
//var settingSecondaryColor: Color {
81+
// var settingSecondaryColor: Color {
8382
// get { self[SecondaryColorKey.self] }
8483
// set { self[SecondaryColorKey.self] = newValue }
85-
//}
84+
// }
8685
//
8786
///// For buttons.
88-
//var settingAccentColor: Color {
87+
// var settingAccentColor: Color {
8988
// get { self[AccentColorKey.self] }
9089
// set { self[AccentColorKey.self] = newValue }
91-
//}
90+
// }
9291
//
9392
///// For outer views.
94-
//var settingSecondaryBackgroundColor: Color {
93+
// var settingSecondaryBackgroundColor: Color {
9594
// get { self[SecondaryBackgroundColorKey.self] }
9695
// set { self[SecondaryBackgroundColorKey.self] = newValue }
97-
//}
96+
// }
9897
//
9998
///// For inner views.
100-
//var settingBackgroundColor: Color {
99+
// var settingBackgroundColor: Color {
101100
// get { self[BackgroundColorKey.self] }
102101
// set { self[BackgroundColorKey.self] = newValue }
103-
//}
102+
// }

Sources/Views/SettingGroup.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct SettingGroup: Setting {
4949
}
5050

5151
public struct SettingGroupView<Content: View>: View {
52-
@Environment(\.settingBackgroundColor) var settingBackgroundColor
52+
@Environment(\.settingSecondaryBackgroundColor) var settingSecondaryBackgroundColor
5353
@Environment(\.settingSecondaryColor) var settingSecondaryColor
5454

5555
public var icon: SettingIcon?
@@ -117,7 +117,7 @@ public struct SettingGroupView<Content: View>: View {
117117
) {
118118
content()
119119
}
120-
.background(backgroundColor ?? settingBackgroundColor)
120+
.background(backgroundColor ?? settingSecondaryBackgroundColor)
121121
.cornerRadius(backgroundCornerRadius)
122122

123123
if let footer {

Sources/Views/SettingPage.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public extension SettingPage {
9898
}
9999

100100
struct SettingPageView<Content>: View where Content: View {
101-
@Environment(\.settingSecondaryBackgroundColor) var settingSecondaryBackgroundColor
101+
@Environment(\.settingBackgroundColor) var settingBackgroundColor
102102

103103
var title: String
104104
var spacing = CGFloat(20)
@@ -143,7 +143,7 @@ struct SettingPageView<Content>: View where Content: View {
143143
.padding(.vertical, verticalPadding)
144144
}
145145
.scrollDismissesKeyboard(.interactively)
146-
.background(backgroundColor)
146+
.background(backgroundColor ?? settingBackgroundColor)
147147
.navigationTitle(title)
148148
} else {
149149
ScrollView {
@@ -153,7 +153,7 @@ struct SettingPageView<Content>: View where Content: View {
153153
.frame(maxWidth: .infinity, alignment: .leading)
154154
.padding(.vertical, verticalPadding)
155155
}
156-
.background(backgroundColor ?? settingSecondaryBackgroundColor)
156+
.background(backgroundColor ?? settingBackgroundColor)
157157
.navigationTitle(title)
158158
}
159159
}

0 commit comments

Comments
 (0)