@momo-kits/native-kits 0.162.30-debug → 0.162.31-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +19 -0
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +14 -6
- package/ios/Application/LanguageSource.swift +93 -0
- package/ios/Application/Localize.swift +73 -4
- package/ios/Application/LocalizeModifier.swift +30 -0
- package/ios/Application/Navigation/NavigationContainer.swift +28 -18
- package/ios/Application/Navigation/Navigator.swift +121 -53
- package/ios/Application/Navigation/NavigatorManager.swift +49 -0
- package/ios/Application/Navigation/component/NavigationFooter.swift +90 -0
- package/ios/Application/StackScreen.swift +19 -28
- package/ios/Badge/Badge.swift +2 -1
- package/ios/Badge/BadgeRibbon.swift +6 -2
- package/ios/Button/Button.swift +41 -61
- package/ios/Chip/Chip.swift +6 -5
- package/ios/Icon/Icon.swift +13 -4
- package/ios/Input/ErrorView.swift +2 -1
- package/ios/Input/Input.swift +9 -2
- package/ios/Input/InputPhoneNumber.swift +2 -1
- package/ios/Input/InputSearch.swift +3 -2
- package/ios/Input/InputTextArea.swift +6 -1
- package/ios/InputMoney/InputMoney.swift +5 -2
- package/ios/InputOTP/InputOTP.swift +2 -1
- package/ios/Layout/GridContext.swift +30 -0
- package/ios/Layout/Item.swift +42 -0
- package/ios/Layout/Section.swift +134 -0
- package/ios/Popup/PopupNotify.swift +2 -1
- package/ios/ProgressInfo/ProgressInfo.swift +4 -3
- package/ios/Rating/Rating.swift +2 -1
- package/ios/Stepper/Stepper.swift +2 -1
- package/ios/SuggestAction/SuggestAction.swift +3 -2
- package/ios/Tag/Tag.swift +2 -1
- package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
- package/ios/Title/Title.swift +3 -2
- package/ios/Tooltip/Tooltip.swift +2 -1
- package/ios/Typography/FontScale.swift +103 -0
- package/ios/Typography/FontScaleStore.swift +52 -13
- package/ios/Typography/Text.swift +12 -29
- package/ios/Typography/Typography.swift +66 -86
- package/ios/native-kits.podspec +2 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +87 -73
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +55 -249
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +90 -82
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +74 -104
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +47 -50
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +63 -7
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +90 -81
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +73 -97
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DemoScreen.swift +420 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +46 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +54 -57
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +80 -45
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconDemo.swift +81 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +49 -62
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +66 -116
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +104 -98
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +76 -118
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +73 -86
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +69 -54
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +74 -54
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +73 -20
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +68 -38
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +55 -52
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +51 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +14 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +47 -51
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PlaygroundData.swift +76 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +67 -93
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +34 -43
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +83 -71
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +55 -23
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +58 -46
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SectionDemo.swift +83 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +41 -12
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +67 -127
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +54 -110
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +69 -79
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +78 -58
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +76 -65
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +82 -127
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +44 -19
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +92 -168
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +79 -27
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +0 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +87 -92
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +94 -163
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +70 -70
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +68 -114
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +3 -1
- package/package.json +2 -2
|
@@ -2,149 +2,89 @@
|
|
|
2
2
|
// SliderDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
+
// Preview + Playground demo for MomoSlider.
|
|
6
|
+
//
|
|
5
7
|
|
|
6
|
-
import Foundation
|
|
7
8
|
import MoMoUIKits
|
|
8
9
|
import SwiftUI
|
|
9
10
|
|
|
10
|
-
// MARK: - SliderDemo
|
|
11
|
-
|
|
12
11
|
struct SliderDemo: View {
|
|
13
|
-
// Playground state
|
|
14
|
-
@State private var pgLow: CGFloat = 20
|
|
15
|
-
@State private var pgHigh: CGFloat = 80
|
|
16
|
-
@State private var pgDisableRange = false
|
|
17
|
-
@State private var pgFloatingLabel = false
|
|
18
|
-
@State private var pgDisabled = false
|
|
19
|
-
@State private var pgMinRange = false
|
|
20
|
-
@State private var pgStepBig = false
|
|
21
|
-
|
|
22
12
|
var body: some View {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
playground
|
|
28
|
-
}
|
|
29
|
-
.padding(.vertical, 16)
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { SliderPreview() }, playground: { SliderPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
30
17
|
}
|
|
31
18
|
}
|
|
19
|
+
}
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private var preview: some View {
|
|
36
|
-
VStack(alignment: .leading, spacing: 24) {
|
|
37
|
-
section("Range Slider (default)") {
|
|
38
|
-
MomoSlider(min: 0, max: 100, step: 1)
|
|
39
|
-
.padding(.horizontal, 8)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
section("Range Slider with initial values") {
|
|
43
|
-
MomoSlider(min: 0, max: 100, step: 1, low: 20, high: 80)
|
|
44
|
-
.padding(.horizontal, 8)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
section("Single-thumb Slider (disableRange)") {
|
|
48
|
-
MomoSlider(min: 0, max: 100, step: 1, low: 40, disableRange: true)
|
|
49
|
-
.padding(.horizontal, 8)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
section("Slider with step = 10") {
|
|
53
|
-
MomoSlider(min: 0, max: 100, step: 10, low: 20, high: 70)
|
|
54
|
-
.padding(.horizontal, 8)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
section("Slider with minRange = 20") {
|
|
58
|
-
MomoSlider(min: 0, max: 100, step: 1, low: 10, high: 90, minRange: 20)
|
|
59
|
-
.padding(.horizontal, 8)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
section("Floating Label") {
|
|
63
|
-
MomoSlider(min: 0, max: 100, step: 1, low: 30, high: 70, floatingLabel: true)
|
|
64
|
-
.padding(.horizontal, 8)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
section("Disabled") {
|
|
68
|
-
MomoSlider(min: 0, max: 100, step: 1, low: 30, high: 70, disabled: true)
|
|
69
|
-
.padding(.horizontal, 8)
|
|
70
|
-
}
|
|
21
|
+
// MARK: - Preview
|
|
71
22
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
23
|
+
private struct SliderPreview: View {
|
|
24
|
+
var body: some View {
|
|
25
|
+
BasicColumnBox("Range Slider (default)", alignment: .leading) {
|
|
26
|
+
MomoSlider(min: 0, max: 100, step: 1)
|
|
76
27
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// MARK: - Playground
|
|
80
|
-
|
|
81
|
-
private var playground: some View {
|
|
82
|
-
section("Playground") {
|
|
83
|
-
toggle("Disable Range (single thumb)", $pgDisableRange)
|
|
84
|
-
toggle("Floating Label", $pgFloatingLabel)
|
|
85
|
-
toggle("Disabled", $pgDisabled)
|
|
86
|
-
toggle("Min Range = 20", $pgMinRange)
|
|
87
|
-
toggle("Step = 10 (instead of 1)", $pgStepBig)
|
|
88
|
-
|
|
89
|
-
MomoSlider(
|
|
90
|
-
min: 0,
|
|
91
|
-
max: 100,
|
|
92
|
-
step: pgStepBig ? 10 : 1,
|
|
93
|
-
low: pgLow,
|
|
94
|
-
high: pgHigh,
|
|
95
|
-
minRange: pgMinRange ? 20 : 0,
|
|
96
|
-
disableRange: pgDisableRange,
|
|
97
|
-
floatingLabel: pgFloatingLabel,
|
|
98
|
-
disabled: pgDisabled,
|
|
99
|
-
onValueChanged: { low, high, _ in
|
|
100
|
-
pgLow = low
|
|
101
|
-
pgHigh = high
|
|
102
|
-
}
|
|
103
|
-
)
|
|
104
|
-
.padding(.horizontal, 8)
|
|
105
|
-
// Re-create slider when structural params change so initial values apply.
|
|
106
|
-
.id("\(pgDisableRange)-\(pgMinRange)-\(pgStepBig)")
|
|
107
|
-
|
|
108
|
-
if pgDisableRange {
|
|
109
|
-
Text("Value: \(Int(pgLow))")
|
|
110
|
-
.font(.subheadline)
|
|
111
|
-
.padding(.top, 8)
|
|
112
|
-
} else {
|
|
113
|
-
Text("Low: \(Int(pgLow)) · High: \(Int(pgHigh))")
|
|
114
|
-
.font(.subheadline)
|
|
115
|
-
.padding(.top, 8)
|
|
116
|
-
}
|
|
28
|
+
BasicColumnBox("With initial values", alignment: .leading) {
|
|
29
|
+
MomoSlider(min: 0, max: 100, step: 1, low: 20, high: 80)
|
|
117
30
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// MARK: - Helpers
|
|
121
|
-
|
|
122
|
-
@ViewBuilder
|
|
123
|
-
private func section<Content: View>(
|
|
124
|
-
_ title: String,
|
|
125
|
-
@ViewBuilder content: () -> Content
|
|
126
|
-
) -> some View {
|
|
127
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
128
|
-
Text(title)
|
|
129
|
-
.font(.headline)
|
|
130
|
-
content()
|
|
31
|
+
BasicColumnBox("Single-thumb (disableRange)", alignment: .leading) {
|
|
32
|
+
MomoSlider(min: 0, max: 100, step: 1, low: 40, disableRange: true)
|
|
131
33
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
34
|
+
BasicColumnBox("Step = 10", alignment: .leading) {
|
|
35
|
+
MomoSlider(min: 0, max: 100, step: 10, low: 20, high: 70)
|
|
36
|
+
}
|
|
37
|
+
BasicColumnBox("Min range = 20", alignment: .leading) {
|
|
38
|
+
MomoSlider(min: 0, max: 100, step: 1, low: 10, high: 90, minRange: 20)
|
|
39
|
+
}
|
|
40
|
+
BasicColumnBox("Floating Label", alignment: .leading) {
|
|
41
|
+
MomoSlider(min: 0, max: 100, step: 1, low: 30, high: 70, floatingLabel: true)
|
|
42
|
+
}
|
|
43
|
+
BasicColumnBox("Disabled", alignment: .leading) {
|
|
44
|
+
MomoSlider(min: 0, max: 100, step: 1, low: 30, high: 70, disabled: true)
|
|
140
45
|
}
|
|
141
46
|
}
|
|
142
47
|
}
|
|
143
48
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
49
|
+
// MARK: - Playground
|
|
50
|
+
|
|
51
|
+
@available(iOS 16.0, *)
|
|
52
|
+
private struct SliderPlayground: View {
|
|
53
|
+
@State private var low: Double = 20
|
|
54
|
+
@State private var high: Double = 80
|
|
55
|
+
@State private var minRange: Double = 0
|
|
56
|
+
@State private var step: Double = 1
|
|
57
|
+
@State private var disableRange = false
|
|
58
|
+
@State private var floatingLabel = false
|
|
59
|
+
@State private var disabled = false
|
|
60
|
+
|
|
61
|
+
var body: some View {
|
|
62
|
+
PlaygroundTab(
|
|
63
|
+
component: {
|
|
64
|
+
MomoSlider(
|
|
65
|
+
min: 0,
|
|
66
|
+
max: 100,
|
|
67
|
+
step: CGFloat(step),
|
|
68
|
+
low: CGFloat(low),
|
|
69
|
+
high: CGFloat(high),
|
|
70
|
+
minRange: CGFloat(minRange),
|
|
71
|
+
disableRange: disableRange,
|
|
72
|
+
floatingLabel: floatingLabel,
|
|
73
|
+
disabled: disabled,
|
|
74
|
+
onValueChanged: { l, h, _ in low = Double(l); high = Double(h) }
|
|
75
|
+
)
|
|
76
|
+
// Re-seed when structural params change so initial values apply.
|
|
77
|
+
.id("\(disableRange)-\(minRange)-\(step)")
|
|
78
|
+
},
|
|
79
|
+
params: [
|
|
80
|
+
.checkbox("DisableRange", $disableRange),
|
|
81
|
+
.checkbox("FloatingLabel", $floatingLabel),
|
|
82
|
+
.checkbox("Disabled", $disabled),
|
|
83
|
+
.slider("Low", $low, min: 0, max: 100, step: 1),
|
|
84
|
+
.slider("High", $high, min: 0, max: 100, step: 1),
|
|
85
|
+
.slider("MinRange", $minRange, min: 0, max: 40, step: 5),
|
|
86
|
+
.slider("Step", $step, min: 1, max: 10, step: 1),
|
|
87
|
+
]
|
|
88
|
+
)
|
|
148
89
|
}
|
|
149
90
|
}
|
|
150
|
-
#endif
|
|
@@ -4,135 +4,79 @@ import SwiftUI
|
|
|
4
4
|
struct SnackBarDemo: View {
|
|
5
5
|
var body: some View {
|
|
6
6
|
if #available(iOS 16.0, *) {
|
|
7
|
-
|
|
7
|
+
DemoScreen(preview: { SnackBarPreview() }, playground: { SnackBarPlayground() })
|
|
8
8
|
} else {
|
|
9
|
-
|
|
10
|
-
.padding()
|
|
9
|
+
Text("Requires iOS 16+").padding()
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
// MARK: - Preview
|
|
15
|
+
|
|
15
16
|
@available(iOS 16.0, *)
|
|
16
|
-
private struct
|
|
17
|
+
private struct SnackBarPreview: View {
|
|
17
18
|
@EnvironmentObject private var navigator: Navigator
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if undefinedDuration {
|
|
25
|
-
return nil
|
|
26
|
-
}
|
|
27
|
-
guard let milliseconds = Double(duration) else {
|
|
28
|
-
return nil
|
|
20
|
+
var body: some View {
|
|
21
|
+
BasicColumnBox("SnackBar", alignment: .leading) {
|
|
22
|
+
MoMoUIKits.Button(title: "Show snack bar", action: { showSnack(1) }, size: .large)
|
|
23
|
+
MoMoUIKits.Button(title: "Show toast", action: { navigator.showSnackBar(.toast(duration: 1)) }, type: .secondary, size: .large)
|
|
24
|
+
MoMoUIKits.Button(title: "Hide snack bar", action: { navigator.hideSnackBar() }, type: .text, size: .large)
|
|
29
25
|
}
|
|
30
|
-
return milliseconds / 1000
|
|
31
26
|
}
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
undefinedDuration = checked
|
|
49
|
-
if checked {
|
|
50
|
-
duration = ""
|
|
51
|
-
} else if duration.isEmpty {
|
|
52
|
-
duration = "1000"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
),
|
|
56
|
-
title: "Undefined"
|
|
57
|
-
)
|
|
28
|
+
private func showSnack(_ duration: TimeInterval?) {
|
|
29
|
+
navigator.showSnackBar(.custom(duration: duration) {
|
|
30
|
+
HStack {
|
|
31
|
+
MomoText("Snack bar !!!", color: Colors.black01)
|
|
32
|
+
Spacer()
|
|
33
|
+
}
|
|
34
|
+
.padding(.horizontal, 20)
|
|
35
|
+
.frame(height: 80)
|
|
36
|
+
.frame(maxWidth: .infinity)
|
|
37
|
+
.background(Colors.black17)
|
|
38
|
+
.clipShape(RoundedRectangle(cornerRadius: Radius.M))
|
|
39
|
+
.padding(.horizontal, Spacing.M)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
}
|
|
58
43
|
|
|
59
|
-
|
|
60
|
-
MoMoUIKits.Switch($showFooter)
|
|
61
|
-
MomoText("Footer")
|
|
62
|
-
}
|
|
44
|
+
// MARK: - Playground
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
)
|
|
46
|
+
@available(iOS 16.0, *)
|
|
47
|
+
private struct SnackBarPlayground: View {
|
|
48
|
+
@EnvironmentObject private var navigator: Navigator
|
|
49
|
+
@State private var duration = "1000"
|
|
69
50
|
|
|
70
|
-
|
|
71
|
-
title: "Show toast",
|
|
72
|
-
action: { navigator.showSnackBar(.toast(duration: snackBarDuration)) },
|
|
73
|
-
type: .secondary,
|
|
74
|
-
size: .large
|
|
75
|
-
)
|
|
51
|
+
private var seconds: TimeInterval? { Double(duration).map { $0 / 1000 } }
|
|
76
52
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
)
|
|
53
|
+
var body: some View {
|
|
54
|
+
PlaygroundTab(
|
|
55
|
+
component: {
|
|
56
|
+
VStack(spacing: Spacing.S) {
|
|
57
|
+
MoMoUIKits.Button(title: "Show snack bar", action: { showSnack(seconds) }, size: .large)
|
|
58
|
+
MoMoUIKits.Button(title: "Show toast", action: { navigator.showSnackBar(.toast(duration: seconds)) }, type: .secondary, size: .large)
|
|
59
|
+
MoMoUIKits.Button(title: "Hide snack bar", action: { navigator.hideSnackBar() }, type: .text, size: .large)
|
|
83
60
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
footer
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private var footer: some View {
|
|
94
|
-
VStack(spacing: 0) {
|
|
95
|
-
MoMoUIKits.Button(
|
|
96
|
-
title: "Footer",
|
|
97
|
-
action: {},
|
|
98
|
-
size: .large
|
|
99
|
-
)
|
|
100
|
-
.padding(.vertical, Spacing.S)
|
|
101
|
-
.padding(.horizontal, Spacing.M)
|
|
102
|
-
}
|
|
103
|
-
.frame(maxWidth: .infinity)
|
|
104
|
-
.background(Colors.black01)
|
|
105
|
-
.overlay(
|
|
106
|
-
Rectangle()
|
|
107
|
-
.fill(Colors.black20.opacity(0.1))
|
|
108
|
-
.frame(height: 4)
|
|
109
|
-
.shadow(color: Colors.black20.opacity(0.2), radius: 10, y: -2),
|
|
110
|
-
alignment: .top
|
|
61
|
+
},
|
|
62
|
+
params: [
|
|
63
|
+
.number("Duration (ms)", $duration),
|
|
64
|
+
]
|
|
111
65
|
)
|
|
112
66
|
}
|
|
113
67
|
|
|
114
|
-
private func
|
|
115
|
-
navigator.showSnackBar(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
Spacer()
|
|
120
|
-
}
|
|
121
|
-
.padding(.horizontal, 20)
|
|
122
|
-
.frame(height: 80)
|
|
123
|
-
.frame(maxWidth: .infinity)
|
|
124
|
-
.background(Colors.black17)
|
|
125
|
-
.clipShape(RoundedRectangle(cornerRadius: Radius.M))
|
|
126
|
-
.padding(.horizontal, Spacing.M)
|
|
68
|
+
private func showSnack(_ duration: TimeInterval?) {
|
|
69
|
+
navigator.showSnackBar(.custom(duration: duration) {
|
|
70
|
+
HStack {
|
|
71
|
+
MomoText("Snack bar !!!", color: Colors.black01)
|
|
72
|
+
Spacer()
|
|
127
73
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
SnackBarDemo()
|
|
74
|
+
.padding(.horizontal, 20)
|
|
75
|
+
.frame(height: 80)
|
|
76
|
+
.frame(maxWidth: .infinity)
|
|
77
|
+
.background(Colors.black17)
|
|
78
|
+
.clipShape(RoundedRectangle(cornerRadius: Radius.M))
|
|
79
|
+
.padding(.horizontal, Spacing.M)
|
|
80
|
+
})
|
|
136
81
|
}
|
|
137
82
|
}
|
|
138
|
-
#endif
|
|
@@ -2,102 +2,92 @@
|
|
|
2
2
|
// StepperDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
+
// Preview + Playground demo (mirrors the Compose DemoScreen pattern).
|
|
6
|
+
//
|
|
5
7
|
|
|
6
|
-
import Foundation
|
|
7
8
|
import MoMoUIKits
|
|
8
9
|
import SwiftUI
|
|
9
10
|
|
|
10
|
-
// MARK: - StepperDemo
|
|
11
|
-
|
|
12
11
|
struct StepperDemo: View {
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { StepperPreview() }, playground: { StepperPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MARK: - Preview
|
|
22
|
+
|
|
23
|
+
private struct StepperPreview: View {
|
|
13
24
|
@State private var sizeLarge = 5
|
|
14
25
|
@State private var sizeSmall = 5
|
|
15
|
-
|
|
16
|
-
@State private var def0 = 0
|
|
17
26
|
@State private var def50 = 50
|
|
18
|
-
@State private var def100 = 100
|
|
19
|
-
|
|
20
27
|
@State private var customStep5 = 0
|
|
21
|
-
@State private var
|
|
22
|
-
|
|
23
|
-
@State private var editableLarge = 5
|
|
24
|
-
@State private var editableSmall = 5
|
|
25
|
-
|
|
26
|
-
@State private var disabledAllLarge = 5
|
|
27
|
-
@State private var disabledAllSmall = 5
|
|
28
|
-
|
|
28
|
+
@State private var editable = 5
|
|
29
|
+
@State private var disabledAll = 5
|
|
29
30
|
@State private var disabledMinus = 5
|
|
30
31
|
@State private var disabledPlus = 5
|
|
31
|
-
|
|
32
|
-
@State private var boundLow = 0
|
|
33
|
-
@State private var boundHigh = 10
|
|
32
|
+
@State private var bound = 0
|
|
34
33
|
|
|
35
34
|
var body: some View {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
MomoStepper(value: $sizeLarge, size: .large)
|
|
40
|
-
MomoStepper(value: $sizeSmall, size: .small)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
section("Default (min=0, max=100, step=1)") {
|
|
44
|
-
MomoStepper(value: $def0)
|
|
45
|
-
MomoStepper(value: $def50)
|
|
46
|
-
MomoStepper(value: $def100)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
section("Custom step") {
|
|
50
|
-
MomoStepper(value: $customStep5, min: 0, max: 50, step: 5)
|
|
51
|
-
MomoStepper(value: $customStep10, min: 0, max: 100, step: 10)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
section("Editable") {
|
|
55
|
-
MomoStepper(value: $editableLarge, editable: true)
|
|
56
|
-
MomoStepper(value: $editableSmall, size: .small, editable: true)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
section("Disabled — all") {
|
|
60
|
-
MomoStepper(value: $disabledAllLarge, disabled: true)
|
|
61
|
-
MomoStepper(value: $disabledAllSmall, size: .small, disabled: true)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
section("Disabled — minus only") {
|
|
65
|
-
MomoStepper(value: $disabledMinus, disabled: StepperDisabled(minus: true, plus: false))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
section("Disabled — plus only") {
|
|
69
|
-
MomoStepper(value: $disabledPlus, disabled: StepperDisabled(minus: false, plus: true))
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
section("Auto-disabled at bounds") {
|
|
73
|
-
MomoStepper(value: $boundLow, min: 0, max: 10)
|
|
74
|
-
MomoStepper(value: $boundHigh, min: 0, max: 10)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
.padding(.vertical, 16)
|
|
35
|
+
BasicColumnBox("Size", alignment: .leading) {
|
|
36
|
+
MomoStepper(value: $sizeLarge, size: .large)
|
|
37
|
+
MomoStepper(value: $sizeSmall, size: .small)
|
|
78
38
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
39
|
+
BasicColumnBox("Default (min=0, max=100, step=1)", alignment: .leading) {
|
|
40
|
+
MomoStepper(value: $def50)
|
|
41
|
+
}
|
|
42
|
+
BasicColumnBox("Custom step (5)", alignment: .leading) {
|
|
43
|
+
MomoStepper(value: $customStep5, min: 0, max: 50, step: 5)
|
|
44
|
+
}
|
|
45
|
+
BasicColumnBox("Editable", alignment: .leading) {
|
|
46
|
+
MomoStepper(value: $editable, editable: true)
|
|
47
|
+
}
|
|
48
|
+
BasicColumnBox("Disabled — all", alignment: .leading) {
|
|
49
|
+
MomoStepper(value: $disabledAll, disabled: true)
|
|
50
|
+
}
|
|
51
|
+
BasicColumnBox("Disabled — minus / plus only", alignment: .leading) {
|
|
52
|
+
MomoStepper(value: $disabledMinus, disabled: StepperDisabled(minus: true, plus: false))
|
|
53
|
+
MomoStepper(value: $disabledPlus, disabled: StepperDisabled(minus: false, plus: true))
|
|
54
|
+
}
|
|
55
|
+
BasicColumnBox("Auto-disabled at bounds (0…10)", alignment: .leading) {
|
|
56
|
+
MomoStepper(value: $bound, min: 0, max: 10)
|
|
92
57
|
}
|
|
93
|
-
.padding(.horizontal, 16)
|
|
94
58
|
}
|
|
95
59
|
}
|
|
96
60
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
61
|
+
// MARK: - Playground
|
|
62
|
+
|
|
63
|
+
@available(iOS 16.0, *)
|
|
64
|
+
private struct StepperPlayground: View {
|
|
65
|
+
@State private var value = 5
|
|
66
|
+
@State private var small = false
|
|
67
|
+
@State private var editable = false
|
|
68
|
+
@State private var disabled = false
|
|
69
|
+
@State private var step = 1.0
|
|
70
|
+
|
|
71
|
+
var body: some View {
|
|
72
|
+
PlaygroundTab(
|
|
73
|
+
component: {
|
|
74
|
+
MomoStepper(
|
|
75
|
+
value: $value,
|
|
76
|
+
min: 0,
|
|
77
|
+
max: 100,
|
|
78
|
+
step: Int(step),
|
|
79
|
+
size: small ? .small : .large,
|
|
80
|
+
disabled: StepperDisabled(disabled),
|
|
81
|
+
editable: editable
|
|
82
|
+
)
|
|
83
|
+
.id("\(small)-\(editable)-\(disabled)-\(Int(step))")
|
|
84
|
+
},
|
|
85
|
+
params: [
|
|
86
|
+
.checkbox("Small", $small),
|
|
87
|
+
.checkbox("Editable", $editable),
|
|
88
|
+
.checkbox("Disabled", $disabled),
|
|
89
|
+
.slider("Step", $step, min: 1, max: 10, step: 1),
|
|
90
|
+
]
|
|
91
|
+
)
|
|
101
92
|
}
|
|
102
93
|
}
|
|
103
|
-
#endif
|