@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
|
@@ -2,268 +2,74 @@
|
|
|
2
2
|
// BadgeDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo for Badge / BadgeDot / BadgeRibbon.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import MoMoUIKits
|
|
10
9
|
import SwiftUI
|
|
11
10
|
|
|
12
|
-
// MARK: - BadgeDemo
|
|
13
|
-
|
|
14
11
|
struct BadgeDemo: View {
|
|
15
|
-
|
|
12
|
+
var body: some View {
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { BadgePreview() }, playground: { BadgePlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
16
20
|
|
|
21
|
+
// MARK: - Preview
|
|
22
|
+
|
|
23
|
+
private struct BadgePreview: View {
|
|
17
24
|
var body: some View {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Text("Two Digits")
|
|
46
|
-
.font(.caption)
|
|
47
|
-
.foregroundColor(.gray)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
VStack(spacing: 8) {
|
|
51
|
-
Badge(label: "999")
|
|
52
|
-
Text("99+ Format")
|
|
53
|
-
.font(.caption)
|
|
54
|
-
.foregroundColor(.gray)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
HStack(spacing: 16) {
|
|
59
|
-
VStack(spacing: 8) {
|
|
60
|
-
Badge(label: "New")
|
|
61
|
-
Text("Text Label")
|
|
62
|
-
.font(.caption)
|
|
63
|
-
.foregroundColor(.gray)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
VStack(spacing: 8) {
|
|
67
|
-
Badge(label: "Hot", backgroundColor: Colors.pink03)
|
|
68
|
-
Text("Custom Color")
|
|
69
|
-
.font(.caption)
|
|
70
|
-
.foregroundColor(.gray)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
VStack(spacing: 8) {
|
|
74
|
-
Badge(label: "5", backgroundColor: Colors.green03)
|
|
75
|
-
Text("Green Badge")
|
|
76
|
-
.font(.caption)
|
|
77
|
-
.foregroundColor(.gray)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
.padding(.horizontal, 16)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Divider()
|
|
85
|
-
|
|
86
|
-
// MARK: - Badge Dots
|
|
87
|
-
|
|
88
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
89
|
-
Text("Badge Dots")
|
|
90
|
-
.font(.headline)
|
|
91
|
-
.padding(.horizontal, 16)
|
|
92
|
-
|
|
93
|
-
HStack(spacing: 32) {
|
|
94
|
-
VStack(spacing: 8) {
|
|
95
|
-
BadgeDot(size: .small)
|
|
96
|
-
Text("Small")
|
|
97
|
-
.font(.caption)
|
|
98
|
-
.foregroundColor(.gray)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
VStack(spacing: 8) {
|
|
102
|
-
BadgeDot(size: .large)
|
|
103
|
-
Text("Large")
|
|
104
|
-
.font(.caption)
|
|
105
|
-
.foregroundColor(.gray)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
.padding(.horizontal, 16)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
Divider()
|
|
112
|
-
|
|
113
|
-
// MARK: - Badge Ribbons
|
|
114
|
-
|
|
115
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
116
|
-
Text("Badge Ribbons")
|
|
117
|
-
.font(.headline)
|
|
118
|
-
.padding(.horizontal, 16)
|
|
119
|
-
|
|
120
|
-
VStack(spacing: 20) {
|
|
121
|
-
HStack(spacing: 20) {
|
|
122
|
-
VStack(spacing: 8) {
|
|
123
|
-
BadgeRibbon(position: .topLeft, label: "Top Left", isRound: true)
|
|
124
|
-
.frame(width: 150, height: 30)
|
|
125
|
-
Text("Top Left")
|
|
126
|
-
.font(.caption)
|
|
127
|
-
.foregroundColor(.gray)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
VStack(spacing: 8) {
|
|
131
|
-
BadgeRibbon(position: .topRight, label: "Top Right", isRound: true)
|
|
132
|
-
.frame(width: 150, height: 30)
|
|
133
|
-
Text("Top Right")
|
|
134
|
-
.font(.caption)
|
|
135
|
-
.foregroundColor(.gray)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
HStack(spacing: 20) {
|
|
140
|
-
VStack(spacing: 8) {
|
|
141
|
-
BadgeRibbon(position: .bottomLeft, label: "Bottom Left", isRound: true)
|
|
142
|
-
.frame(width: 150, height: 30)
|
|
143
|
-
Text("Bottom Left")
|
|
144
|
-
.font(.caption)
|
|
145
|
-
.foregroundColor(.gray)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
VStack(spacing: 8) {
|
|
149
|
-
BadgeRibbon(position: .bottomRight, label: "Bottom Right", isRound: true)
|
|
150
|
-
.frame(width: 150, height: 30)
|
|
151
|
-
Text("Bottom Right")
|
|
152
|
-
.font(.caption)
|
|
153
|
-
.foregroundColor(.gray)
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
.padding(.horizontal, 16)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
Divider()
|
|
161
|
-
|
|
162
|
-
// MARK: - Badge in Context (Real Usage Examples)
|
|
163
|
-
|
|
164
|
-
VStack(alignment: .leading, spacing: 12) {
|
|
165
|
-
Text("Real Usage Examples")
|
|
166
|
-
.font(.headline)
|
|
167
|
-
.padding(.horizontal, 16)
|
|
168
|
-
|
|
169
|
-
VStack(spacing: 16) {
|
|
170
|
-
// Notification with badge
|
|
171
|
-
HStack {
|
|
172
|
-
Image(systemName: "bell.fill")
|
|
173
|
-
.font(.system(size: 24))
|
|
174
|
-
.foregroundColor(Colors.primary)
|
|
175
|
-
|
|
176
|
-
Text("Notifications")
|
|
177
|
-
.font(.body)
|
|
178
|
-
|
|
179
|
-
Spacer()
|
|
180
|
-
|
|
181
|
-
Badge(label: "23")
|
|
182
|
-
}
|
|
183
|
-
.padding()
|
|
184
|
-
.background(Color(.systemGray6))
|
|
185
|
-
.cornerRadius(12)
|
|
186
|
-
|
|
187
|
-
// Message with badge
|
|
188
|
-
HStack {
|
|
189
|
-
Image(systemName: "message.fill")
|
|
190
|
-
.font(.system(size: 24))
|
|
191
|
-
.foregroundColor(Colors.primary)
|
|
192
|
-
|
|
193
|
-
Text("Messages")
|
|
194
|
-
.font(.body)
|
|
195
|
-
|
|
196
|
-
Spacer()
|
|
197
|
-
|
|
198
|
-
Badge(label: "5")
|
|
199
|
-
}
|
|
200
|
-
.padding()
|
|
201
|
-
.background(Color(.systemGray6))
|
|
202
|
-
.cornerRadius(12)
|
|
203
|
-
|
|
204
|
-
// Product card with ribbon
|
|
205
|
-
ZStack(alignment: .topTrailing) {
|
|
206
|
-
VStack(alignment: .leading, spacing: 8) {
|
|
207
|
-
Rectangle()
|
|
208
|
-
.fill(Color(.systemGray5))
|
|
209
|
-
.frame(height: 120)
|
|
210
|
-
.cornerRadius(8)
|
|
211
|
-
|
|
212
|
-
Text("Product Name")
|
|
213
|
-
.font(.headline)
|
|
214
|
-
|
|
215
|
-
Text("$99.99")
|
|
216
|
-
.font(.subheadline)
|
|
217
|
-
.foregroundColor(.gray)
|
|
218
|
-
}
|
|
219
|
-
.padding()
|
|
220
|
-
.background(Color(.systemGray6))
|
|
221
|
-
.cornerRadius(12)
|
|
222
|
-
|
|
223
|
-
BadgeRibbon(position: .topRight, label: "NEW")
|
|
224
|
-
.frame(width: 60, height: 40)
|
|
225
|
-
.offset(x: 5, y: 0)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Profile with dot indicator
|
|
229
|
-
HStack {
|
|
230
|
-
ZStack(alignment: .topTrailing) {
|
|
231
|
-
Circle()
|
|
232
|
-
.fill(Color(.systemGray5))
|
|
233
|
-
.frame(width: 50, height: 50)
|
|
234
|
-
|
|
235
|
-
BadgeDot(size: .small)
|
|
236
|
-
.offset(x: 2, y: 2)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
VStack(alignment: .leading) {
|
|
240
|
-
Text("User Name")
|
|
241
|
-
.font(.headline)
|
|
242
|
-
Text("Online")
|
|
243
|
-
.font(.caption)
|
|
244
|
-
.foregroundColor(Colors.green03)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
Spacer()
|
|
248
|
-
}
|
|
249
|
-
.padding()
|
|
250
|
-
.background(Color(.systemGray6))
|
|
251
|
-
.cornerRadius(12)
|
|
252
|
-
}
|
|
253
|
-
.padding(.horizontal, 16)
|
|
254
|
-
}
|
|
25
|
+
BasicColumnBox("Basic Badges", alignment: .leading) {
|
|
26
|
+
HStack(spacing: Spacing.L) {
|
|
27
|
+
Badge()
|
|
28
|
+
Badge(label: "9")
|
|
29
|
+
Badge(label: "99")
|
|
30
|
+
Badge(label: "999")
|
|
31
|
+
}
|
|
32
|
+
HStack(spacing: Spacing.L) {
|
|
33
|
+
Badge(label: "New")
|
|
34
|
+
Badge(label: "Hot", backgroundColor: Colors.pink03)
|
|
35
|
+
Badge(label: "5", backgroundColor: Colors.green03)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
BasicColumnBox("Badge Dots", alignment: .leading) {
|
|
40
|
+
HStack(spacing: Spacing.XL) {
|
|
41
|
+
BadgeDot(size: .small)
|
|
42
|
+
BadgeDot(size: .large)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
BasicColumnBox("Badge Ribbons", alignment: .leading) {
|
|
47
|
+
HStack(spacing: Spacing.L) {
|
|
48
|
+
BadgeRibbon(position: .topLeft, label: "Top Left", isRound: true)
|
|
49
|
+
.frame(width: 150, height: 30)
|
|
50
|
+
BadgeRibbon(position: .topRight, label: "Top Right", isRound: true)
|
|
51
|
+
.frame(width: 150, height: 30)
|
|
255
52
|
}
|
|
256
|
-
.padding(.vertical, 16)
|
|
257
53
|
}
|
|
258
54
|
}
|
|
259
55
|
}
|
|
260
56
|
|
|
261
|
-
// MARK: -
|
|
57
|
+
// MARK: - Playground
|
|
262
58
|
|
|
263
|
-
|
|
264
|
-
struct
|
|
265
|
-
|
|
266
|
-
|
|
59
|
+
@available(iOS 16.0, *)
|
|
60
|
+
private struct BadgePlayground: View {
|
|
61
|
+
@State private var label = "New"
|
|
62
|
+
@State private var color: PlaygroundOption? = playgroundColors.first { $0.key == "pink03" }
|
|
63
|
+
|
|
64
|
+
var body: some View {
|
|
65
|
+
PlaygroundTab(
|
|
66
|
+
component: {
|
|
67
|
+
Badge(label: label, backgroundColor: color?.value as? Color)
|
|
68
|
+
},
|
|
69
|
+
params: [
|
|
70
|
+
.string("Label", $label),
|
|
71
|
+
.color("BackgroundColor", playgroundColors, $color),
|
|
72
|
+
]
|
|
73
|
+
)
|
|
267
74
|
}
|
|
268
75
|
}
|
|
269
|
-
#endif
|
|
@@ -1,100 +1,108 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// ButtonDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo, mirroring Compose's ButtonUsage.kt.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
|
-
import Lottie
|
|
10
8
|
import MoMoUIKits
|
|
11
9
|
import SwiftUI
|
|
12
10
|
|
|
13
|
-
// MARK: - ButtonDemo
|
|
14
|
-
|
|
15
11
|
struct ButtonDemo: View {
|
|
16
|
-
// MARK: Internal
|
|
17
|
-
|
|
18
12
|
var body: some View {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Button(title: "Button", action: onPress, size: .small)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
Group {
|
|
30
|
-
Button(title: "Button", action: onPress, type: .danger,
|
|
31
|
-
iconLeft: AnyView(Image(systemName: "checkmark.circle")))
|
|
32
|
-
Button(title: "Button", action: onPress, type: .danger, size: .medium)
|
|
33
|
-
Button(title: "Button", action: onPress, type: .danger, size: .small)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
Group {
|
|
37
|
-
Button(title: "Button", action: onPress, type: .danger, iconLeft: AnyView(Image(systemName: "checkmark.circle")), isFull: false)
|
|
38
|
-
Button(title: "Button", action: onPress, type: .danger, size: .medium, isFull: false)
|
|
39
|
-
Button(title: "Button", action: onPress, type: .danger, size: .small, isFull: false)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Group {
|
|
44
|
-
Button(title: "Button", action: onPress, type: .tonal, size: .large)
|
|
45
|
-
Button(title: "Button", action: onPress, type: .tonal, size: .medium)
|
|
46
|
-
Button(title: "Button", action: onPress, type: .tonal, size: .small)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
Group {
|
|
50
|
-
Button(title: "Tinted icon", action: onPress, type: .primary,
|
|
51
|
-
iconLeft: AnyView(Image(systemName: "checkmark.circle")), useTintColor: true)
|
|
52
|
-
Button(title: "Original icon", action: onPress, type: .primary,
|
|
53
|
-
iconLeft: AnyView(Image(systemName: "checkmark.circle")), useTintColor: false)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
Group {
|
|
57
|
-
Button(title: "Button", action: onPress, type: .secondary, size: .large)
|
|
58
|
-
Button(title: "Button", action: onPress, type: .secondary, size: .medium)
|
|
59
|
-
Button(title: "Button", action: onPress, type: .secondary, size: .small)
|
|
60
|
-
}
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { ButtonPreview() }, playground: { ButtonPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
61
20
|
|
|
62
|
-
|
|
63
|
-
Button(title: "Button", action: onPress, type: .text, size: .large)
|
|
64
|
-
Button(title: "Button", action: onPress, type: .text, size: .medium)
|
|
65
|
-
Button(title: "Button", action: onPress, type: .text, size: .small)
|
|
66
|
-
}
|
|
21
|
+
// MARK: - Preview
|
|
67
22
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Button(title: "Button", action: onPress, type: .outline, size: .medium)
|
|
71
|
-
Button(title: "Button", action: onPress, type: .outline, size: .small)
|
|
72
|
-
}
|
|
23
|
+
private struct ButtonPreview: View {
|
|
24
|
+
private let url = "https://static-00.iconduck.com/assets.00/external-link-icon-512x512-h2zzryfc.png"
|
|
73
25
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
26
|
+
var body: some View {
|
|
27
|
+
BasicColumnBox("Title") {
|
|
28
|
+
MoMoUIKits.Button(title: "Open", action: {})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
BasicColumnBox("Type") {
|
|
32
|
+
MoMoUIKits.Button(title: "PRIMARY", action: {}, type: .primary)
|
|
33
|
+
MoMoUIKits.Button(title: "DANGER", action: {}, type: .danger)
|
|
34
|
+
MoMoUIKits.Button(title: "SECONDARY", action: {}, type: .secondary)
|
|
35
|
+
MoMoUIKits.Button(title: "TONAL", action: {}, type: .tonal)
|
|
36
|
+
MoMoUIKits.Button(title: "OUTLINE", action: {}, type: .outline)
|
|
37
|
+
MoMoUIKits.Button(title: "TEXT", action: {}, type: .text)
|
|
38
|
+
MoMoUIKits.Button(title: "DISABLED", action: {}, type: .disabled)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
BasicColumnBox("Size") {
|
|
42
|
+
MoMoUIKits.Button(title: "LARGE", action: {}, size: .large)
|
|
43
|
+
MoMoUIKits.Button(title: "MEDIUM", action: {}, size: .medium)
|
|
44
|
+
MoMoUIKits.Button(title: "SMALL", action: {}, size: .small)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
BasicColumnBox("Loading") {
|
|
48
|
+
MoMoUIKits.Button(title: "PRIMARY", action: {}, type: .primary, loading: true)
|
|
49
|
+
MoMoUIKits.Button(title: "DANGER", action: {}, type: .danger, loading: true)
|
|
50
|
+
MoMoUIKits.Button(title: "SECONDARY", action: {}, type: .secondary, loading: true)
|
|
51
|
+
MoMoUIKits.Button(title: "TONAL", action: {}, type: .tonal, loading: true)
|
|
52
|
+
MoMoUIKits.Button(title: "OUTLINE", action: {}, type: .outline, loading: true)
|
|
53
|
+
MoMoUIKits.Button(title: "TEXT", action: {}, type: .text, loading: true)
|
|
54
|
+
MoMoUIKits.Button(title: "DISABLED", action: {}, type: .disabled, loading: true)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
BasicColumnBox("Icon Right") {
|
|
58
|
+
MoMoUIKits.Button(title: "Icon", action: {}, iconRight: url)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
BasicColumnBox("Icon Left") {
|
|
62
|
+
MoMoUIKits.Button(title: "Icon", action: {}, iconLeft: url)
|
|
63
|
+
}
|
|
90
64
|
}
|
|
65
|
+
}
|
|
91
66
|
|
|
92
|
-
|
|
93
|
-
print("Button")
|
|
94
|
-
}
|
|
67
|
+
// MARK: - Playground
|
|
95
68
|
|
|
96
|
-
|
|
69
|
+
@available(iOS 16.0, *)
|
|
70
|
+
private struct ButtonPlayground: View {
|
|
71
|
+
@State private var title = "Button"
|
|
72
|
+
@State private var type: PlaygroundOption? = buttonTypeList.first { $0.key == "primary" }
|
|
73
|
+
@State private var size: PlaygroundOption? = buttonSizeList.first { $0.key == "large" }
|
|
74
|
+
@State private var iconRight: PlaygroundOption?
|
|
75
|
+
// Seeded (Compose leaves both nil) so the UseTintColor toggle has an icon to act on.
|
|
76
|
+
@State private var iconLeft: PlaygroundOption? = playgroundIcons.first { $0.key == "basic_home" }
|
|
77
|
+
@State private var full = true
|
|
78
|
+
@State private var loading = false
|
|
79
|
+
@State private var useTintColor = true
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
var body: some View {
|
|
82
|
+
PlaygroundTab(
|
|
83
|
+
component: {
|
|
84
|
+
MoMoUIKits.Button(
|
|
85
|
+
title: title,
|
|
86
|
+
action: {},
|
|
87
|
+
type: (type?.value as? ButtonType) ?? .primary,
|
|
88
|
+
size: (size?.value as? ButtonSize) ?? .large,
|
|
89
|
+
iconLeft: (iconLeft?.value as? String) ?? "",
|
|
90
|
+
iconRight: (iconRight?.value as? String) ?? "",
|
|
91
|
+
isFull: full,
|
|
92
|
+
loading: loading,
|
|
93
|
+
useTintColor: useTintColor
|
|
94
|
+
)
|
|
95
|
+
},
|
|
96
|
+
params: [
|
|
97
|
+
.string("Children", $title),
|
|
98
|
+
.radio("Type", buttonTypeList, $type),
|
|
99
|
+
.radio("Size", buttonSizeList, $size),
|
|
100
|
+
.checkbox("Full", $full),
|
|
101
|
+
.option("IconRight", playgroundIcons, $iconRight),
|
|
102
|
+
.option("IconLeft", playgroundIcons, $iconLeft),
|
|
103
|
+
.checkbox("Loading", $loading),
|
|
104
|
+
.checkbox("UseTintColor", $useTintColor),
|
|
105
|
+
]
|
|
106
|
+
)
|
|
107
|
+
}
|
|
100
108
|
}
|