@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.
Files changed (93) hide show
  1. package/CLAUDE.md +19 -0
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/compose.podspec +1 -1
  4. package/gradle.properties +1 -1
  5. package/ios/Application/ApplicationEnvironment.swift +14 -6
  6. package/ios/Application/LanguageSource.swift +93 -0
  7. package/ios/Application/Localize.swift +73 -4
  8. package/ios/Application/LocalizeModifier.swift +30 -0
  9. package/ios/Application/Navigation/NavigationContainer.swift +28 -18
  10. package/ios/Application/Navigation/Navigator.swift +121 -53
  11. package/ios/Application/Navigation/NavigatorManager.swift +49 -0
  12. package/ios/Application/Navigation/component/NavigationFooter.swift +90 -0
  13. package/ios/Application/StackScreen.swift +19 -28
  14. package/ios/Badge/Badge.swift +2 -1
  15. package/ios/Badge/BadgeRibbon.swift +6 -2
  16. package/ios/Button/Button.swift +41 -61
  17. package/ios/Chip/Chip.swift +6 -5
  18. package/ios/Icon/Icon.swift +13 -4
  19. package/ios/Input/ErrorView.swift +2 -1
  20. package/ios/Input/Input.swift +9 -2
  21. package/ios/Input/InputPhoneNumber.swift +2 -1
  22. package/ios/Input/InputSearch.swift +3 -2
  23. package/ios/Input/InputTextArea.swift +6 -1
  24. package/ios/InputMoney/InputMoney.swift +5 -2
  25. package/ios/InputOTP/InputOTP.swift +2 -1
  26. package/ios/Layout/GridContext.swift +30 -0
  27. package/ios/Layout/Item.swift +42 -0
  28. package/ios/Layout/Section.swift +134 -0
  29. package/ios/Popup/PopupNotify.swift +2 -1
  30. package/ios/ProgressInfo/ProgressInfo.swift +4 -3
  31. package/ios/Rating/Rating.swift +2 -1
  32. package/ios/Stepper/Stepper.swift +2 -1
  33. package/ios/SuggestAction/SuggestAction.swift +3 -2
  34. package/ios/Tag/Tag.swift +2 -1
  35. package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
  36. package/ios/Title/Title.swift +3 -2
  37. package/ios/Tooltip/Tooltip.swift +2 -1
  38. package/ios/Typography/FontScale.swift +103 -0
  39. package/ios/Typography/FontScaleStore.swift +52 -13
  40. package/ios/Typography/Text.swift +12 -29
  41. package/ios/Typography/Typography.swift +66 -86
  42. package/ios/native-kits.podspec +2 -1
  43. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  44. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +87 -73
  45. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +55 -249
  46. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +90 -82
  47. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +74 -104
  48. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +47 -50
  49. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +63 -7
  50. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +90 -81
  51. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +73 -97
  52. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DemoScreen.swift +420 -0
  53. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +46 -4
  54. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +54 -57
  55. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +80 -45
  56. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconDemo.swift +81 -0
  57. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +49 -62
  58. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +66 -116
  59. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +104 -98
  60. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +76 -118
  61. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +73 -86
  62. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +69 -54
  63. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +74 -54
  64. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +73 -20
  65. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +68 -38
  66. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +55 -52
  67. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +51 -4
  68. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +14 -2
  69. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +47 -51
  70. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PlaygroundData.swift +76 -0
  71. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +67 -93
  72. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +34 -43
  73. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +83 -71
  74. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +55 -23
  75. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +58 -46
  76. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SectionDemo.swift +83 -0
  77. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +41 -12
  78. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +67 -127
  79. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +54 -110
  80. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +69 -79
  81. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +78 -58
  82. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +76 -65
  83. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +82 -127
  84. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +44 -19
  85. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +92 -168
  86. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +79 -27
  87. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +0 -1
  88. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +87 -92
  89. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +94 -163
  90. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +70 -70
  91. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +68 -114
  92. package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +3 -1
  93. package/package.json +2 -2
@@ -2,110 +2,116 @@
2
2
  // InputDemo.swift
3
3
  // Example
4
4
  //
5
- // Created by dung.pham2 on 29/11/24.
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
- ScrollView {
24
- VStack(alignment: .leading, spacing: 20) {
25
- Text("Input Demo")
26
- .font(.title1)
27
-
28
- Group {
29
- Text("Size")
30
- .font(.headerText1)
31
-
32
- Input(text: $textValue1, placeholder: "Small", size: .small, autofocus: true)
33
- Input(text: $textValue1, placeholder: "Large", size: .large)
34
- }
35
-
36
- Group {
37
- Text("Secure Text Entry")
38
- .font(.headerText1)
39
-
40
- Input(text: $textValue2, placeholder: "Enter here", floatingValue: "Momo", floatingIcon: "01.MoMo", secureTextEntry: true, autofocus: true)
41
- Input(text: $textValue2, placeholder: "Enter here", floatingValue: "Momo", floatingIcon: "01.MoMo", size: .large, secureTextEntry: true)
42
- }
43
-
44
- Group {
45
- Text("Floating Value")
46
- .font(.headerText1)
47
-
48
- Input(text: $textValue3, placeholder: "Enter here", floatingValue: "Momo", floatingIcon: "01.MoMo")
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
- // Showcases InputDropDown mirroring InputDropDownUsage.kt.
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
- ScrollView {
17
- VStack(alignment: .leading, spacing: 20) {
18
- Text("InputDropDown Demo")
19
- .font(.title1)
20
-
21
- Group {
22
- Text("Size").font(.headerText1)
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
- Group {
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
- Group {
74
- Text("Error spacing").font(.headerText1)
75
- InputDropDown(
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
- Group {
83
- Text("Leading Icon").font(.headerText1)
84
- InputDropDown(
85
- value: $empty,
86
- floatingValue: "Small input",
87
- placeholder: "Leading icon",
88
- leadingIcon: "basic_home"
89
- )
90
- InputDropDown(
91
- value: $empty,
92
- floatingValue: "Large input",
93
- placeholder: "Leading icon",
94
- size: .large,
95
- leadingIcon: "basic_home"
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
- Group {
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
- Group {
115
- Text("Required").font(.headerText1)
116
- InputDropDown(
117
- value: $empty,
118
- floatingValue: "Title",
119
- placeholder: "Required field",
120
- required: true
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
- Group {
125
- Text("Loading").font(.headerText1)
126
- InputDropDown(
127
- value: $empty,
128
- placeholder: "Loading",
129
- loading: true
130
- )
131
- }
132
- }
133
- .padding()
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
- // Usage demo for InputMoney. Mirrors Compose's InputMoneyUsage preview cases.
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
- ScrollView {
21
- VStack(alignment: .leading, spacing: 24) {
22
- section(title: "Size") {
23
- InputMoney(
24
- text: $text1,
25
- placeholder: "Small",
26
- size: .small,
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
- section(title: "Disabled") {
58
- InputMoney(
59
- text: .constant(""),
60
- placeholder: "Enter amount",
61
- disabled: true,
62
- icon: "basic_home"
63
- )
64
- }
21
+ // MARK: - Preview
65
22
 
66
- section(title: "Icon") {
67
- InputMoney(
68
- text: $text5,
69
- floatingValue: "Amount",
70
- placeholder: "With icon",
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
- section(title: "Error spacing") {
78
- InputMoney(
79
- text: $text6,
80
- placeholder: "Enter amount",
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
- @ViewBuilder
91
- private func section<Content: View>(title: String, @ViewBuilder content: () -> Content) -> some View {
92
- VStack(alignment: .leading, spacing: 12) {
93
- Text(title)
94
- .font(.headline)
95
- .foregroundColor(.secondary)
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
- #if DEBUG
102
- struct InputMoneyDemo_Previews: PreviewProvider {
103
- static var previews: some View {
104
- InputMoneyDemo()
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