Skip to content

Commit 730a88f

Browse files
committed
Use system theme
1 parent b9ce4e2 commit 730a88f

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

Sources/CommandBarIOS/Components/Buttons/Button.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import SwiftUI
22

33
struct CMDButton: View {
4+
@Environment(\.colorScheme) var colorScheme
5+
46
var title: String
57
var variant: NudgeContentButtonBlockMeta.ButtonType?
68
var fullWidth: Bool = false
79
var action: (() -> Void)?
810

911
var backgroundColor: Color {
10-
return (variant ?? .primary) == .primary ? Color.black : Color.white
12+
return (variant ?? .primary) == .primary ? colorScheme == .dark ? Color(UIColor.systemBackground.lighter(by: 15)!) : Color.black : Color.white
1113
}
1214

1315
var foregroundColor: Color {
1416
return (variant ?? .primary) == .primary ? Color.white : Color.black
1517
}
1618

1719
var borderColor: Color {
18-
return (variant ?? .primary) == .primary ? Color.black : Color.gray.opacity(0.5)
20+
return (variant ?? .primary) == .primary ? colorScheme == .dark ? Color(UIColor.systemBackground.lighter(by: 15)!) : Color.black : Color.gray.opacity(0.5)
1921
}
2022

2123
var body: some View {

Sources/CommandBarIOS/Components/Buttons/ButtonGroup.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ enum ButtonGroupVariant {
88
}
99

1010
struct ButtonGroupView<Option, Content: View>: View {
11+
@Environment(\.colorScheme) var colorScheme
12+
1113
let variant: ButtonGroupVariant
1214
let options: [Option]
1315
let content: (Option, Bool) -> Content
@@ -29,6 +31,7 @@ struct ButtonGroupView<Option, Content: View>: View {
2931
}) {
3032
content(options[index], isSelected)
3133
}.frame(maxWidth: .infinity)
34+
3235
}
3336
}
3437
}

Sources/CommandBarIOS/Nudges/Content/SurveyRatingBlock.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import SwiftUI
22

33

44
struct StarButtons: View {
5+
@Environment(\.colorScheme) var colorScheme
6+
57
@Binding var selection: Int;
68

79
let action: () -> Void;
@@ -19,6 +21,7 @@ struct StarButtons: View {
1921

2022
ButtonGroupView(variant: .inclusive, options: stars, selection: $selection) { option, isSelected in
2123
ZStack {
24+
2225
Image(systemName: "star")
2326
.resizable()
2427
.scaledToFit()
@@ -29,22 +32,22 @@ struct StarButtons: View {
2932
.resizable()
3033
.scaledToFit()
3134
.frame(width: isSelected ? 20 : 24, height: isSelected ? 20 : 24) // Original size
32-
.foregroundColor(isSelected ? activeStarColor : starColor)
35+
.foregroundColor(isSelected ? activeStarColor : colorScheme == .dark ? .gray.opacity(0.8) : starColor)
3336
}
3437
.frame(maxWidth: .infinity)
3538
.padding(.vertical, 8)
36-
.background(isSelected ? activeBackgroundColor : backgroundColor)
37-
.foregroundColor(.white)
39+
.foregroundColor(colorScheme == .dark ? Color(UIColor.systemBackground.lighter(by: 15)!) : .white)
3840
.cornerRadius(4)
3941
.overlay(
4042
RoundedRectangle(cornerRadius: 4)
41-
.stroke(isSelected ? activeBorderColor : borderColor, lineWidth: 1)
43+
.stroke(isSelected ? activeBorderColor : colorScheme == .dark ? .gray.opacity(0.8) : borderColor, lineWidth: 1)
4244
)
4345
}
4446
}
4547
}
4648

4749
struct EmojiButtons: View {
50+
@Environment(\.colorScheme) var colorScheme
4851
@Binding var selection: Int;
4952

5053
let action: () -> Void;
@@ -62,18 +65,19 @@ struct EmojiButtons: View {
6265
.shadow(color: .init(.sRGB, red: 0, green: 0, blue: 0, opacity: isSelected ? 0.35 : 0), radius: 7, x: 0, y: 4)
6366
.frame(maxWidth: .infinity)
6467
.padding(.vertical, 8)
65-
.background(isSelected ? activeBackgroundColor : backgroundColor)
66-
.foregroundColor(.white)
68+
.background(isSelected ? activeBackgroundColor : colorScheme == .dark ? Color(UIColor.systemBackground.lighter(by: 15)!) : .white)
69+
.foregroundColor( colorScheme == .dark && !isSelected ? .white : .black)
6770
.cornerRadius(4)
6871
.overlay(
6972
RoundedRectangle(cornerRadius: 4)
70-
.stroke(isSelected ? activeBorderColor : borderColor, lineWidth: 1)
73+
.stroke(isSelected ? activeBorderColor : colorScheme == .dark ? .gray.opacity(0.8) : borderColor, lineWidth: 1)
7174
)
7275
}
7376
}
7477
}
7578

7679
struct NumberButtons: View {
80+
@Environment(\.colorScheme) var colorScheme
7781
@Binding var selection: Int;
7882

7983
let action: () -> Void;
@@ -91,12 +95,12 @@ struct NumberButtons: View {
9195
Text(option)
9296
.frame(maxWidth: .infinity)
9397
.padding(.vertical, 8)
94-
.background(isSelected ? activeBackgroundColor : backgroundColor)
95-
.foregroundColor(.black)
98+
.background(isSelected ? activeBackgroundColor : colorScheme == .dark ? Color(UIColor.systemBackground.lighter(by: 15)!) : .white)
99+
.foregroundColor( colorScheme == .dark && !isSelected ? .white : .black)
96100
.cornerRadius(4)
97101
.overlay(
98102
RoundedRectangle(cornerRadius: 4)
99-
.stroke(isSelected ? activeBorderColor : borderColor, lineWidth: 1)
103+
.stroke(isSelected ? activeBorderColor : colorScheme == .dark ? .gray.opacity(0.8) : borderColor, lineWidth: 1)
100104
)
101105
}
102106
}

Sources/CommandBarIOS/Nudges/NudgeView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import SwiftUI
22

33
struct NudgeView: View {
4+
@Environment(\.colorScheme) var colorScheme
5+
46
let nudge: Nudge
57
let step: NudgeStep
68
let stepIndex: Int
@@ -116,7 +118,7 @@ struct NudgeView: View {
116118
ContentStack
117119
}
118120
.padding()
119-
.background(Color(UIColor.systemBackground))
121+
.background(colorScheme == .dark ? Color(UIColor.systemBackground.lighter(by: 10)!) : Color.white)
120122
.cornerRadius(cornerRadius)
121123
.scaleEffect(self.appear == 1 ? 1 : 0)
122124
.onAppear {

0 commit comments

Comments
 (0)