@momo-kits/native-kits 0.162.30 → 0.162.31
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/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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// SectionDemo.swift
|
|
3
|
+
// Example
|
|
4
|
+
//
|
|
5
|
+
// Preview + Playground demo for SectionView / ItemView (12-column grid).
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
10
|
+
|
|
11
|
+
struct SectionDemo: View {
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { SectionPreview() }, playground: { SectionPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MARK: - Preview
|
|
22
|
+
|
|
23
|
+
private struct SectionPreview: View {
|
|
24
|
+
var body: some View {
|
|
25
|
+
BasicColumnBox("Full width — span 12", alignment: .leading) {
|
|
26
|
+
SectionView { SectionTile("12") }
|
|
27
|
+
}
|
|
28
|
+
BasicColumnBox("Even splits", alignment: .leading) {
|
|
29
|
+
SectionView {
|
|
30
|
+
ItemView(widthSpan: 6) { SectionTile("6") }
|
|
31
|
+
ItemView(widthSpan: 6) { SectionTile("6") }
|
|
32
|
+
ItemView(widthSpan: 4) { SectionTile("4") }
|
|
33
|
+
ItemView(widthSpan: 4) { SectionTile("4") }
|
|
34
|
+
ItemView(widthSpan: 4) { SectionTile("4") }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
BasicColumnBox("heightSpan — square tiles", alignment: .leading) {
|
|
38
|
+
SectionView {
|
|
39
|
+
ItemView(widthSpan: 3, heightSpan: 3) { SectionTile("3×3") }
|
|
40
|
+
ItemView(widthSpan: 3, heightSpan: 3) { SectionTile("3×3") }
|
|
41
|
+
ItemView(widthSpan: 6, heightSpan: 3) { SectionTile("6×3") }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// MARK: - Playground
|
|
48
|
+
|
|
49
|
+
@available(iOS 16.0, *)
|
|
50
|
+
private struct SectionPlayground: View {
|
|
51
|
+
@State private var span: Double = 6
|
|
52
|
+
@State private var useMargin = true
|
|
53
|
+
|
|
54
|
+
var body: some View {
|
|
55
|
+
PlaygroundTab(
|
|
56
|
+
component: {
|
|
57
|
+
SectionView(useMargin: useMargin) {
|
|
58
|
+
ItemView(widthSpan: Int(span)) { SectionTile("\(Int(span))") }
|
|
59
|
+
ItemView(widthSpan: 12 - Int(span)) { SectionTile("\(12 - Int(span))") }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
params: [
|
|
63
|
+
.slider("Left widthSpan", $span, min: 1, max: 11, step: 1),
|
|
64
|
+
.checkbox("useMargin", $useMargin),
|
|
65
|
+
]
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// Filled placeholder so span widths are visible.
|
|
71
|
+
private struct SectionTile: View {
|
|
72
|
+
let label: String
|
|
73
|
+
init(_ label: String) { self.label = label }
|
|
74
|
+
|
|
75
|
+
var body: some View {
|
|
76
|
+
Text(label)
|
|
77
|
+
.font(.footnote)
|
|
78
|
+
.foregroundColor(Colors.black17)
|
|
79
|
+
.frame(maxWidth: .infinity, minHeight: 44, maxHeight: .infinity)
|
|
80
|
+
.background(Colors.blue08)
|
|
81
|
+
.clipShape(RoundedRectangle(cornerRadius: Radius.S, style: .continuous))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -2,31 +2,60 @@
|
|
|
2
2
|
// SkeletonDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
+
// Preview + Playground demo (DemoScreen pattern).
|
|
6
|
+
//
|
|
5
7
|
|
|
6
|
-
import SwiftUI
|
|
7
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
struct SkeletonDemo: View {
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { SkeletonPreview() }, playground: { SkeletonPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
|
|
12
|
-
|
|
13
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
14
|
-
Spacer().frame(height: 12)
|
|
21
|
+
// MARK: - Preview
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
private struct SkeletonPreview: View {
|
|
24
|
+
var body: some View {
|
|
25
|
+
BasicColumnBox("Square (aspect 1:1)", alignment: .leading) {
|
|
17
26
|
Skeleton()
|
|
18
27
|
.aspectRatio(1, contentMode: .fit)
|
|
19
28
|
.frame(maxWidth: .infinity)
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
}
|
|
30
|
+
BasicColumnBox("Fixed height (32)", alignment: .leading) {
|
|
22
31
|
Skeleton()
|
|
23
32
|
.frame(maxWidth: .infinity)
|
|
24
33
|
.frame(height: 32)
|
|
25
34
|
}
|
|
26
|
-
.
|
|
35
|
+
BasicColumnBox("Lines", alignment: .leading) {
|
|
36
|
+
Skeleton().frame(maxWidth: .infinity).frame(height: 16)
|
|
37
|
+
Skeleton().frame(maxWidth: .infinity).frame(height: 16)
|
|
38
|
+
Skeleton().frame(width: 160).frame(height: 16)
|
|
39
|
+
}
|
|
27
40
|
}
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
// MARK: - Playground
|
|
44
|
+
|
|
45
|
+
@available(iOS 16.0, *)
|
|
46
|
+
private struct SkeletonPlayground: View {
|
|
47
|
+
@State private var height: Double = 32
|
|
48
|
+
|
|
49
|
+
var body: some View {
|
|
50
|
+
PlaygroundTab(
|
|
51
|
+
component: {
|
|
52
|
+
Skeleton()
|
|
53
|
+
.frame(maxWidth: .infinity)
|
|
54
|
+
.frame(height: CGFloat(height))
|
|
55
|
+
},
|
|
56
|
+
params: [
|
|
57
|
+
.slider("Height", $height, min: 16, max: 200, step: 4),
|
|
58
|
+
]
|
|
59
|
+
)
|
|
60
|
+
}
|
|
32
61
|
}
|
|
@@ -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
|