@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,110 +2,116 @@
|
|
|
2
2
|
// InputDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo, mirroring Compose's InputUsage.kt.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import SwiftUI
|
|
9
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
10
10
|
|
|
11
11
|
struct InputDemo: View {
|
|
12
|
-
@State private var textValue1 = ""
|
|
13
|
-
@State private var textValue2 = ""
|
|
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
|
-
|
|
22
12
|
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
|
-
|
|
51
|
-
|
|
52
|
-
Group {
|
|
53
|
-
Text("Hint")
|
|
54
|
-
.font(.headerText1)
|
|
55
|
-
|
|
56
|
-
Input(text: $textValue4, placeholder: "Enter here", hintText: textValue4.isEmpty ? "Hint text" : textValue4 )
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
Group {
|
|
60
|
-
Text("Error")
|
|
61
|
-
.font(.headerText1)
|
|
62
|
-
|
|
63
|
-
Input(text: $textValue4, placeholder: "Enter here", error: textValue4.isEmpty ? "Error" : textValue4 )
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
Group {
|
|
67
|
-
Text("Disabled")
|
|
68
|
-
.font(.headerText1)
|
|
69
|
-
|
|
70
|
-
Input(text: $textValue5, placeholder: "Enter here", disabled: true, leadingIcon: "01.MoMo"
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
Group {
|
|
75
|
-
Text("Leading Icon")
|
|
76
|
-
.font(.headerText1)
|
|
77
|
-
|
|
78
|
-
Input(text: $textValue6, placeholder: "Leading Icon", floatingValue: "Small Input", leadingIcon: "01.MoMo"
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
Input(text: $textValue7, placeholder: "Leading Icon", floatingValue: "Large Input", size: .large, leadingIcon: "01.MoMo"
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
Group {
|
|
86
|
-
Text("Trailing Icon")
|
|
87
|
-
.font(.headerText1)
|
|
88
|
-
|
|
89
|
-
Input(text: $textValue8, placeholder: "Trailing Icon", floatingValue: "Trailing", rightIcon: "01.MoMo")
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
Group {
|
|
93
|
-
Text("Loading")
|
|
94
|
-
.font(.headerText1)
|
|
95
|
-
|
|
96
|
-
Input(text: $textValue8, placeholder: "Loading", floatingValue: "Loading", loading: true, required: true)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
Group {
|
|
100
|
-
Text("Font Weight")
|
|
101
|
-
.font(.headerText1)
|
|
102
|
-
|
|
103
|
-
Input(text: $textValue9, placeholder: "Font Weight", floatingValue: "Regular Font Weight", required: true, fontWeight: .regular)
|
|
104
|
-
|
|
105
|
-
Input(text: $textValue9, placeholder: "Font Weight", floatingValue: "Bold Font Weight", required: true, fontWeight: .bold)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
.padding()
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { InputPreview() }, playground: { InputPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// MARK: - Preview
|
|
22
|
+
|
|
23
|
+
private struct InputPreview: View {
|
|
24
|
+
@State private var t1 = ""
|
|
25
|
+
@State private var t2 = ""
|
|
26
|
+
@State private var t3 = ""
|
|
27
|
+
@State private var t4 = ""
|
|
28
|
+
@State private var t5 = ""
|
|
29
|
+
@State private var t6 = ""
|
|
30
|
+
@State private var t7 = ""
|
|
31
|
+
|
|
32
|
+
var body: some View {
|
|
33
|
+
BasicColumnBox("Size", alignment: .leading) {
|
|
34
|
+
Input(text: $t1, placeholder: "Small", size: .small)
|
|
35
|
+
Input(text: $t1, placeholder: "Large", size: .large)
|
|
36
|
+
}
|
|
37
|
+
BasicColumnBox("Floating Value", alignment: .leading) {
|
|
38
|
+
Input(text: $t2, placeholder: "Enter here", floatingValue: "Momo", floatingIcon: "01.MoMo")
|
|
39
|
+
}
|
|
40
|
+
BasicColumnBox("Secure Text Entry", alignment: .leading) {
|
|
41
|
+
Input(text: $t3, placeholder: "Enter here", floatingValue: "Momo", secureTextEntry: true)
|
|
109
42
|
}
|
|
43
|
+
BasicColumnBox("Hint", alignment: .leading) {
|
|
44
|
+
Input(text: $t4, placeholder: "Enter here", hintText: "Hint text")
|
|
45
|
+
}
|
|
46
|
+
BasicColumnBox("Error", alignment: .leading) {
|
|
47
|
+
Input(text: $t5, placeholder: "Enter here", error: "Error")
|
|
48
|
+
}
|
|
49
|
+
BasicColumnBox("Disabled", alignment: .leading) {
|
|
50
|
+
Input(text: $t6, placeholder: "Enter here", disabled: true, leadingIcon: "01.MoMo")
|
|
51
|
+
}
|
|
52
|
+
BasicColumnBox("Loading", alignment: .leading) {
|
|
53
|
+
Input(text: $t7, placeholder: "Loading", floatingValue: "Loading", loading: true, required: true)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// MARK: - Playground
|
|
59
|
+
|
|
60
|
+
@available(iOS 16.0, *)
|
|
61
|
+
private struct InputPlayground: View {
|
|
62
|
+
@State private var text = ""
|
|
63
|
+
@State private var placeholder = "Placeholder"
|
|
64
|
+
@State private var floatingValue = ""
|
|
65
|
+
@State private var hintText = ""
|
|
66
|
+
@State private var error = ""
|
|
67
|
+
@State private var size: PlaygroundOption? = inputSizeList.first { $0.key == "small" }
|
|
68
|
+
@State private var fontWeight: PlaygroundOption? = inputFontWeightList.first { $0.key == "regular" }
|
|
69
|
+
@State private var keyboardType: PlaygroundOption? = keyboardTypeList.first { $0.key == "default" }
|
|
70
|
+
@State private var leadingIcon: PlaygroundOption?
|
|
71
|
+
@State private var rightIcon: PlaygroundOption?
|
|
72
|
+
@State private var maxLength = ""
|
|
73
|
+
@State private var disabled = false
|
|
74
|
+
@State private var secure = false
|
|
75
|
+
@State private var loading = false
|
|
76
|
+
@State private var required = false
|
|
77
|
+
|
|
78
|
+
var body: some View {
|
|
79
|
+
PlaygroundTab(
|
|
80
|
+
component: {
|
|
81
|
+
Input(
|
|
82
|
+
text: $text,
|
|
83
|
+
placeholder: placeholder,
|
|
84
|
+
floatingValue: floatingValue,
|
|
85
|
+
size: (size?.value as? InputSize) ?? .small,
|
|
86
|
+
hintText: hintText,
|
|
87
|
+
error: error,
|
|
88
|
+
disabled: disabled,
|
|
89
|
+
secureTextEntry: secure,
|
|
90
|
+
rightIcon: (rightIcon?.value as? String) ?? "",
|
|
91
|
+
leadingIcon: (leadingIcon?.value as? String) ?? "",
|
|
92
|
+
loading: loading,
|
|
93
|
+
required: required,
|
|
94
|
+
maxLength: maxLength.isEmpty ? nil : Int(maxLength),
|
|
95
|
+
fontWeight: (fontWeight?.value as? InputFontWeight) ?? .regular,
|
|
96
|
+
keyboardType: (keyboardType?.value as? UIKeyboardType) ?? .default
|
|
97
|
+
)
|
|
98
|
+
},
|
|
99
|
+
params: [
|
|
100
|
+
.string("Placeholder", $placeholder),
|
|
101
|
+
.string("FloatingValue", $floatingValue),
|
|
102
|
+
.string("HintText", $hintText),
|
|
103
|
+
.string("Error", $error),
|
|
104
|
+
.radio("Size", inputSizeList, $size),
|
|
105
|
+
.radio("FontWeight", inputFontWeightList, $fontWeight),
|
|
106
|
+
.radio("KeyboardType", keyboardTypeList, $keyboardType),
|
|
107
|
+
.option("LeadingIcon", playgroundIcons, $leadingIcon),
|
|
108
|
+
.option("RightIcon", playgroundIcons, $rightIcon),
|
|
109
|
+
.number("MaxLength", $maxLength),
|
|
110
|
+
.checkbox("Disabled", $disabled),
|
|
111
|
+
.checkbox("SecureTextEntry", $secure),
|
|
112
|
+
.checkbox("Loading", $loading),
|
|
113
|
+
.checkbox("Required", $required),
|
|
114
|
+
]
|
|
115
|
+
)
|
|
110
116
|
}
|
|
111
117
|
}
|
|
@@ -2,135 +2,93 @@
|
|
|
2
2
|
// InputDropDownDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
//
|
|
5
|
+
// Preview + Playground demo for InputDropDown.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import SwiftUI
|
|
9
8
|
import MoMoUIKits
|
|
9
|
+
import SwiftUI
|
|
10
10
|
|
|
11
11
|
struct InputDropDownDemo: View {
|
|
12
|
-
@State private var empty = ""
|
|
13
|
-
@State private var errorValue = "Error input"
|
|
14
|
-
|
|
15
12
|
var body: some View {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
InputDropDown(value: $empty, placeholder: "Input small", size: .small)
|
|
24
|
-
InputDropDown(value: $empty, placeholder: "Input large", size: .large)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
Group {
|
|
28
|
-
Text("Floating Value").font(.headerText1)
|
|
29
|
-
InputDropDown(
|
|
30
|
-
value: $empty,
|
|
31
|
-
floatingValue: "Title",
|
|
32
|
-
floatingIcon: "basic_home",
|
|
33
|
-
placeholder: "Select options"
|
|
34
|
-
)
|
|
35
|
-
InputDropDown(
|
|
36
|
-
value: $empty,
|
|
37
|
-
floatingValue: "Title",
|
|
38
|
-
floatingIcon: "basic_home",
|
|
39
|
-
floatingIconColor: Colors.pink03,
|
|
40
|
-
placeholder: "Select options"
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
Group {
|
|
45
|
-
Text("Error message").font(.headerText1)
|
|
46
|
-
InputDropDown(
|
|
47
|
-
value: $errorValue,
|
|
48
|
-
placeholder: "Error input",
|
|
49
|
-
error: "Error message"
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
Group {
|
|
54
|
-
Text("Hint message").font(.headerText1)
|
|
55
|
-
InputDropDown(
|
|
56
|
-
value: $empty,
|
|
57
|
-
placeholder: "Error input",
|
|
58
|
-
hintText: "Hint message"
|
|
59
|
-
)
|
|
60
|
-
}
|
|
13
|
+
if #available(iOS 16.0, *) {
|
|
14
|
+
DemoScreen(preview: { InputDropDownPreview() }, playground: { InputDropDownPlayground() })
|
|
15
|
+
} else {
|
|
16
|
+
Text("Requires iOS 16+").padding()
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
61
20
|
|
|
62
|
-
|
|
63
|
-
Text("Disabled").font(.headerText1)
|
|
64
|
-
InputDropDown(
|
|
65
|
-
value: $empty,
|
|
66
|
-
floatingValue: "Title",
|
|
67
|
-
floatingIcon: "basic_home",
|
|
68
|
-
placeholder: "Disabled input",
|
|
69
|
-
disabled: true
|
|
70
|
-
)
|
|
71
|
-
}
|
|
21
|
+
// MARK: - Preview
|
|
72
22
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
value: $empty,
|
|
77
|
-
placeholder: "",
|
|
78
|
-
errorSpacing: true
|
|
79
|
-
)
|
|
80
|
-
}
|
|
23
|
+
private struct InputDropDownPreview: View {
|
|
24
|
+
@State private var empty = ""
|
|
25
|
+
@State private var errorValue = "Error input"
|
|
81
26
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
27
|
+
var body: some View {
|
|
28
|
+
BasicColumnBox("Size", alignment: .leading) {
|
|
29
|
+
InputDropDown(value: $empty, placeholder: "Input small", size: .small)
|
|
30
|
+
InputDropDown(value: $empty, placeholder: "Input large", size: .large)
|
|
31
|
+
}
|
|
32
|
+
BasicColumnBox("Floating Value", alignment: .leading) {
|
|
33
|
+
InputDropDown(value: $empty, floatingValue: "Title", floatingIcon: "basic_home", placeholder: "Select options")
|
|
34
|
+
}
|
|
35
|
+
BasicColumnBox("Error message", alignment: .leading) {
|
|
36
|
+
InputDropDown(value: $errorValue, placeholder: "Error input", error: "Error message")
|
|
37
|
+
}
|
|
38
|
+
BasicColumnBox("Disabled", alignment: .leading) {
|
|
39
|
+
InputDropDown(value: $empty, floatingValue: "Title", floatingIcon: "basic_home", placeholder: "Disabled input", disabled: true)
|
|
40
|
+
}
|
|
41
|
+
BasicColumnBox("Leading Icon", alignment: .leading) {
|
|
42
|
+
InputDropDown(value: $empty, floatingValue: "Small input", placeholder: "Leading icon", leadingIcon: "basic_home")
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
98
46
|
|
|
99
|
-
|
|
100
|
-
Text("Icon").font(.headerText1)
|
|
101
|
-
InputDropDown(
|
|
102
|
-
value: $empty,
|
|
103
|
-
placeholder: "Right icon",
|
|
104
|
-
icon: "arrow_chevron_down_small"
|
|
105
|
-
)
|
|
106
|
-
InputDropDown(
|
|
107
|
-
value: $empty,
|
|
108
|
-
placeholder: "Right icon",
|
|
109
|
-
icon: "arrow_chevron_down_small",
|
|
110
|
-
iconColor: Colors.pink03
|
|
111
|
-
)
|
|
112
|
-
}
|
|
47
|
+
// MARK: - Playground
|
|
113
48
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
49
|
+
@available(iOS 16.0, *)
|
|
50
|
+
private struct InputDropDownPlayground: View {
|
|
51
|
+
@State private var value = ""
|
|
52
|
+
@State private var placeholder = "Select options"
|
|
53
|
+
@State private var floatingValue = ""
|
|
54
|
+
@State private var hintText = ""
|
|
55
|
+
@State private var error = ""
|
|
56
|
+
@State private var size: PlaygroundOption? = inputSizeList.first { $0.key == "small" }
|
|
57
|
+
@State private var leadingIcon: PlaygroundOption?
|
|
58
|
+
@State private var disabled = false
|
|
59
|
+
@State private var errorSpacing = false
|
|
60
|
+
@State private var loading = false
|
|
61
|
+
@State private var required = false
|
|
123
62
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
63
|
+
var body: some View {
|
|
64
|
+
PlaygroundTab(
|
|
65
|
+
component: {
|
|
66
|
+
InputDropDown(
|
|
67
|
+
value: $value,
|
|
68
|
+
floatingValue: floatingValue,
|
|
69
|
+
placeholder: placeholder,
|
|
70
|
+
size: (size?.value as? InputSize) ?? .small,
|
|
71
|
+
hintText: hintText,
|
|
72
|
+
error: error,
|
|
73
|
+
errorSpacing: errorSpacing,
|
|
74
|
+
disabled: disabled,
|
|
75
|
+
leadingIcon: (leadingIcon?.value as? String) ?? "",
|
|
76
|
+
loading: loading,
|
|
77
|
+
required: required
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
params: [
|
|
81
|
+
.string("Placeholder", $placeholder),
|
|
82
|
+
.string("FloatingValue", $floatingValue),
|
|
83
|
+
.string("HintText", $hintText),
|
|
84
|
+
.string("Error", $error),
|
|
85
|
+
.radio("Size", inputSizeList, $size),
|
|
86
|
+
.option("LeadingIcon", playgroundIcons, $leadingIcon),
|
|
87
|
+
.checkbox("Disabled", $disabled),
|
|
88
|
+
.checkbox("ErrorSpacing", $errorSpacing),
|
|
89
|
+
.checkbox("Loading", $loading),
|
|
90
|
+
.checkbox("Required", $required),
|
|
91
|
+
]
|
|
92
|
+
)
|
|
135
93
|
}
|
|
136
94
|
}
|
|
@@ -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
|