@momo-kits/native-kits 0.163.1-beta.3-debug → 0.163.1-beta.5-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 (215) hide show
  1. package/CLAUDE.md +1 -1
  2. package/compose/build.gradle.kts +2 -1
  3. package/compose/build.gradle.kts.backup +1 -0
  4. package/compose/compose.podspec +1 -1
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +8 -10
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +3 -0
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +11 -9
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +40 -55
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +69 -26
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -1
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +3 -6
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +28 -21
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +112 -115
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +11 -6
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +3 -4
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +3 -1
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +2 -1
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  24. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  25. package/gradle/libs.versions.toml +2 -0
  26. package/gradle.properties +1 -1
  27. package/ios/Application/ApplicationEnvironment.swift +11 -1
  28. package/ios/Application/Components.swift +34 -44
  29. package/ios/Application/FloatingButton.swift +10 -9
  30. package/ios/Application/HeaderRight.swift +79 -45
  31. package/ios/Application/Navigation/BottomTab/BottomTab.swift +103 -0
  32. package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +215 -0
  33. package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +65 -0
  34. package/ios/Application/Navigation/HeaderBackProps.swift +66 -0
  35. package/ios/Application/Navigation/HeaderTitle.swift +57 -0
  36. package/ios/Application/Navigation/HeaderUser.swift +209 -0
  37. package/ios/Application/Navigation/NavigationContainer.swift +176 -0
  38. package/ios/Application/Navigation/NavigationOptions.swift +109 -0
  39. package/ios/Application/Navigation/Navigator.swift +364 -0
  40. package/ios/Application/Navigation/Overplay/BottomSheet.swift +188 -0
  41. package/ios/Application/Navigation/Overplay/ModalScreen.swift +68 -0
  42. package/ios/Application/Navigation/Overplay/SnackBar.swift +144 -0
  43. package/ios/Application/Navigation/component/Header.swift +178 -0
  44. package/ios/Application/Navigation/component/HeaderBackground.swift +83 -0
  45. package/ios/Application/Navigation/component/HeaderColor.swift +65 -0
  46. package/ios/Application/Screen.swift +2 -1
  47. package/ios/Application/StackScreen.swift +453 -0
  48. package/ios/Avatar/Avatar.swift +193 -0
  49. package/ios/Badge/Badge.swift +11 -14
  50. package/ios/Badge/BadgeRibbon.swift +12 -21
  51. package/ios/BaselineView/BaselineView.swift +163 -0
  52. package/ios/Button/Button.swift +61 -22
  53. package/ios/Carousel/Carousel.swift +181 -0
  54. package/ios/Checkbox/Checkbox.swift +14 -13
  55. package/ios/Chip/Chip.swift +23 -9
  56. package/ios/Collapse/Collapse.swift +182 -0
  57. package/ios/Colors+Radius+Spacing/Colors.swift +12 -12
  58. package/ios/Colors+Radius+Spacing/Theme.swift +295 -0
  59. package/ios/DateTimePicker/DateTimePicker.swift +210 -0
  60. package/ios/DateTimePicker/DateTimePickerTypes.swift +55 -0
  61. package/ios/DateTimePicker/DateTimePickerUtils.swift +167 -0
  62. package/ios/DateTimePicker/WheelPicker.swift +161 -0
  63. package/ios/Divider/Divider.swift +16 -0
  64. package/ios/Extensions/Color++.swift +32 -0
  65. package/ios/Icon/Icon.swift +6 -1
  66. package/ios/IconButton/IconButton.swift +112 -0
  67. package/ios/Input/Input.swift +41 -25
  68. package/ios/Input/InputPhoneNumber.swift +20 -19
  69. package/ios/Input/InputSearch.swift +100 -47
  70. package/ios/Input/InputTextArea.swift +66 -40
  71. package/ios/InputDropDown/InputDropDown.swift +198 -0
  72. package/ios/InputMoney/InputMoney.swift +335 -0
  73. package/ios/InputOTP/InputOTP.swift +210 -0
  74. package/ios/Loader/Loader.swift +113 -0
  75. package/ios/MoMoUIKits.podspec +5 -0
  76. package/ios/Pagination/PaginationDot.swift +61 -0
  77. package/ios/Pagination/PaginationNumber.swift +35 -0
  78. package/ios/Pagination/PaginationScroll.swift +101 -0
  79. package/ios/Pagination/PaginationWhiteDot.swift +37 -0
  80. package/ios/Popup/PopupDisplay.swift +8 -16
  81. package/ios/Popup/PopupInput.swift +2 -8
  82. package/ios/Popup/PopupNotify.swift +219 -0
  83. package/ios/ProgressInfo/ProgressInfo.swift +294 -0
  84. package/ios/Radio/Radio.swift +70 -0
  85. package/ios/Rating/Rating.swift +82 -0
  86. package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +11 -0
  87. package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +38 -0
  88. package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +38 -0
  89. package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +38 -0
  90. package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +6 -0
  91. package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +38 -0
  92. package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +38 -0
  93. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +38 -0
  94. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +38 -0
  95. package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +38 -0
  96. package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +38 -0
  97. package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +38 -0
  98. package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +38 -0
  99. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +9 -0
  100. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +38 -0
  101. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +38 -0
  102. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +38 -0
  103. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +38 -0
  104. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +38 -0
  105. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +38 -0
  106. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +38 -0
  107. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +38 -0
  108. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +38 -0
  109. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +38 -0
  110. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +38 -0
  111. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +38 -0
  112. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +38 -0
  113. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +38 -0
  114. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +38 -0
  115. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +38 -0
  116. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +38 -0
  117. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +38 -0
  118. package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +38 -0
  119. package/ios/Skeleton/Skeleton.swift +99 -0
  120. package/ios/Slider/Slider.swift +237 -0
  121. package/ios/Stepper/Stepper.swift +220 -0
  122. package/ios/Steps/Steps.swift +451 -0
  123. package/ios/SuggestAction/SuggestAction.swift +97 -0
  124. package/ios/Swipeable/SwipeCell.swift +185 -0
  125. package/ios/Swipeable/SwipeCellModel.swift +21 -0
  126. package/ios/TabView/TabView.swift +530 -0
  127. package/ios/Tag/Tag.swift +98 -0
  128. package/ios/Title/Title.swift +269 -0
  129. package/ios/Tooltip/Tooltip.swift +482 -0
  130. package/ios/Typography/FontScaleStore.swift +19 -0
  131. package/ios/Typography/Text.swift +86 -17
  132. package/ios/Typography/Typography.swift +12 -14
  133. package/ios/Uploader/Uploader.swift +183 -0
  134. package/ios/native-kits.podspec +61 -8
  135. package/ios-demo/MoMoUIKitsDemo.podspec +20 -0
  136. package/ios-demo/README.md +120 -0
  137. package/ios-demo/Resources/dot_loading.json +558 -0
  138. package/ios-demo/Resources/icon.json +4052 -0
  139. package/ios-demo/Resources/lottie_circle_loader.json +1 -0
  140. package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +48 -0
  141. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +25 -0
  142. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +26 -0
  143. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +19 -0
  144. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +33 -0
  145. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +48 -0
  146. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +21 -0
  147. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +17 -0
  148. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +28 -0
  149. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +31 -0
  150. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +24 -0
  151. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +110 -0
  152. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +93 -0
  153. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +269 -0
  154. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +117 -0
  155. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +89 -0
  156. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +100 -0
  157. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +126 -0
  158. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +63 -0
  159. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +20 -0
  160. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +93 -0
  161. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +107 -0
  162. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +124 -0
  163. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +14 -0
  164. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +49 -0
  165. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +278 -0
  166. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +58 -0
  167. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +78 -0
  168. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +138 -0
  169. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +111 -0
  170. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +136 -0
  171. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +107 -0
  172. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +73 -0
  173. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +100 -0
  174. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +32 -0
  175. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +57 -0
  176. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +70 -0
  177. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +227 -0
  178. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +72 -0
  179. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +175 -0
  180. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +121 -0
  181. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +76 -0
  182. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +89 -0
  183. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +32 -0
  184. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +56 -0
  185. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +32 -0
  186. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +150 -0
  187. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +138 -0
  188. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +103 -0
  189. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +94 -0
  190. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +79 -0
  191. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +152 -0
  192. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +33 -0
  193. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +190 -0
  194. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +34 -0
  195. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +182 -0
  196. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +109 -0
  197. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +187 -0
  198. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +87 -0
  199. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +131 -0
  200. package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +51 -0
  201. package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +15 -0
  202. package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +73 -0
  203. package/package.json +1 -1
  204. package/publish.sh +50 -0
  205. package/scripts/gen-ios-color.mjs +136 -0
  206. package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  207. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  208. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
  209. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
  210. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
  211. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
  212. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
  213. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
  214. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
  215. package/ios/Application/FontScaleStore.swift +0 -59
@@ -0,0 +1,220 @@
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
+ }
@@ -0,0 +1,451 @@
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
+ }