Skip to content

Commit c36cc69

Browse files
Merge branch 'dev' into modal-swiftui
2 parents 29af48e + ba11ff7 commit c36cc69

File tree

17 files changed

+55
-110
lines changed

17 files changed

+55
-110
lines changed

Examples/DemosApp/DemosApp/ComponentsPreview/Helpers/PreviewWrapper.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ struct PreviewWrapper<Content: View>: View {
55
let title: String
66
@ViewBuilder let content: () -> Content
77

8-
@Environment(\.colorScheme) private var colorScheme
9-
108
var body: some View {
119
ZStack(alignment: Alignment(horizontal: .leading, vertical: .top)) {
1210
self.content()
@@ -21,8 +19,8 @@ struct PreviewWrapper<Content: View>: View {
2119
LinearGradient(
2220
gradient: Gradient(
2321
colors: [
24-
UniversalColor.blue.color(for: self.colorScheme),
25-
UniversalColor.purple.color(for: self.colorScheme),
22+
UniversalColor.blue.color,
23+
UniversalColor.purple.color,
2624
]
2725
),
2826
startPoint: .topLeading,

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/ButtonPreview.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct ButtonPreview: View {
2929
Picker("Style", selection: self.$model.style) {
3030
Text("Filled").tag(ButtonVM.Style.filled)
3131
Text("Plain").tag(ButtonVM.Style.plain)
32+
Text("Light").tag(ButtonVM.Style.light)
3233
Text("Bordered with small border").tag(ButtonVM.Style.bordered(.small))
3334
Text("Bordered with medium border").tag(ButtonVM.Style.bordered(.medium))
3435
Text("Bordered with large border").tag(ButtonVM.Style.bordered(.large))

Examples/DemosApp/DemosApp/Demos/Login/SwiftUILogin.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ struct SwiftUILogin: View {
3434
)
3535
}
3636

37-
@Environment(\.colorScheme) var colorScheme
38-
3937
var body: some View {
4038
ZStack {
41-
UniversalColor.background.color(for: self.colorScheme)
39+
UniversalColor.background.color
4240

4341
ScrollView {
4442
VStack(spacing: 20) {

Sources/ComponentsKit/Components/Button/Models/ButtonStyle.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ extension ButtonVM {
77
case filled
88
/// A button with a transparent background.
99
case plain
10+
/// A button with a partially transparent background.
11+
case light
1012
/// A button with a transparent background and a border.
1113
case bordered(BorderWidth)
1214
}

Sources/ComponentsKit/Components/Button/Models/ButtonVM.swift

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,44 +50,38 @@ public struct ButtonVM: ComponentVM {
5050
// MARK: Shared Helpers
5151

5252
extension ButtonVM {
53-
private var mainColor: UniversalColor {
54-
let color = self.color?.main ?? .content2
55-
return color.enabled(self.isEnabled)
56-
}
57-
private var contrastColor: UniversalColor {
58-
let color = self.color?.contrast ?? .foreground
59-
return color.enabled(self.isEnabled)
60-
}
6153
var backgroundColor: UniversalColor? {
6254
switch self.style {
6355
case .filled:
64-
return self.mainColor
56+
let color = self.color?.main ?? .content2
57+
return color.enabled(self.isEnabled)
58+
case .light:
59+
let color = self.color?.background ?? .content1
60+
return color.enabled(self.isEnabled)
6561
case .plain, .bordered:
6662
return nil
6763
}
6864
}
6965
var foregroundColor: UniversalColor {
70-
switch self.style {
66+
let color = switch self.style {
7167
case .filled:
72-
return self.contrastColor
73-
case .plain:
74-
return self.mainColor
75-
case .bordered:
76-
let color = self.color?.main ?? .foreground
77-
return color.enabled(self.isEnabled)
68+
self.color?.contrast ?? .foreground
69+
case .plain, .light, .bordered:
70+
self.color?.main ?? .foreground
7871
}
72+
return color.enabled(self.isEnabled)
7973
}
8074
var borderWidth: CGFloat {
8175
switch self.style {
82-
case .filled, .plain:
76+
case .filled, .plain, .light:
8377
return 0.0
8478
case .bordered(let borderWidth):
8579
return borderWidth.value
8680
}
8781
}
8882
var borderColor: UniversalColor? {
8983
switch self.style {
90-
case .filled, .plain:
84+
case .filled, .plain, .light:
9185
return nil
9286
case .bordered:
9387
if let color {

Sources/ComponentsKit/Components/Button/SUButton.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ private struct CustomButtonStyle: SwiftUI.ButtonStyle {
6262
.padding(.trailing, self.model.horizontalPadding)
6363
.frame(maxWidth: self.model.width)
6464
.frame(height: self.model.height)
65-
.foregroundStyle(self.model.foregroundColor.color(for: self.colorScheme))
65+
.foregroundStyle(self.model.foregroundColor.color)
6666
.background(
67-
self.model.backgroundColor?.color(for: self.colorScheme) ?? Color.clear
67+
self.model.backgroundColor?.color ?? Color.clear
6868
)
6969
.clipShape(
7070
RoundedRectangle(
@@ -76,7 +76,7 @@ private struct CustomButtonStyle: SwiftUI.ButtonStyle {
7676
cornerRadius: self.model.cornerRadius.value()
7777
)
7878
.stroke(
79-
self.model.borderColor?.color(for: self.colorScheme) ?? .clear,
79+
self.model.borderColor?.color ?? .clear,
8080
lineWidth: self.model.borderWidth
8181
)
8282
}

Sources/ComponentsKit/Components/Checkbox/SUCheckbox.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public struct SUCheckbox: View {
1212

1313
@State private var checkmarkStroke: CGFloat
1414
@State private var borderOpacity: CGFloat
15-
@Environment(\.colorScheme) private var colorScheme
1615

1716
// MARK: Initialization
1817

@@ -35,7 +34,7 @@ public struct SUCheckbox: View {
3534
public var body: some View {
3635
HStack(spacing: self.model.spacing) {
3736
ZStack {
38-
self.model.backgroundColor.color(for: self.colorScheme)
37+
self.model.backgroundColor.color
3938
.clipShape(
4039
RoundedRectangle(cornerRadius: self.model.checkboxCornerRadius)
4140
)
@@ -66,12 +65,12 @@ public struct SUCheckbox: View {
6665
lineCap: .round,
6766
lineJoin: .round
6867
))
69-
.foregroundStyle(self.model.foregroundColor.color(for: self.colorScheme))
68+
.foregroundStyle(self.model.foregroundColor.color)
7069
}
7170
.overlay {
7271
RoundedRectangle(cornerRadius: self.model.checkboxCornerRadius)
7372
.stroke(
74-
self.model.borderColor.color(for: self.colorScheme),
73+
self.model.borderColor.color,
7574
lineWidth: self.model.borderWidth
7675
)
7776
.opacity(self.borderOpacity)
@@ -84,7 +83,7 @@ public struct SUCheckbox: View {
8483

8584
if let title = self.model.title {
8685
Text(title)
87-
.foregroundStyle(self.model.titleColor.color(for: self.colorScheme))
86+
.foregroundStyle(self.model.titleColor.color)
8887
.font(self.model.titleFont.font)
8988
}
9089
}

Sources/ComponentsKit/Components/Countdown/SUCountdown.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public struct SUCountdown: View {
1212
/// The countdown manager handling the countdown logic.
1313
@StateObject private var manager = CountdownManager()
1414

15-
@Environment(\.colorScheme) private var colorScheme
16-
1715
// MARK: - Initializer
1816

1917
/// Initializer.
@@ -86,7 +84,7 @@ public struct SUCountdown: View {
8684
private var colonView: some View {
8785
Text(":")
8886
.font(self.model.preferredMainFont.font)
89-
.foregroundColor(self.model.colonColor.color(for: self.colorScheme))
87+
.foregroundColor(self.model.colonColor.color)
9088
}
9189

9290
private func lightStyledTime(
@@ -97,7 +95,7 @@ public struct SUCountdown: View {
9795
.frame(minHeight: self.model.lightBackgroundMinHight)
9896
.frame(minWidth: self.model.lightBackgroundMinWidth)
9997
.background(RoundedRectangle(cornerRadius: 8)
100-
.fill(self.model.backgroundColor.color(for: self.colorScheme))
98+
.fill(self.model.backgroundColor.color)
10199
)
102100
}
103101
}

Sources/ComponentsKit/Components/Divider/SUDivider.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ public struct SUDivider: View {
77
/// A model that defines the appearance properties.
88
public var model: DividerVM
99

10-
@Environment(\.colorScheme) private var colorScheme
11-
1210
// MARK: - Initialization
1311

1412
/// Initializer.
@@ -22,7 +20,7 @@ public struct SUDivider: View {
2220

2321
public var body: some View {
2422
Rectangle()
25-
.fill(self.model.lineColor.color(for: self.colorScheme))
23+
.fill(self.model.lineColor.color)
2624
.frame(
2725
maxWidth: self.model.orientation == .vertical ? self.model.lineSize : nil,
2826
maxHeight: self.model.orientation == .horizontal ? self.model.lineSize : nil

Sources/ComponentsKit/Components/InputField/SUInputField.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public struct SUInputField<FocusValue: Hashable>: View {
2626
/// text inputs and input fields within the same view can be independently focused based on the shared `globalFocus`.
2727
public var localFocus: FocusValue
2828

29-
@Environment(\.colorScheme) private var colorScheme
30-
3129
// MARK: Initialization
3230

3331
/// Initializer.
@@ -61,18 +59,18 @@ public struct SUInputField<FocusValue: Hashable>: View {
6159
if self.model.isSecureInput {
6260
SecureField(text: self.$text, label: {
6361
Text(self.model.placeholder ?? "")
64-
.foregroundStyle(self.model.placeholderColor.color(for: self.colorScheme))
62+
.foregroundStyle(self.model.placeholderColor.color)
6563
})
6664
} else {
6765
TextField(text: self.$text, label: {
6866
Text(self.model.placeholder ?? "")
69-
.foregroundStyle(self.model.placeholderColor.color(for: self.colorScheme))
67+
.foregroundStyle(self.model.placeholderColor.color)
7068
})
7169
}
7270
}
73-
.tint(self.model.tintColor.color(for: self.colorScheme))
71+
.tint(self.model.tintColor.color)
7472
.font(self.model.preferredFont.font)
75-
.foregroundStyle(self.model.foregroundColor.color(for: self.colorScheme))
73+
.foregroundStyle(self.model.foregroundColor.color)
7674
.focused(self.$globalFocus, equals: self.localFocus)
7775
.disabled(!self.model.isEnabled)
7876
.keyboardType(self.model.keyboardType)
@@ -82,7 +80,7 @@ public struct SUInputField<FocusValue: Hashable>: View {
8280
}
8381
.padding(.horizontal, self.model.horizontalPadding)
8482
.frame(height: self.model.height)
85-
.background(self.model.backgroundColor.color(for: self.colorScheme))
83+
.background(self.model.backgroundColor.color)
8684
.onTapGesture {
8785
self.globalFocus = self.localFocus
8886
}

0 commit comments

Comments
 (0)