@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,106 +2,93 @@
|
|
|
2
2
|
// InputMoneyDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo for InputMoney.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import MoMoUIKits
|
|
9
9
|
import SwiftUI
|
|
10
10
|
|
|
11
11
|
struct InputMoneyDemo: View {
|
|
12
|
-
@State private var text1 = ""
|
|
13
|
-
@State private var text2 = ""
|
|
14
|
-
@State private var text3 = ""
|
|
15
|
-
@State private var text4 = ""
|
|
16
|
-
@State private var text5 = ""
|
|
17
|
-
@State private var text6 = ""
|
|
18
|
-
|
|
19
12
|
var body: some View {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
onChangeText: { text1 = $0 }
|
|
28
|
-
)
|
|
29
|
-
InputMoney(
|
|
30
|
-
text: $text2,
|
|
31
|
-
placeholder: "Large",
|
|
32
|
-
size: .large,
|
|
33
|
-
onChangeText: { text2 = $0 }
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
section(title: "Floating Value") {
|
|
38
|
-
InputMoney(
|
|
39
|
-
text: $text3,
|
|
40
|
-
floatingValue: "Amount",
|
|
41
|
-
floatingIcon: "basic_home",
|
|
42
|
-
floatingIconColor: Colors.pink03,
|
|
43
|
-
placeholder: "Enter amount",
|
|
44
|
-
onChangeText: { text3 = $0 }
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
section(title: "Error") {
|
|
49
|
-
InputMoney(
|
|
50
|
-
text: $text4,
|
|
51
|
-
placeholder: "Enter amount",
|
|
52
|
-
error: "Invalid amount",
|
|
53
|
-
onChangeText: { text4 = $0 }
|
|
54
|
-
)
|
|
55
|
-
}
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { InputMoneyPreview() }, playground: { InputMoneyPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
56
20
|
|
|
57
|
-
|
|
58
|
-
InputMoney(
|
|
59
|
-
text: .constant(""),
|
|
60
|
-
placeholder: "Enter amount",
|
|
61
|
-
disabled: true,
|
|
62
|
-
icon: "basic_home"
|
|
63
|
-
)
|
|
64
|
-
}
|
|
21
|
+
// MARK: - Preview
|
|
65
22
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
icon: "basic_home",
|
|
72
|
-
iconColor: Colors.pink03,
|
|
73
|
-
onChangeText: { text5 = $0 }
|
|
74
|
-
)
|
|
75
|
-
}
|
|
23
|
+
private struct InputMoneyPreview: View {
|
|
24
|
+
@State private var t1 = ""
|
|
25
|
+
@State private var t2 = ""
|
|
26
|
+
@State private var t3 = ""
|
|
27
|
+
@State private var t4 = ""
|
|
76
28
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
errorSpacing: true,
|
|
82
|
-
onChangeText: { text6 = $0 }
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
.padding(16)
|
|
29
|
+
var body: some View {
|
|
30
|
+
BasicColumnBox("Size", alignment: .leading) {
|
|
31
|
+
InputMoney(text: $t1, placeholder: "Small", size: .small, onChangeText: { t1 = $0 })
|
|
32
|
+
InputMoney(text: $t2, placeholder: "Large", size: .large, onChangeText: { t2 = $0 })
|
|
87
33
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
content()
|
|
34
|
+
BasicColumnBox("Floating Value", alignment: .leading) {
|
|
35
|
+
InputMoney(text: $t3, floatingValue: "Amount", floatingIcon: "basic_home", floatingIconColor: Colors.pink03, placeholder: "Enter amount", onChangeText: { t3 = $0 })
|
|
36
|
+
}
|
|
37
|
+
BasicColumnBox("Error", alignment: .leading) {
|
|
38
|
+
InputMoney(text: $t4, placeholder: "Enter amount", error: "Invalid amount", onChangeText: { t4 = $0 })
|
|
39
|
+
}
|
|
40
|
+
BasicColumnBox("Disabled", alignment: .leading) {
|
|
41
|
+
InputMoney(text: .constant(""), placeholder: "Enter amount", disabled: true, icon: "basic_home")
|
|
97
42
|
}
|
|
98
43
|
}
|
|
99
44
|
}
|
|
100
45
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
46
|
+
// MARK: - Playground
|
|
47
|
+
|
|
48
|
+
@available(iOS 16.0, *)
|
|
49
|
+
private struct InputMoneyPlayground: View {
|
|
50
|
+
@State private var text = ""
|
|
51
|
+
@State private var placeholder = "0đ"
|
|
52
|
+
@State private var floatingValue = ""
|
|
53
|
+
@State private var error = ""
|
|
54
|
+
@State private var size: PlaygroundOption? = inputSizeList.first { $0.key == "small" }
|
|
55
|
+
@State private var fontWeight: PlaygroundOption? = inputFontWeightList.first { $0.key == "bold" }
|
|
56
|
+
@State private var icon: PlaygroundOption?
|
|
57
|
+
@State private var disabled = false
|
|
58
|
+
@State private var errorSpacing = false
|
|
59
|
+
@State private var loading = false
|
|
60
|
+
@State private var required = false
|
|
61
|
+
|
|
62
|
+
var body: some View {
|
|
63
|
+
PlaygroundTab(
|
|
64
|
+
component: {
|
|
65
|
+
InputMoney(
|
|
66
|
+
text: $text,
|
|
67
|
+
floatingValue: floatingValue,
|
|
68
|
+
placeholder: placeholder,
|
|
69
|
+
size: (size?.value as? InputSize) ?? .small,
|
|
70
|
+
error: error,
|
|
71
|
+
errorSpacing: errorSpacing,
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
icon: (icon?.value as? String) ?? "",
|
|
74
|
+
loading: loading,
|
|
75
|
+
required: required,
|
|
76
|
+
fontWeight: (fontWeight?.value as? InputFontWeight) ?? .bold,
|
|
77
|
+
onChangeText: { text = $0 }
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
params: [
|
|
81
|
+
.string("Placeholder", $placeholder),
|
|
82
|
+
.string("FloatingValue", $floatingValue),
|
|
83
|
+
.string("Error", $error),
|
|
84
|
+
.radio("Size", inputSizeList, $size),
|
|
85
|
+
.radio("FontWeight", inputFontWeightList, $fontWeight),
|
|
86
|
+
.option("Icon", playgroundIcons, $icon),
|
|
87
|
+
.checkbox("Disabled", $disabled),
|
|
88
|
+
.checkbox("ErrorSpacing", $errorSpacing),
|
|
89
|
+
.checkbox("Loading", $loading),
|
|
90
|
+
.checkbox("Required", $required),
|
|
91
|
+
]
|
|
92
|
+
)
|
|
105
93
|
}
|
|
106
94
|
}
|
|
107
|
-
#endif
|
|
@@ -2,72 +2,87 @@
|
|
|
2
2
|
// InputOTPDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
// error message, error spacing, and a fixed-length numeric variant.
|
|
5
|
+
// Preview + Playground demo for InputOTP.
|
|
7
6
|
//
|
|
8
7
|
|
|
9
8
|
import MoMoUIKits
|
|
10
9
|
import SwiftUI
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
// Component-specific option maps (mirror otpLengthList / otpDataTypeList in DemoScreen.kt).
|
|
12
|
+
private let otpLengthList: [PlaygroundOption] = [
|
|
13
|
+
.init("2", 2), .init("4", 4), .init("6", 6), .init("8", 8), .init("10", 10),
|
|
14
|
+
]
|
|
15
|
+
private let otpDataTypeList: [PlaygroundOption] = [
|
|
16
|
+
.init("number", "number"), .init("string", "string"),
|
|
17
|
+
]
|
|
18
18
|
|
|
19
|
+
struct InputOTPDemo: View {
|
|
19
20
|
var body: some View {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
section("Placeholder") {
|
|
30
|
-
InputOTP(
|
|
31
|
-
value: $value2,
|
|
32
|
-
floatingValue: "",
|
|
33
|
-
placeholder: "Placeholder text"
|
|
34
|
-
)
|
|
35
|
-
}
|
|
21
|
+
if #available(iOS 16.0, *) {
|
|
22
|
+
DemoScreen(preview: { InputOTPPreview() }, playground: { InputOTPPlayground() })
|
|
23
|
+
} else {
|
|
24
|
+
Text("Requires iOS 16+").padding()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
InputOTP(
|
|
39
|
-
value: $value3,
|
|
40
|
-
errorMessage: "Error",
|
|
41
|
-
floatingValue: ""
|
|
42
|
-
)
|
|
43
|
-
}
|
|
29
|
+
// MARK: - Preview
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
}
|
|
31
|
+
private struct InputOTPPreview: View {
|
|
32
|
+
@State private var v1 = ""
|
|
33
|
+
@State private var v2 = ""
|
|
34
|
+
@State private var v3 = ""
|
|
35
|
+
@State private var v4 = ""
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
var body: some View {
|
|
38
|
+
BasicColumnBox("Floating Value", alignment: .leading) {
|
|
39
|
+
InputOTP(value: $v1, floatingValue: "Nhập mã xác thực OTP")
|
|
40
|
+
}
|
|
41
|
+
BasicColumnBox("Placeholder", alignment: .leading) {
|
|
42
|
+
InputOTP(value: $v2, floatingValue: "", placeholder: "Placeholder text")
|
|
43
|
+
}
|
|
44
|
+
BasicColumnBox("Error Message", alignment: .leading) {
|
|
45
|
+
InputOTP(value: $v3, errorMessage: "Error", floatingValue: "")
|
|
46
|
+
}
|
|
47
|
+
BasicColumnBox("Length 6, number", alignment: .leading) {
|
|
48
|
+
InputOTP(value: $v4, length: 6, floatingValue: "", dataType: "number")
|
|
63
49
|
}
|
|
64
50
|
}
|
|
51
|
+
}
|
|
65
52
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
// MARK: - Playground
|
|
54
|
+
|
|
55
|
+
@available(iOS 16.0, *)
|
|
56
|
+
private struct InputOTPPlayground: View {
|
|
57
|
+
@State private var value = ""
|
|
58
|
+
@State private var floatingValue = "Label"
|
|
59
|
+
@State private var placeholder = ""
|
|
60
|
+
@State private var errorMessage = ""
|
|
61
|
+
@State private var length: PlaygroundOption? = otpLengthList.first { $0.key == "6" }
|
|
62
|
+
@State private var dataType: PlaygroundOption? = otpDataTypeList.first { $0.key == "number" }
|
|
63
|
+
@State private var errorSpacing = false
|
|
64
|
+
|
|
65
|
+
var body: some View {
|
|
66
|
+
PlaygroundTab(
|
|
67
|
+
component: {
|
|
68
|
+
InputOTP(
|
|
69
|
+
value: $value,
|
|
70
|
+
length: length?.value as? Int,
|
|
71
|
+
errorMessage: errorMessage,
|
|
72
|
+
errorSpacing: errorSpacing,
|
|
73
|
+
floatingValue: floatingValue,
|
|
74
|
+
placeholder: placeholder,
|
|
75
|
+
dataType: (dataType?.value as? String) ?? "number"
|
|
76
|
+
)
|
|
77
|
+
},
|
|
78
|
+
params: [
|
|
79
|
+
.string("FloatingValue", $floatingValue),
|
|
80
|
+
.string("Placeholder", $placeholder),
|
|
81
|
+
.string("ErrorMessage", $errorMessage),
|
|
82
|
+
.radio("Length", otpLengthList, $length),
|
|
83
|
+
.radio("DataType", otpDataTypeList, $dataType),
|
|
84
|
+
.checkbox("ErrorSpacing", $errorSpacing),
|
|
85
|
+
]
|
|
86
|
+
)
|
|
72
87
|
}
|
|
73
88
|
}
|
|
@@ -2,67 +2,87 @@
|
|
|
2
2
|
// InputPhoneNumberDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo for InputPhoneNumber.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import SwiftUI
|
|
9
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
10
10
|
|
|
11
11
|
public struct InputPhoneNumberDemo: View {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@State private var textValue3 = ""
|
|
15
|
-
@State private var textValue4 = ""
|
|
16
|
-
@State private var textValue5 = ""
|
|
17
|
-
@State private var textValue6 = ""
|
|
18
|
-
@State private var textValue7 = ""
|
|
19
|
-
@State private var textValue8 = ""
|
|
20
|
-
@State private var textValue9 = ""
|
|
21
|
-
|
|
12
|
+
public init() {}
|
|
13
|
+
|
|
22
14
|
public var body: some View {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Group {
|
|
51
|
-
Text("Loading")
|
|
52
|
-
.font(.headerText1)
|
|
53
|
-
|
|
54
|
-
InputPhoneNumber(text: $textValue8, placeholder: "Loading", loading: true)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
Group {
|
|
58
|
-
Text("Trailing Icon")
|
|
59
|
-
.font(.headerText1)
|
|
60
|
-
|
|
61
|
-
InputPhoneNumber(text: $textValue9, placeholder: "Font Weight", rightIcon: "24_ic_public", rightIconColor: Colors.pink03)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
.padding()
|
|
15
|
+
if #available(iOS 16.0, *) {
|
|
16
|
+
DemoScreen(preview: { InputPhoneNumberPreview() }, playground: { InputPhoneNumberPlayground() })
|
|
17
|
+
} else {
|
|
18
|
+
Text("Requires iOS 16+").padding()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// MARK: - Preview
|
|
24
|
+
|
|
25
|
+
private struct InputPhoneNumberPreview: View {
|
|
26
|
+
@State private var t1 = ""
|
|
27
|
+
@State private var t2 = ""
|
|
28
|
+
@State private var t3 = ""
|
|
29
|
+
@State private var t4 = ""
|
|
30
|
+
@State private var t5 = ""
|
|
31
|
+
|
|
32
|
+
var body: some View {
|
|
33
|
+
BasicColumnBox("Size", alignment: .leading) {
|
|
34
|
+
InputPhoneNumber(text: $t1, placeholder: "Small", size: .small)
|
|
35
|
+
InputPhoneNumber(text: $t2, placeholder: "Large", size: .large)
|
|
36
|
+
}
|
|
37
|
+
BasicColumnBox("Hint text", alignment: .leading) {
|
|
38
|
+
InputPhoneNumber(text: $t3, placeholder: "Enter here", hintText: "Hint text")
|
|
39
|
+
}
|
|
40
|
+
BasicColumnBox("Error", alignment: .leading) {
|
|
41
|
+
InputPhoneNumber(text: $t4, placeholder: "Enter here", error: "error message")
|
|
65
42
|
}
|
|
43
|
+
BasicColumnBox("Trailing Icon", alignment: .leading) {
|
|
44
|
+
InputPhoneNumber(text: $t5, placeholder: "Phone", rightIcon: "24_ic_public", rightIconColor: Colors.pink03)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// MARK: - Playground
|
|
50
|
+
|
|
51
|
+
@available(iOS 16.0, *)
|
|
52
|
+
private struct InputPhoneNumberPlayground: View {
|
|
53
|
+
@State private var text = ""
|
|
54
|
+
@State private var placeholder = "0123456789"
|
|
55
|
+
@State private var hintText = ""
|
|
56
|
+
@State private var error = ""
|
|
57
|
+
@State private var size: PlaygroundOption? = inputSizeList.first { $0.key == "small" }
|
|
58
|
+
@State private var rightIcon: PlaygroundOption?
|
|
59
|
+
@State private var loading = false
|
|
60
|
+
@State private var required = false
|
|
61
|
+
|
|
62
|
+
var body: some View {
|
|
63
|
+
PlaygroundTab(
|
|
64
|
+
component: {
|
|
65
|
+
InputPhoneNumber(
|
|
66
|
+
text: $text,
|
|
67
|
+
placeholder: placeholder,
|
|
68
|
+
size: (size?.value as? InputSize) ?? .small,
|
|
69
|
+
hintText: hintText,
|
|
70
|
+
error: error,
|
|
71
|
+
loading: loading,
|
|
72
|
+
required: required,
|
|
73
|
+
rightIcon: (rightIcon?.value as? String) ?? ""
|
|
74
|
+
)
|
|
75
|
+
},
|
|
76
|
+
params: [
|
|
77
|
+
.string("Placeholder", $placeholder),
|
|
78
|
+
.string("HintText", $hintText),
|
|
79
|
+
.string("Error", $error),
|
|
80
|
+
.radio("Size", inputSizeList, $size),
|
|
81
|
+
.option("RightIcon", playgroundIcons, $rightIcon),
|
|
82
|
+
.checkbox("Loading", $loading),
|
|
83
|
+
.checkbox("Required", $required),
|
|
84
|
+
]
|
|
85
|
+
)
|
|
66
86
|
}
|
|
67
87
|
}
|
|
68
88
|
|
|
@@ -2,31 +2,84 @@
|
|
|
2
2
|
// InputSearchDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo for InputSearch.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import SwiftUI
|
|
9
8
|
import MoMoUIKits
|
|
10
|
-
|
|
11
|
-
// Your imports remain the same
|
|
9
|
+
import SwiftUI
|
|
12
10
|
|
|
13
11
|
public struct InputSearchDemo: View {
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
public init() {}
|
|
13
|
+
|
|
16
14
|
public var body: some View {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
if #available(iOS 16.0, *) {
|
|
16
|
+
DemoScreen(preview: { InputSearchPreview() }, playground: { InputSearchPlayground() })
|
|
17
|
+
} else {
|
|
18
|
+
Text("Requires iOS 16+").padding()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// MARK: - Preview
|
|
24
|
+
|
|
25
|
+
private struct InputSearchPreview: View {
|
|
26
|
+
@State private var t1 = ""
|
|
27
|
+
@State private var t2 = ""
|
|
28
|
+
@State private var t3 = ""
|
|
29
|
+
|
|
30
|
+
var body: some View {
|
|
31
|
+
BasicColumnBox("Default", alignment: .leading) {
|
|
32
|
+
InputSearch(text: $t1, placeholder: "Search")
|
|
33
|
+
.frame(height: 40)
|
|
34
|
+
}
|
|
35
|
+
BasicColumnBox("With cancel button", alignment: .leading) {
|
|
36
|
+
InputSearch(text: $t2, buttonText: "Huỷ", showButtonText: true, placeholder: "Search")
|
|
37
|
+
.frame(height: 40)
|
|
38
|
+
}
|
|
39
|
+
BasicColumnBox("Disabled", alignment: .leading) {
|
|
40
|
+
InputSearch(text: $t3, placeholder: "Search", disabled: true)
|
|
41
|
+
.frame(height: 40)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// MARK: - Playground
|
|
47
|
+
|
|
48
|
+
@available(iOS 16.0, *)
|
|
49
|
+
private struct InputSearchPlayground: View {
|
|
50
|
+
@State private var text = ""
|
|
51
|
+
@State private var placeholder = "Search"
|
|
52
|
+
@State private var buttonText = "Huỷ"
|
|
53
|
+
@State private var error = ""
|
|
54
|
+
@State private var showButtonText = false
|
|
55
|
+
@State private var showBorder = true
|
|
56
|
+
@State private var disabled = false
|
|
57
|
+
@State private var loading = false
|
|
58
|
+
|
|
59
|
+
var body: some View {
|
|
60
|
+
PlaygroundTab(
|
|
61
|
+
component: {
|
|
62
|
+
InputSearch(
|
|
63
|
+
text: $text,
|
|
64
|
+
buttonText: buttonText,
|
|
65
|
+
showButtonText: showButtonText,
|
|
66
|
+
showBorder: showBorder,
|
|
67
|
+
placeholder: placeholder,
|
|
68
|
+
error: error,
|
|
69
|
+
disabled: disabled,
|
|
70
|
+
loading: loading
|
|
71
|
+
)
|
|
72
|
+
.frame(height: 40)
|
|
73
|
+
},
|
|
74
|
+
params: [
|
|
75
|
+
.string("Placeholder", $placeholder),
|
|
76
|
+
.string("ButtonText", $buttonText),
|
|
77
|
+
.string("Error", $error),
|
|
78
|
+
.checkbox("ShowButtonText", $showButtonText),
|
|
79
|
+
.checkbox("ShowBorder", $showBorder),
|
|
80
|
+
.checkbox("Disabled", $disabled),
|
|
81
|
+
.checkbox("Loading", $loading),
|
|
82
|
+
]
|
|
83
|
+
)
|
|
31
84
|
}
|
|
32
85
|
}
|