Skip to content

Commit c48294c

Browse files
Merge pull request #75 from componentskit/dev
1.5.0
2 parents 34fd22c + 03c1c5b commit c48294c

File tree

67 files changed

+992
-673
lines changed

Some content is hidden

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

67 files changed

+992
-673
lines changed

Examples/DemosApp/DemosApp/ComponentsPreview/Helpers/ModalPreview+Helpers.swift

+16-12
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ struct ModalPreviewHelpers {
6060
Section("Properties") {
6161
Picker("Background Color", selection: self.$model.backgroundColor) {
6262
Text("Default").tag(Optional<UniversalColor>.none)
63-
Text("Accent Background").tag(ComponentColor.accent.background)
64-
Text("Success Background").tag(ComponentColor.success.background)
65-
Text("Warning Background").tag(ComponentColor.warning.background)
66-
Text("Danger Background").tag(ComponentColor.danger.background)
63+
Text("Accent Background").tag(UniversalColor.accentBackground)
64+
Text("Success Background").tag(UniversalColor.successBackground)
65+
Text("Warning Background").tag(UniversalColor.warningBackground)
66+
Text("Danger Background").tag(UniversalColor.dangerBackground)
6767
}
6868
BorderWidthPicker(selection: self.$model.borderWidth)
6969
Toggle("Closes On Overlay Tap", isOn: self.$model.closesOnOverlayTap)
@@ -203,16 +203,20 @@ Enim habitant laoreet inceptos scelerisque senectus, tellus molestie ut. Eros ri
203203
}
204204

205205
static func suBody(body: ContentBody) -> some View {
206-
Group {
207-
switch body {
208-
case .shortText:
209-
Text(self.bodyShortText)
210-
case .longText:
211-
Text(self.bodyLongText)
206+
HStack {
207+
Group {
208+
switch body {
209+
case .shortText:
210+
Text(self.bodyShortText)
211+
case .longText:
212+
Text(self.bodyLongText)
213+
}
212214
}
215+
.font(self.bodyFont.font)
216+
.multilineTextAlignment(.leading)
217+
218+
Spacer()
213219
}
214-
.font(self.bodyFont.font)
215-
.multilineTextAlignment(.leading)
216220
}
217221

218222
static func suFooter(

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/AlertPreview.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ struct AlertPreview: View {
8484
Section("Main Properties") {
8585
Picker("Background Color", selection: self.$model.backgroundColor) {
8686
Text("Default").tag(Optional<UniversalColor>.none)
87-
Text("Accent Background").tag(ComponentColor.accent.background)
88-
Text("Success Background").tag(ComponentColor.success.background)
89-
Text("Warning Background").tag(ComponentColor.warning.background)
90-
Text("Danger Background").tag(ComponentColor.danger.background)
87+
Text("Accent Background").tag(UniversalColor.accentBackground)
88+
Text("Success Background").tag(UniversalColor.successBackground)
89+
Text("Warning Background").tag(UniversalColor.warningBackground)
90+
Text("Danger Background").tag(UniversalColor.dangerBackground)
9191
}
9292
BorderWidthPicker(selection: self.$model.borderWidth)
9393
Toggle("Closes On Overlay Tap", isOn: self.$model.closesOnOverlayTap)
@@ -154,7 +154,7 @@ Enim habitant laoreet inceptos scelerisque senectus, tellus molestie ut. Eros ri
154154
}
155155
static let initialSecondaryButton = AlertButtonVM {
156156
$0.title = SecondaryButtonText.short.rawValue
157-
$0.style = .light
157+
$0.style = .plain
158158
}
159159

160160
var primaryButtonVMOrDefault: Binding<AlertButtonVM> {

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/BadgePreview.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@ struct BadgePreview: View {
1717
SUBadge(model: self.model)
1818
}
1919
Form {
20+
ComponentOptionalColorPicker(selection: self.$model.color)
21+
ComponentRadiusPicker(selection: self.$model.cornerRadius) {
22+
Text("Custom: 4px").tag(ComponentRadius.custom(4))
23+
}
24+
Toggle("Enabled", isOn: self.$model.isEnabled)
2025
Picker("Font", selection: self.$model.font) {
21-
Text("Default").tag(Optional<UniversalFont>.none)
2226
Text("Small").tag(UniversalFont.smButton)
2327
Text("Medium").tag(UniversalFont.mdButton)
2428
Text("Large").tag(UniversalFont.lgButton)
2529
Text("Custom: system bold of size 16").tag(UniversalFont.system(size: 16, weight: .bold))
2630
}
27-
ComponentOptionalColorPicker(selection: self.$model.color)
28-
ComponentRadiusPicker(selection: self.$model.cornerRadius) {
29-
Text("Custom: 4px").tag(ComponentRadius.custom(4))
30-
}
31-
Picker("Style", selection: self.$model.style) {
32-
Text("Filled").tag(BadgeVM.Style.filled)
33-
Text("Light").tag(BadgeVM.Style.light)
34-
}
3531
Picker("Paddings", selection: self.$model.paddings) {
3632
Text("8px; 6px")
3733
.tag(Paddings(top: 6, leading: 8, bottom: 6, trailing: 8))
@@ -40,6 +36,10 @@ struct BadgePreview: View {
4036
Text("12px; 10px")
4137
.tag(Paddings(top: 10, leading: 12, bottom: 10, trailing: 12))
4238
}
39+
Picker("Style", selection: self.$model.style) {
40+
Text("Filled").tag(BadgeVM.Style.filled)
41+
Text("Light").tag(BadgeVM.Style.light)
42+
}
4343
}
4444
}
4545
}

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/BottomModalPreview.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct BottomModalPreview: View {
6262
footer: self.$contentFooter,
6363
additionalPickers: {
6464
Toggle("Draggable", isOn: self.$model.isDraggable)
65-
Toggle("Hides On Swap", isOn: self.$model.hidesOnSwap)
65+
Toggle("Hides On Swipe", isOn: self.$model.hidesOnSwipe)
6666
}
6767
)
6868
}

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/CardPreview.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ struct CardPreview: View {
1818
Picker("Background Color", selection: self.$model.backgroundColor) {
1919
Text("Default").tag(Optional<UniversalColor>.none)
2020
Text("Secondary Background").tag(UniversalColor.secondaryBackground)
21-
Text("Accent Background").tag(ComponentColor.accent.background)
22-
Text("Success Background").tag(ComponentColor.success.background)
23-
Text("Warning Background").tag(ComponentColor.warning.background)
24-
Text("Danger Background").tag(ComponentColor.danger.background)
21+
Text("Accent Background").tag(UniversalColor.accentBackground)
22+
Text("Success Background").tag(UniversalColor.successBackground)
23+
Text("Warning Background").tag(UniversalColor.warningBackground)
24+
Text("Danger Background").tag(UniversalColor.dangerBackground)
2525
}
2626
BorderWidthPicker(selection: self.$model.borderWidth)
2727
Picker("Content Paddings", selection: self.$model.contentPaddings) {
@@ -37,7 +37,7 @@ struct CardPreview: View {
3737
Text("Small").tag(Shadow.small)
3838
Text("Medium").tag(Shadow.medium)
3939
Text("Large").tag(Shadow.large)
40-
Text("Custom").tag(Shadow.custom(20.0, .zero, ComponentColor.accent.background))
40+
Text("Custom").tag(Shadow.custom(20.0, .zero, UniversalColor.accentBackground))
4141
}
4242
}
4343
}

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/CircularProgressPreview.swift

+16-23
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ import UIKit
44

55
struct CircularProgressPreview: View {
66
@State private var model = Self.initialModel
7-
@State private var currentValue: CGFloat = Self.initialValue
87

9-
private let circularProgress = UKCircularProgress(
10-
model: Self.initialModel
11-
)
8+
private let circularProgress = UKCircularProgress(model: Self.initialModel)
129

1310
private let timer = Timer
1411
.publish(every: 0.5, on: .main, in: .common)
@@ -20,58 +17,54 @@ struct CircularProgressPreview: View {
2017
self.circularProgress
2118
.preview
2219
.onAppear {
23-
self.circularProgress.currentValue = Self.initialValue
2420
self.circularProgress.model = Self.initialModel
2521
}
2622
.onChange(of: model) { newModel in
2723
self.circularProgress.model = newModel
2824
}
29-
.onChange(of: self.currentValue) { newValue in
30-
self.circularProgress.currentValue = newValue
31-
}
3225
}
3326
PreviewWrapper(title: "SwiftUI") {
34-
SUCircularProgress(currentValue: self.currentValue, model: self.model)
27+
SUCircularProgress(model: self.model)
3528
}
3629
Form {
3730
ComponentColorPicker(selection: self.$model.color)
3831
CaptionFontPicker(selection: self.$model.font)
32+
Picker("Line Cap", selection: self.$model.lineCap) {
33+
Text("Rounded").tag(CircularProgressVM.LineCap.rounded)
34+
Text("Square").tag(CircularProgressVM.LineCap.square)
35+
}
3936
Picker("Line Width", selection: self.$model.lineWidth) {
4037
Text("Default").tag(Optional<CGFloat>.none)
4138
Text("2").tag(Optional<CGFloat>.some(2))
4239
Text("4").tag(Optional<CGFloat>.some(4))
4340
Text("8").tag(Optional<CGFloat>.some(8))
4441
}
45-
SizePicker(selection: self.$model.size)
46-
Picker("Style", selection: self.$model.style) {
47-
Text("Light").tag(CircularProgressVM.Style.light)
48-
Text("Striped").tag(CircularProgressVM.Style.striped)
42+
Picker("Shape", selection: self.$model.shape) {
43+
Text("Circle").tag(CircularProgressVM.Shape.circle)
44+
Text("Arc").tag(CircularProgressVM.Shape.arc)
4945
}
46+
SizePicker(selection: self.$model.size)
5047
}
5148
.onReceive(self.timer) { _ in
52-
if self.currentValue < self.model.maxValue {
49+
if self.model.currentValue < self.model.maxValue {
5350
let step = (self.model.maxValue - self.model.minValue) / 100
54-
self.currentValue = min(
51+
self.model.currentValue = min(
5552
self.model.maxValue,
56-
self.currentValue + CGFloat(Int.random(in: 1...20)) * step
53+
self.model.currentValue + CGFloat(Int.random(in: 1...20)) * step
5754
)
5855
} else {
59-
self.currentValue = self.model.minValue
56+
self.model.currentValue = self.model.minValue
6057
}
61-
self.model.label = "\(Int(self.currentValue))%"
58+
self.model.label = "\(Int(self.model.currentValue))%"
6259
}
6360
}
6461
}
6562

6663
// MARK: - Helpers
6764

68-
private static var initialValue: Double {
69-
return 0.0
70-
}
71-
7265
private static var initialModel = CircularProgressVM {
7366
$0.label = "0%"
74-
$0.style = .light
67+
$0.currentValue = 0.0
7568
}
7669
}
7770

Examples/DemosApp/DemosApp/ComponentsPreview/PreviewPages/ProgressBarPreview.swift

+8-15
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import UIKit
44

55
struct ProgressBarPreview: View {
66
@State private var model = Self.initialModel
7-
@State private var currentValue: CGFloat = Self.initialValue
8-
9-
private let progressBar = UKProgressBar(initialValue: Self.initialValue, model: Self.initialModel)
10-
7+
8+
private let progressBar = UKProgressBar(model: Self.initialModel)
9+
1110
private let timer = Timer
1211
.publish(every: 0.5, on: .main, in: .common)
1312
.autoconnect()
@@ -18,15 +17,14 @@ struct ProgressBarPreview: View {
1817
self.progressBar
1918
.preview
2019
.onAppear {
21-
self.progressBar.currentValue = self.currentValue
2220
self.progressBar.model = Self.initialModel
2321
}
2422
.onChange(of: self.model) { newValue in
2523
self.progressBar.model = newValue
2624
}
2725
}
2826
PreviewWrapper(title: "SwiftUI") {
29-
SUProgressBar(currentValue: self.$currentValue, model: self.model)
27+
SUProgressBar(model: self.model)
3028
}
3129
Form {
3230
ComponentColorPicker(selection: self.$model.color)
@@ -42,25 +40,20 @@ struct ProgressBarPreview: View {
4240
}
4341
}
4442
.onReceive(self.timer) { _ in
45-
if self.currentValue < self.model.maxValue {
43+
if self.model.currentValue < self.model.maxValue {
4644
let step = (self.model.maxValue - self.model.minValue) / 100
47-
self.currentValue = min(
45+
self.model.currentValue = min(
4846
self.model.maxValue,
49-
self.currentValue + CGFloat(Int.random(in: 1...20)) * step
47+
self.model.currentValue + CGFloat(Int.random(in: 1...20)) * step
5048
)
5149
} else {
52-
self.currentValue = self.model.minValue
50+
self.model.currentValue = self.model.minValue
5351
}
54-
55-
self.progressBar.currentValue = self.currentValue
5652
}
5753
}
5854

5955
// MARK: - Helpers
6056

61-
private static var initialValue: Double {
62-
return 0.0
63-
}
6457
private static var initialModel: ProgressBarVM {
6558
return .init()
6659
}

Examples/DemosApp/DemosApp/Core/App.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ struct App: View {
4141
NavigationLinkWithTitle("Loading") {
4242
LoadingPreview()
4343
}
44-
NavigationLinkWithTitle("Progress Bar") {
45-
ProgressBarPreview()
46-
}
4744
NavigationLinkWithTitle("Modal (Bottom)") {
4845
BottomModalPreview()
4946
}
5047
NavigationLinkWithTitle("Modal (Center)") {
5148
CenterModalPreview()
5249
}
50+
NavigationLinkWithTitle("Progress Bar") {
51+
ProgressBarPreview()
52+
}
5353
NavigationLinkWithTitle("Radio Group") {
5454
RadioGroupPreview()
5555
}

0 commit comments

Comments
 (0)