Skip to content

Commit bf0773e

Browse files
Merge branch 'refactor/config' into button/light-style
2 parents b10de5e + 1168a96 commit bf0773e

File tree

74 files changed

+1605
-371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1605
-371
lines changed

Examples/DemosApp/DemosApp/ComponentsPreview/Helpers/PreviewPickers.swift

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,43 +94,81 @@ struct CornerRadiusPicker<Custom: View>: View {
9494
// MARK: - FontPickers
9595

9696
struct BodyFontPicker: View {
97+
let title: String
9798
@Binding var selection: UniversalFont?
99+
100+
init(title: String = "Font", selection: Binding<UniversalFont?>) {
101+
self.title = title
102+
self._selection = selection
103+
}
98104

99105
var body: some View {
100-
Picker("Font", selection: self.$selection) {
106+
Picker(self.title, selection: self.$selection) {
101107
Text("Default").tag(Optional<UniversalFont>.none)
102108
Text("Small").tag(UniversalFont.smBody)
103109
Text("Medium").tag(UniversalFont.mdBody)
104110
Text("Large").tag(UniversalFont.lgBody)
105-
Text("Custom: system bold of size 18").tag(UniversalFont.system(size: 18, weight: .bold))
111+
Text("Custom: system semibold of size 16").tag(UniversalFont.system(size: 16, weight: .semibold))
106112
}
107113
}
108114
}
109115

110116
struct ButtonFontPicker: View {
117+
let title: String
111118
@Binding var selection: UniversalFont?
112119

120+
init(title: String = "Font", selection: Binding<UniversalFont?>) {
121+
self.title = title
122+
self._selection = selection
123+
}
124+
113125
var body: some View {
114-
Picker("Font", selection: self.$selection) {
126+
Picker(self.title, selection: self.$selection) {
115127
Text("Default").tag(Optional<UniversalFont>.none)
116128
Text("Small").tag(UniversalFont.smButton)
117129
Text("Medium").tag(UniversalFont.mdButton)
118130
Text("Large").tag(UniversalFont.lgButton)
119-
Text("Custom: system bold of size 18").tag(UniversalFont.system(size: 18, weight: .bold))
131+
Text("Custom: system bold of size 16").tag(UniversalFont.system(size: 16, weight: .bold))
120132
}
121133
}
122134
}
123135

124136
struct HeadlineFontPicker: View {
137+
let title: String
125138
@Binding var selection: UniversalFont?
139+
140+
init(title: String = "Font", selection: Binding<UniversalFont?>) {
141+
self.title = title
142+
self._selection = selection
143+
}
126144

127145
var body: some View {
128-
Picker("Font", selection: self.$selection) {
146+
Picker(self.title, selection: self.$selection) {
129147
Text("Default").tag(Optional<UniversalFont>.none)
130148
Text("Small").tag(UniversalFont.smHeadline)
131149
Text("Medium").tag(UniversalFont.mdHeadline)
132150
Text("Large").tag(UniversalFont.lgHeadline)
133-
Text("Custom: system bold of size 18").tag(UniversalFont.system(size: 18, weight: .bold))
151+
Text("Custom: system bold of size 20").tag(UniversalFont.system(size: 20, weight: .bold))
152+
}
153+
}
154+
}
155+
156+
struct CaptionFontPicker: View {
157+
let title: String
158+
@Binding var selection: UniversalFont?
159+
160+
init(title: String = "Font", selection: Binding<UniversalFont?>) {
161+
self.title = title
162+
self._selection = selection
163+
}
164+
165+
var body: some View {
166+
Picker(self.title, selection: self.$selection) {
167+
Text("Default").tag(Optional<UniversalFont>.none)
168+
Text("Small").tag(UniversalFont.smCaption)
169+
Text("Medium").tag(UniversalFont.mdCaption)
170+
Text("Large").tag(UniversalFont.lgCaption)
171+
Text("Custom: system semibold of size 12").tag(UniversalFont.system(size: 12, weight: .semibold))
134172
}
135173
}
136174
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct PreviewWrapper<Content: View>: View {
2121
LinearGradient(
2222
gradient: Gradient(
2323
colors: [
24-
Palette.Brand.blue.color(for: self.colorScheme),
25-
Palette.Brand.purple.color(for: self.colorScheme)
24+
UniversalColor.blue.color(for: self.colorScheme),
25+
UniversalColor.purple.color(for: self.colorScheme),
2626
]
2727
),
2828
startPoint: .topLeading,
@@ -42,3 +42,16 @@ struct PreviewWrapper<Content: View>: View {
4242
.padding(.horizontal)
4343
}
4444
}
45+
46+
// MARK: - Colors
47+
48+
extension UniversalColor {
49+
fileprivate static let blue: Self = .themed(
50+
light: .hex("#3684F8"),
51+
dark: .hex("#0058DB")
52+
)
53+
fileprivate static let purple: Self = .themed(
54+
light: .hex("#A920FD"),
55+
dark: .hex("#7800C1")
56+
)
57+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ struct ButtonPreview: View {
3333
Text("Bordered with small border").tag(ButtonVM.Style.bordered(.small))
3434
Text("Bordered with medium border").tag(ButtonVM.Style.bordered(.medium))
3535
Text("Bordered with large border").tag(ButtonVM.Style.bordered(.large))
36-
Text("Bordered with custom border: 6px").tag(ButtonVM.Style.bordered(.custom(6)))
3736
}
3837
}
3938
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import ComponentsKit
2+
import SwiftUI
3+
import UIKit
4+
5+
struct CountdownPreview: View {
6+
@State private var model = CountdownVM()
7+
8+
var body: some View {
9+
VStack {
10+
PreviewWrapper(title: "UIKit") {
11+
UKCountdown(model: self.model)
12+
.preview
13+
}
14+
PreviewWrapper(title: "SwiftUI") {
15+
SUCountdown(model: self.model)
16+
}
17+
Form {
18+
ComponentOptionalColorPicker(selection: self.$model.color)
19+
Picker("Locale", selection: self.$model.locale) {
20+
Text("Current").tag(Locale.current)
21+
Text("EN").tag(Locale(identifier: "en"))
22+
Text("ES").tag(Locale(identifier: "es"))
23+
Text("FR").tag(Locale(identifier: "fr"))
24+
Text("DE").tag(Locale(identifier: "de"))
25+
Text("ZH").tag(Locale(identifier: "zh"))
26+
Text("JA").tag(Locale(identifier: "ja"))
27+
Text("RU").tag(Locale(identifier: "ru"))
28+
Text("AR").tag(Locale(identifier: "ar"))
29+
Text("HI").tag(Locale(identifier: "hi"))
30+
Text("PT").tag(Locale(identifier: "pt"))
31+
}
32+
HeadlineFontPicker(title: "Main Font", selection: self.$model.mainFont)
33+
CaptionFontPicker(title: "Secondary Font", selection: self.$model.secondaryFont)
34+
SizePicker(selection: self.$model.size)
35+
Picker("Style", selection: self.$model.style) {
36+
Text("Plain").tag(CountdownVM.Style.plain)
37+
Text("Light").tag(CountdownVM.Style.light)
38+
}
39+
Picker("Units Style", selection: self.$model.unitsStyle) {
40+
Text("None").tag(CountdownVM.UnitsStyle.hidden)
41+
Text("Bottom").tag(CountdownVM.UnitsStyle.bottom)
42+
Text("Trailing").tag(CountdownVM.UnitsStyle.trailing)
43+
}
44+
DatePicker("Until Date", selection: self.$model.until, in: Date()..., displayedComponents: [.date, .hourAndMinute])
45+
.datePickerStyle(.compact)
46+
}
47+
}
48+
}
49+
}
50+
51+
#Preview {
52+
CountdownPreview()
53+
}

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/InputFieldPreview.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct InputFieldPreview: View {
1717
self.inputField
1818
.preview
1919
.onAppear {
20+
self.inputField.text = ""
2021
self.inputField.model = Self.initialModel
2122
}
2223
.onChange(of: self.model) { newValue in

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/TextInputPreview.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct TextInputPreviewPreview: View {
1717
self.textInput
1818
.preview
1919
.onAppear {
20+
self.textInput.text = ""
2021
self.textInput.model = Self.initialModel
2122
}
2223
.onChange(of: self.model) { newValue in

Examples/DemosApp/DemosApp/Core/App.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ struct App: View {
1212
NavigationLinkWithTitle("Checkbox") {
1313
CheckboxPreview()
1414
}
15+
NavigationLinkWithTitle("Countdown") {
16+
CountdownPreview()
17+
}
1518
NavigationLinkWithTitle("Divider") {
1619
DividerPreview()
1720
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct SwiftUILogin: View {
6262
? "Welcome back"
6363
: "Create an account"
6464
)
65-
.font(.system(size: 30, weight: .bold))
65+
.font(UniversalFont.lgHeadline.font)
6666
.padding(.vertical, 30)
6767

6868
if self.selectedPage == .signUp {
@@ -129,6 +129,7 @@ struct SwiftUILogin: View {
129129
model: .init {
130130
$0.title = "Continue"
131131
$0.isFullWidth = true
132+
$0.color = .primary
132133
$0.isEnabled = self.isButtonEnabled
133134
},
134135
action: {

Examples/DemosApp/DemosApp/Demos/Login/UIKitLogin.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class UIKitLogin: UIViewController {
3636
)
3737
private let titleLabel: UILabel = {
3838
let label = UILabel()
39-
label.font = .systemFont(ofSize: 30, weight: .bold)
39+
label.font = UniversalFont.lgHeadline.uiFont
4040
return label
4141
}()
4242
private let nameInput = UKInputField(
@@ -74,6 +74,7 @@ final class UIKitLogin: UIViewController {
7474
model: .init {
7575
$0.title = "Continue"
7676
$0.isFullWidth = true
77+
$0.color = .primary
7778
}
7879
)
7980
private let loader = UKLoading()

Examples/DemosApp/DemosApp/Helpers/Palette+Colors.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)