@momo-kits/native-kits 0.162.2-beta.26-debug → 0.162.2-beta.27-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 (197) hide show
  1. package/CLAUDE.md +1 -1
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/compose.podspec +1 -1
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -5
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +1 -1
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -3
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +55 -40
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -4
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +2 -8
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +75 -93
  11. package/gradle.properties +1 -1
  12. package/ios/Application/ApplicationEnvironment.swift +0 -11
  13. package/ios/Application/Components.swift +44 -34
  14. package/ios/Application/FloatingButton.swift +9 -10
  15. package/ios/Application/HeaderRight.swift +45 -79
  16. package/ios/Application/Screen.swift +1 -2
  17. package/ios/Badge/Badge.swift +14 -11
  18. package/ios/Badge/BadgeRibbon.swift +21 -12
  19. package/ios/Button/Button.swift +22 -61
  20. package/ios/Checkbox/Checkbox.swift +13 -14
  21. package/ios/Chip/Chip.swift +9 -23
  22. package/ios/Colors+Radius+Spacing/Colors.swift +12 -12
  23. package/ios/Extensions/Color++.swift +0 -32
  24. package/ios/Icon/Icon.swift +1 -6
  25. package/ios/Input/Input.swift +25 -41
  26. package/ios/Input/InputPhoneNumber.swift +19 -20
  27. package/ios/Input/InputSearch.swift +47 -100
  28. package/ios/Input/InputTextArea.swift +40 -66
  29. package/ios/Popup/PopupDisplay.swift +16 -8
  30. package/ios/Popup/PopupInput.swift +8 -2
  31. package/ios/Swipeable/SwipeCell.swift +0 -185
  32. package/ios/Swipeable/SwipeCellModel.swift +0 -21
  33. package/ios/Typography/Text.swift +5 -79
  34. package/ios/Typography/Typography.swift +0 -3
  35. package/ios/native-kits.podspec +8 -61
  36. package/package.json +1 -1
  37. package/publish.sh +0 -50
  38. package/.claude/settings.local.json +0 -39
  39. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  43. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  44. package/ios/Application/Navigation/BottomTab/BottomTab.swift +0 -103
  45. package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +0 -215
  46. package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +0 -65
  47. package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
  48. package/ios/Application/Navigation/HeaderTitle.swift +0 -57
  49. package/ios/Application/Navigation/HeaderUser.swift +0 -209
  50. package/ios/Application/Navigation/NavigationContainer.swift +0 -176
  51. package/ios/Application/Navigation/NavigationOptions.swift +0 -109
  52. package/ios/Application/Navigation/Navigator.swift +0 -364
  53. package/ios/Application/Navigation/Overplay/BottomSheet.swift +0 -188
  54. package/ios/Application/Navigation/Overplay/ModalScreen.swift +0 -68
  55. package/ios/Application/Navigation/Overplay/SnackBar.swift +0 -144
  56. package/ios/Application/Navigation/component/Header.swift +0 -178
  57. package/ios/Application/Navigation/component/HeaderBackground.swift +0 -83
  58. package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
  59. package/ios/Application/StackScreen.swift +0 -453
  60. package/ios/Avatar/Avatar.swift +0 -193
  61. package/ios/BaselineView/BaselineView.swift +0 -163
  62. package/ios/Carousel/Carousel.swift +0 -181
  63. package/ios/Collapse/Collapse.swift +0 -182
  64. package/ios/Colors+Radius+Spacing/Theme.swift +0 -295
  65. package/ios/DateTimePicker/DateTimePicker.swift +0 -210
  66. package/ios/DateTimePicker/DateTimePickerTypes.swift +0 -55
  67. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -167
  68. package/ios/DateTimePicker/WheelPicker.swift +0 -161
  69. package/ios/Divider/Divider.swift +0 -16
  70. package/ios/IconButton/IconButton.swift +0 -112
  71. package/ios/InputDropDown/InputDropDown.swift +0 -198
  72. package/ios/InputMoney/InputMoney.swift +0 -335
  73. package/ios/InputOTP/InputOTP.swift +0 -210
  74. package/ios/Loader/Loader.swift +0 -113
  75. package/ios/MoMoUIKits.podspec +0 -5
  76. package/ios/Pagination/PaginationDot.swift +0 -61
  77. package/ios/Pagination/PaginationNumber.swift +0 -35
  78. package/ios/Pagination/PaginationScroll.swift +0 -101
  79. package/ios/Pagination/PaginationWhiteDot.swift +0 -37
  80. package/ios/Popup/PopupNotify.swift +0 -219
  81. package/ios/ProgressInfo/ProgressInfo.swift +0 -294
  82. package/ios/Radio/Radio.swift +0 -70
  83. package/ios/Rating/Rating.swift +0 -82
  84. package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +0 -11
  85. package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +0 -38
  86. package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +0 -38
  87. package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +0 -38
  88. package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +0 -6
  89. package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +0 -38
  90. package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +0 -38
  91. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +0 -38
  92. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +0 -38
  93. package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +0 -38
  94. package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +0 -38
  95. package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +0 -38
  96. package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +0 -38
  97. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +0 -9
  98. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +0 -38
  99. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +0 -38
  100. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +0 -38
  101. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +0 -38
  102. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +0 -38
  103. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +0 -38
  104. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +0 -38
  105. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +0 -38
  106. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +0 -38
  107. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +0 -38
  108. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +0 -38
  109. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +0 -38
  110. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +0 -38
  111. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +0 -38
  112. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +0 -38
  113. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +0 -38
  114. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +0 -38
  115. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +0 -38
  116. package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +0 -38
  117. package/ios/Skeleton/Skeleton.swift +0 -99
  118. package/ios/Slider/Slider.swift +0 -237
  119. package/ios/Stepper/Stepper.swift +0 -220
  120. package/ios/Steps/Steps.swift +0 -451
  121. package/ios/SuggestAction/SuggestAction.swift +0 -97
  122. package/ios/TabView/TabView.swift +0 -530
  123. package/ios/Tag/Tag.swift +0 -98
  124. package/ios/Title/Title.swift +0 -269
  125. package/ios/Tooltip/Tooltip.swift +0 -482
  126. package/ios/Typography/FontScaleStore.swift +0 -19
  127. package/ios/Uploader/Uploader.swift +0 -183
  128. package/ios-demo/MoMoUIKitsDemo.podspec +0 -20
  129. package/ios-demo/README.md +0 -120
  130. package/ios-demo/Resources/dot_loading.json +0 -558
  131. package/ios-demo/Resources/icon.json +0 -4052
  132. package/ios-demo/Resources/lottie_circle_loader.json +0 -1
  133. package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +0 -48
  134. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +0 -25
  135. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +0 -26
  136. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +0 -19
  137. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +0 -33
  138. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +0 -48
  139. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +0 -21
  140. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +0 -17
  141. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +0 -28
  142. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +0 -31
  143. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +0 -24
  144. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +0 -110
  145. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +0 -93
  146. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +0 -269
  147. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +0 -117
  148. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +0 -89
  149. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +0 -100
  150. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +0 -126
  151. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +0 -63
  152. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +0 -20
  153. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +0 -93
  154. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +0 -107
  155. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +0 -124
  156. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +0 -14
  157. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +0 -49
  158. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -278
  159. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +0 -58
  160. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +0 -78
  161. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +0 -138
  162. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +0 -111
  163. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +0 -136
  164. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +0 -107
  165. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +0 -73
  166. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +0 -100
  167. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +0 -32
  168. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +0 -57
  169. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +0 -70
  170. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -227
  171. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +0 -72
  172. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +0 -175
  173. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +0 -121
  174. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +0 -76
  175. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +0 -89
  176. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +0 -32
  177. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +0 -56
  178. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +0 -32
  179. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +0 -150
  180. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +0 -138
  181. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +0 -103
  182. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +0 -94
  183. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +0 -79
  184. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +0 -152
  185. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +0 -33
  186. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +0 -190
  187. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +0 -34
  188. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +0 -182
  189. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +0 -109
  190. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +0 -187
  191. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +0 -87
  192. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +0 -131
  193. package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +0 -51
  194. package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +0 -15
  195. package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +0 -73
  196. package/local.properties +0 -8
  197. package/scripts/gen-ios-color.mjs +0 -136
@@ -1,220 +0,0 @@
1
- import SwiftUI
2
-
3
- // ---------------------------------------------------------------------------
4
- // Size variant
5
- // ---------------------------------------------------------------------------
6
-
7
- public enum StepperSize {
8
- case large
9
- case small
10
- }
11
-
12
- private struct StepperSizeSpec {
13
- let buttonSize: CGFloat
14
- let iconSize: CGFloat
15
- let numberMinWidth: CGFloat
16
- let numberHeight: CGFloat
17
- }
18
-
19
- private func stepperSizeSpec(_ size: StepperSize) -> StepperSizeSpec {
20
- switch size {
21
- case .large:
22
- return StepperSizeSpec(buttonSize: 36, iconSize: 22, numberMinWidth: 32, numberHeight: 28)
23
- case .small:
24
- return StepperSizeSpec(buttonSize: 28, iconSize: 18, numberMinWidth: 28, numberHeight: 24)
25
- }
26
- }
27
-
28
- // ---------------------------------------------------------------------------
29
- // Disabled spec — mirrors Compose `disabled: Any` (Bool or per-part array)
30
- // ---------------------------------------------------------------------------
31
-
32
- public struct StepperDisabled {
33
- let minus: Bool
34
- let plus: Bool
35
-
36
- fileprivate var number: Bool { minus && plus }
37
-
38
- public init(minus: Bool, plus: Bool) {
39
- self.minus = minus
40
- self.plus = plus
41
- }
42
-
43
- /// All parts share the same disabled state.
44
- public init(_ all: Bool) {
45
- self.minus = all
46
- self.plus = all
47
- }
48
- }
49
-
50
- extension StepperDisabled: ExpressibleByBooleanLiteral {
51
- public init(booleanLiteral value: Bool) {
52
- self.init(value)
53
- }
54
- }
55
-
56
- // ---------------------------------------------------------------------------
57
- // Private sub-views
58
- // ---------------------------------------------------------------------------
59
-
60
- private struct StepperButton: View {
61
- @Environment(\.appTheme) private var theme
62
-
63
- var sign: String
64
- var size: StepperSize
65
- var disabled: Bool
66
- var onPress: () -> Void
67
-
68
- var body: some View {
69
- let specs = stepperSizeSpec(size)
70
- let iconColor: Color = disabled ? theme.colors.text.disable : theme.colors.primary
71
- let iconName = sign == "-" ? "24_navigation_minus_circle" : "24_navigation_plus_circle"
72
-
73
- SwiftUI.Button(action: { if !disabled { onPress() } }) {
74
- ZStack {
75
- Circle().fill(theme.colors.background.disable)
76
- Icon(source: iconName, size: specs.iconSize, color: iconColor)
77
- }
78
- .frame(width: specs.buttonSize, height: specs.buttonSize)
79
- }
80
- .buttonStyle(.plain)
81
- .disabled(disabled)
82
- }
83
- }
84
-
85
- private struct StepperNumberView: View {
86
- @Environment(\.appTheme) private var theme
87
-
88
- @Binding var text: String
89
- var size: StepperSize
90
- var disabled: Bool
91
- var editable: Bool
92
-
93
- var body: some View {
94
- let specs = stepperSizeSpec(size)
95
- let textColor: Color = disabled ? theme.colors.text.disable : theme.colors.text.default
96
- let borderColor: Color = disabled ? theme.colors.border.disable : theme.colors.border.default
97
-
98
- Group {
99
- if editable {
100
- TextField("", text: $text)
101
- .keyboardType(.numberPad)
102
- .multilineTextAlignment(.center)
103
- .disabled(disabled)
104
- } else {
105
- MomoText(text, typography: .descriptionDefaultRegular, color: textColor)
106
- }
107
- }
108
- .font(.system(size: scaleSize(12)))
109
- .ignoreBoldTextSetting()
110
- .foregroundColor(textColor)
111
- .frame(minWidth: specs.numberMinWidth)
112
- .frame(height: specs.numberHeight)
113
- .padding(.horizontal, Spacing.XS)
114
- .overlay(
115
- RoundedRectangle(cornerRadius: Radius.S)
116
- .stroke(borderColor, lineWidth: 1)
117
- )
118
- }
119
- }
120
-
121
- // ---------------------------------------------------------------------------
122
- // Public API — MomoStepper
123
- // ---------------------------------------------------------------------------
124
-
125
- /// MomoStepper — quantity +/- control. Layout: [- button] [value] [+ button].
126
- ///
127
- /// Named `MomoStepper` to avoid shadowing SwiftUI's built-in `Stepper`.
128
- ///
129
- /// - Parameters:
130
- /// - value: Binding to the current value. Clamped to `min...max`.
131
- /// - min: Minimum allowed value (default 0). Minus auto-disables at this bound.
132
- /// - max: Maximum allowed value (default 100). Plus auto-disables at this bound.
133
- /// - step: Amount added/subtracted per press (default 1).
134
- /// - size: Visual size variant (default `.large`).
135
- /// - disabled: Disable state — `true` for everything, or `StepperDisabled(minus:plus:)`.
136
- /// - editable: When `true` the number display becomes a keyboard input (default false).
137
- /// - onValueChange: Callback invoked with the new value on every change.
138
- public struct MomoStepper: View {
139
- @Binding private var value: Int
140
- private let min: Int
141
- private let max: Int
142
- private let step: Int
143
- private let size: StepperSize
144
- private let disabled: StepperDisabled
145
- private let editable: Bool
146
- private let onValueChange: (Int) -> Void
147
-
148
- @State private var editingText: String = ""
149
-
150
- public init(
151
- value: Binding<Int>,
152
- min: Int = 0,
153
- max: Int = 100,
154
- step: Int = 1,
155
- size: StepperSize = .large,
156
- disabled: StepperDisabled = false,
157
- editable: Bool = false,
158
- onValueChange: @escaping (Int) -> Void = { _ in }
159
- ) {
160
- self._value = value
161
- self.min = min
162
- self.max = max
163
- self.step = step
164
- self.size = size
165
- self.disabled = disabled
166
- self.editable = editable
167
- self.onValueChange = onValueChange
168
- }
169
-
170
- private func clamp(_ raw: Int) -> Int {
171
- Swift.max(min, Swift.min(max, raw))
172
- }
173
-
174
- private func applyValue(_ raw: Int) {
175
- let parsed = clamp(raw)
176
- value = parsed
177
- editingText = String(parsed)
178
- onValueChange(parsed)
179
- }
180
-
181
- public var body: some View {
182
- let effectiveMinusDisabled = disabled.minus || value <= min
183
- let effectivePlusDisabled = disabled.plus || value >= max
184
-
185
- HStack(spacing: Spacing.S) {
186
- StepperButton(
187
- sign: "-",
188
- size: size,
189
- disabled: effectiveMinusDisabled,
190
- onPress: { applyValue(value - step) }
191
- )
192
-
193
- StepperNumberView(
194
- text: Binding(
195
- get: { editable ? editingText : String(value) },
196
- set: { newText in
197
- editingText = newText
198
- let parsed = Int(newText.filter { $0.isNumber }) ?? 0
199
- applyValue(parsed)
200
- }
201
- ),
202
- size: size,
203
- disabled: disabled.number,
204
- editable: editable
205
- )
206
-
207
- StepperButton(
208
- sign: "+",
209
- size: size,
210
- disabled: effectivePlusDisabled,
211
- onPress: { applyValue(value + step) }
212
- )
213
- }
214
- .onAppear {
215
- let clamped = clamp(value)
216
- if clamped != value { value = clamped }
217
- editingText = String(clamped)
218
- }
219
- }
220
- }
@@ -1,451 +0,0 @@
1
- import SwiftUI
2
-
3
- // ─── Data model ────────────────────────────────────────────────────────────────
4
-
5
- /// A single step rendered inside a ``Steps`` indicator.
6
- public struct StepItem: Identifiable {
7
- public let id = UUID()
8
- public let title: String
9
- public let description: String?
10
- public let error: Bool
11
- public let time: String?
12
-
13
- public init(
14
- title: String,
15
- description: String? = nil,
16
- error: Bool = false,
17
- time: String? = nil
18
- ) {
19
- self.title = title
20
- self.description = description
21
- self.error = error
22
- self.time = time
23
- }
24
- }
25
-
26
- // ─── Enumerations ──────────────────────────────────────────────────────────────
27
-
28
- public enum StepsSize {
29
- case small
30
- case large
31
- }
32
-
33
- public enum StepsAlign {
34
- case left
35
- case right
36
- case center
37
- case stretch
38
- }
39
-
40
- // ─── Internal status ───────────────────────────────────────────────────────────
41
-
42
- private enum StepStatus {
43
- case incomplete
44
- case current
45
- case completed
46
- case error
47
- case disabled
48
- }
49
-
50
- private func resolveStatus(
51
- activeIndex: Int,
52
- currentIndex: Int,
53
- error: Bool,
54
- disabled: Bool
55
- ) -> StepStatus {
56
- if disabled { return .disabled }
57
- if error { return .error }
58
- if activeIndex == currentIndex { return .current }
59
- if activeIndex > currentIndex { return .completed }
60
- return .incomplete
61
- }
62
-
63
- // ─── Color helpers ─────────────────────────────────────────────────────────────
64
-
65
- private func resolveIconBgAndBorder(_ status: StepStatus, theme: Theme) -> (bg: Color, border: Color) {
66
- switch status {
67
- case .current, .completed:
68
- return (theme.colors.primary, theme.colors.background.tonal)
69
- case .error:
70
- return (theme.colors.error.primary, theme.colors.error.container)
71
- case .disabled:
72
- return (Colors.pink08, Colors.pink10)
73
- case .incomplete:
74
- return (Colors.black06, theme.colors.border.default)
75
- }
76
- }
77
-
78
- private func resolveTitleColor(_ status: StepStatus, theme: Theme) -> Color {
79
- switch status {
80
- case .current:
81
- return theme.colors.primary
82
- case .error:
83
- return theme.colors.error.primary
84
- case .disabled:
85
- return theme.colors.text.disable
86
- default:
87
- return theme.colors.text.default
88
- }
89
- }
90
-
91
- // ─── Step bubble ───────────────────────────────────────────────────────────────
92
-
93
- private struct StepBubble: View {
94
- @Environment(\.appTheme) private var theme
95
-
96
- let index: Int
97
- let isActive: Bool
98
- let error: Bool
99
- let size: StepsSize
100
- let status: StepStatus
101
- let useNumber: Bool
102
- let customIcon: String?
103
-
104
- private var bubbleSize: CGFloat { size == .small ? 16 : 24 }
105
- private var innerSize: CGFloat { size == .small ? 12 : 16 }
106
- private var dotSize: CGFloat { size == .small ? 6 : 8 }
107
-
108
- var body: some View {
109
- let colors = resolveIconBgAndBorder(status, theme: theme)
110
- ZStack {
111
- Circle()
112
- .fill(colors.bg)
113
- .overlay(Circle().strokeBorder(colors.border, lineWidth: 2))
114
-
115
- bubbleContent
116
- }
117
- .frame(width: bubbleSize, height: bubbleSize)
118
- }
119
-
120
- @ViewBuilder
121
- private var bubbleContent: some View {
122
- if useNumber {
123
- MomoText(
124
- "\(index + 1)",
125
- typography: .headerXsSemibold,
126
- color: Colors.black01
127
- )
128
- } else if isActive {
129
- if let customIcon = customIcon, !customIcon.isEmpty {
130
- Icon(source: customIcon, size: innerSize, color: Colors.black01)
131
- } else {
132
- Circle()
133
- .fill(Colors.black01)
134
- .frame(width: dotSize, height: dotSize)
135
- }
136
- } else {
137
- Icon(
138
- source: error ? "navigation_close" : "notifications_check",
139
- size: innerSize,
140
- color: Colors.black01
141
- )
142
- }
143
- }
144
- }
145
-
146
- // ─── Horizontal layout ─────────────────────────────────────────────────────────
147
-
148
- private struct StepsHorizontal: View {
149
- @Environment(\.appTheme) private var theme
150
-
151
- let steps: [StepItem]
152
- let activeIndex: Int
153
- let size: StepsSize
154
- let useNumber: Bool
155
- let align: StepsAlign
156
- let customIcon: String?
157
- let disabled: Bool
158
- let onPress: ((StepItem, Int) -> Void)?
159
-
160
- private var completedLine: Color { theme.colors.primary.opacity(0.2) }
161
- private var defaultLine: Color { theme.colors.background.default }
162
-
163
- var body: some View {
164
- HStack(alignment: .top, spacing: 0) {
165
- ForEach(Array(steps.enumerated()), id: \.element.id) { index, item in
166
- column(index: index, item: item)
167
- .frame(maxWidth: .infinity)
168
- }
169
- }
170
- .frame(maxWidth: .infinity)
171
- }
172
-
173
- @ViewBuilder
174
- private func column(index: Int, item: StepItem) -> some View {
175
- let status = resolveStatus(
176
- activeIndex: activeIndex,
177
- currentIndex: index,
178
- error: item.error,
179
- disabled: disabled
180
- )
181
- let isActiveOrError = status == .current || status == .error
182
- let titleStyle: TypographyStyle = isActiveOrError
183
- ? .headerXsSemibold : .descriptionDefaultRegular
184
- let descStyle: TypographyStyle = size == .small
185
- ? .descriptionXsRegular : .descriptionDefaultRegular
186
- let titleColor = resolveTitleColor(status, theme: theme)
187
- let subColor = disabled ? theme.colors.text.disable : theme.colors.text.hint
188
-
189
- let colAlignment = horizontalAlignment(for: index)
190
- let textAlignment = textAlign(for: index)
191
-
192
- let hideLineLeft = align == .left || (align == .stretch && index == 0)
193
- let hideLineRight = align == .right || (align == .stretch && index == steps.count - 1)
194
-
195
- let lineLeft: Color = index == 0
196
- ? Color.clear
197
- : (activeIndex >= index ? completedLine : defaultLine)
198
- let lineRight: Color = index == steps.count - 1
199
- ? Color.clear
200
- : (activeIndex > index ? completedLine : defaultLine)
201
-
202
- let clickable = status == .completed && onPress != nil && !disabled
203
-
204
- VStack(alignment: colAlignment, spacing: 0) {
205
- if let time = item.time, !time.isEmpty {
206
- MomoText(time, typography: .descriptionXsRegular, color: subColor)
207
- .multilineTextAlignment(textAlignment)
208
- .frame(maxWidth: .infinity, alignment: frameAlignment(colAlignment))
209
- }
210
-
211
- HStack(spacing: 0) {
212
- if !hideLineLeft {
213
- lineLeft
214
- .frame(height: 2)
215
- .frame(maxWidth: .infinity)
216
- .clipShape(RoundedCorner(radius: Radius.XS, corners: [.topRight, .bottomRight]))
217
- }
218
- StepBubble(
219
- index: index,
220
- isActive: activeIndex == index,
221
- error: item.error,
222
- size: size,
223
- status: status,
224
- useNumber: useNumber,
225
- customIcon: customIcon
226
- )
227
- .padding(.leading, hideLineLeft ? 0 : Spacing.XS)
228
- .padding(.trailing, hideLineRight ? 0 : Spacing.XS)
229
- .padding(.vertical, Spacing.XS)
230
- if !hideLineRight {
231
- lineRight
232
- .frame(height: 2)
233
- .frame(maxWidth: .infinity)
234
- .clipShape(RoundedCorner(radius: Radius.XS, corners: [.topLeft, .bottomLeft]))
235
- }
236
- }
237
- .frame(maxWidth: .infinity)
238
-
239
- if !item.title.isEmpty {
240
- MomoText(item.title, typography: titleStyle, color: titleColor)
241
- .multilineTextAlignment(textAlignment)
242
- .frame(maxWidth: .infinity, alignment: frameAlignment(colAlignment))
243
- .padding(.bottom, Spacing.XXS)
244
- }
245
-
246
- if let desc = item.description, !desc.isEmpty {
247
- MomoText(desc, typography: descStyle, color: subColor)
248
- .multilineTextAlignment(textAlignment)
249
- .frame(maxWidth: .infinity, alignment: frameAlignment(colAlignment))
250
- }
251
- }
252
- .contentShape(Rectangle())
253
- .onTapGesture {
254
- if clickable { onPress?(item, index) }
255
- }
256
- }
257
-
258
- private func horizontalAlignment(for index: Int) -> HorizontalAlignment {
259
- switch align {
260
- case .left: return .leading
261
- case .right: return .trailing
262
- case .center: return .center
263
- case .stretch:
264
- if index == 0 { return .leading }
265
- if index == steps.count - 1 { return .trailing }
266
- return .center
267
- }
268
- }
269
-
270
- private func textAlign(for index: Int) -> TextAlignment {
271
- switch align {
272
- case .left: return .leading
273
- case .right: return .trailing
274
- case .center: return .center
275
- case .stretch:
276
- if index == 0 { return .leading }
277
- if index == steps.count - 1 { return .trailing }
278
- return .center
279
- }
280
- }
281
-
282
- private func frameAlignment(_ h: HorizontalAlignment) -> Alignment {
283
- switch h {
284
- case .leading: return .leading
285
- case .trailing: return .trailing
286
- default: return .center
287
- }
288
- }
289
- }
290
-
291
- // ─── Vertical layout ───────────────────────────────────────────────────────────
292
-
293
- private struct StepsVertical: View {
294
- @Environment(\.appTheme) private var theme
295
-
296
- let steps: [StepItem]
297
- let activeIndex: Int
298
- let size: StepsSize
299
- let useNumber: Bool
300
- let customIcon: String?
301
- let disabled: Bool
302
- let onPress: ((StepItem, Int) -> Void)?
303
-
304
- private var completedLine: Color { theme.colors.primary.opacity(0.2) }
305
- private var defaultLine: Color { theme.colors.background.default }
306
- private var useSmall: Bool { size == .small }
307
- private var connectorHeight: CGFloat { useSmall ? 24 : 32 }
308
-
309
- var body: some View {
310
- VStack(spacing: 0) {
311
- ForEach(Array(steps.enumerated()), id: \.element.id) { index, item in
312
- row(index: index, item: item)
313
- }
314
- }
315
- .frame(maxWidth: .infinity)
316
- }
317
-
318
- @ViewBuilder
319
- private func row(index: Int, item: StepItem) -> some View {
320
- let status = resolveStatus(
321
- activeIndex: activeIndex,
322
- currentIndex: index,
323
- error: item.error,
324
- disabled: disabled
325
- )
326
- let isActiveOrError = status == .current || status == .error
327
- let isLast = index == steps.count - 1
328
-
329
- let titleStyle: TypographyStyle = isActiveOrError
330
- ? (useSmall ? .headerXsSemibold : .headerSSemibold)
331
- : (useSmall ? .descriptionDefaultRegular : .bodyDefaultRegular)
332
- let descStyle: TypographyStyle = useSmall
333
- ? .descriptionXsRegular : .descriptionDefaultRegular
334
-
335
- let titleColor = resolveTitleColor(status, theme: theme)
336
- let subColor = disabled ? theme.colors.text.disable : theme.colors.text.hint
337
- let lineColor = activeIndex > index ? completedLine : defaultLine
338
-
339
- let clickable = status == .completed && onPress != nil && !disabled
340
-
341
- HStack(alignment: .top, spacing: 0) {
342
- VStack(spacing: 0) {
343
- StepBubble(
344
- index: index,
345
- isActive: activeIndex == index,
346
- error: item.error,
347
- size: size,
348
- status: status,
349
- useNumber: useNumber,
350
- customIcon: customIcon
351
- )
352
- if !isLast {
353
- lineColor
354
- .frame(width: 2, height: connectorHeight)
355
- .padding(.vertical, Spacing.XS)
356
- }
357
- }
358
- .padding(.trailing, Spacing.M)
359
-
360
- VStack(alignment: .leading, spacing: 0) {
361
- HStack(alignment: .top, spacing: 0) {
362
- MomoText(item.title, typography: titleStyle, color: titleColor)
363
- .lineLimit(2)
364
- .frame(maxWidth: .infinity, alignment: .leading)
365
- .padding(.trailing, Spacing.S)
366
- if let time = item.time, !time.isEmpty {
367
- MomoText(time, typography: .descriptionXsRegular, color: subColor)
368
- }
369
- }
370
- .frame(maxWidth: .infinity)
371
-
372
- if let desc = item.description, !desc.isEmpty {
373
- MomoText(desc, typography: descStyle, color: subColor)
374
- .frame(maxWidth: .infinity, alignment: .leading)
375
- .padding(.top, Spacing.XXS)
376
- }
377
- }
378
- .frame(maxWidth: .infinity)
379
- .padding(.bottom, isLast ? 0 : Spacing.S)
380
- }
381
- .frame(maxWidth: .infinity)
382
- .contentShape(Rectangle())
383
- .onTapGesture {
384
- if clickable { onPress?(item, index) }
385
- }
386
- }
387
- }
388
-
389
- // ─── Public API ────────────────────────────────────────────────────────────────
390
-
391
- /// Steps — guided progress indicator through a sequence of procedural steps.
392
- ///
393
- /// Mirrors the Compose `Steps` component.
394
- public struct Steps: View {
395
- private let steps: [StepItem]
396
- private let activeIndex: Int
397
- private let horizontal: Bool
398
- private let size: StepsSize
399
- private let useNumber: Bool
400
- private let align: StepsAlign
401
- private let customIcon: String?
402
- private let disabled: Bool
403
- private let onPress: ((StepItem, Int) -> Void)?
404
-
405
- public init(
406
- steps: [StepItem],
407
- activeIndex: Int,
408
- horizontal: Bool = false,
409
- size: StepsSize = .large,
410
- useNumber: Bool = false,
411
- align: StepsAlign = .center,
412
- customIcon: String? = nil,
413
- disabled: Bool = false,
414
- onPress: ((StepItem, Int) -> Void)? = nil
415
- ) {
416
- self.steps = steps
417
- self.activeIndex = activeIndex
418
- self.horizontal = horizontal
419
- self.size = size
420
- self.useNumber = useNumber
421
- self.align = align
422
- self.customIcon = customIcon
423
- self.disabled = disabled
424
- self.onPress = onPress
425
- }
426
-
427
- public var body: some View {
428
- if horizontal {
429
- StepsHorizontal(
430
- steps: steps,
431
- activeIndex: activeIndex,
432
- size: size,
433
- useNumber: useNumber,
434
- align: align,
435
- customIcon: customIcon,
436
- disabled: disabled,
437
- onPress: onPress
438
- )
439
- } else {
440
- StepsVertical(
441
- steps: steps,
442
- activeIndex: activeIndex,
443
- size: size,
444
- useNumber: useNumber,
445
- customIcon: customIcon,
446
- disabled: disabled,
447
- onPress: onPress
448
- )
449
- }
450
- }
451
- }