@momo-kits/native-kits 0.162.2-beta.26 → 0.162.2-beta.27

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 (180) hide show
  1. package/CLAUDE.md +1 -1
  2. package/ios/Application/ApplicationEnvironment.swift +0 -11
  3. package/ios/Application/Components.swift +44 -34
  4. package/ios/Application/FloatingButton.swift +9 -10
  5. package/ios/Application/HeaderRight.swift +45 -79
  6. package/ios/Application/Screen.swift +1 -2
  7. package/ios/Badge/Badge.swift +14 -11
  8. package/ios/Badge/BadgeRibbon.swift +21 -12
  9. package/ios/Button/Button.swift +22 -61
  10. package/ios/Checkbox/Checkbox.swift +13 -14
  11. package/ios/Chip/Chip.swift +9 -23
  12. package/ios/Colors+Radius+Spacing/Colors.swift +12 -12
  13. package/ios/Extensions/Color++.swift +0 -32
  14. package/ios/Icon/Icon.swift +1 -6
  15. package/ios/Input/Input.swift +25 -41
  16. package/ios/Input/InputPhoneNumber.swift +19 -20
  17. package/ios/Input/InputSearch.swift +47 -100
  18. package/ios/Input/InputTextArea.swift +40 -66
  19. package/ios/Popup/PopupDisplay.swift +16 -8
  20. package/ios/Popup/PopupInput.swift +8 -2
  21. package/ios/Swipeable/SwipeCell.swift +0 -185
  22. package/ios/Swipeable/SwipeCellModel.swift +0 -21
  23. package/ios/Typography/Text.swift +5 -79
  24. package/ios/Typography/Typography.swift +0 -3
  25. package/ios/native-kits.podspec +8 -61
  26. package/package.json +1 -1
  27. package/publish.sh +0 -50
  28. package/.claude/settings.local.json +0 -39
  29. package/ios/Application/Navigation/BottomTab/BottomTab.swift +0 -103
  30. package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +0 -215
  31. package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +0 -65
  32. package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
  33. package/ios/Application/Navigation/HeaderTitle.swift +0 -57
  34. package/ios/Application/Navigation/HeaderUser.swift +0 -209
  35. package/ios/Application/Navigation/NavigationContainer.swift +0 -176
  36. package/ios/Application/Navigation/NavigationOptions.swift +0 -109
  37. package/ios/Application/Navigation/Navigator.swift +0 -364
  38. package/ios/Application/Navigation/Overplay/BottomSheet.swift +0 -188
  39. package/ios/Application/Navigation/Overplay/ModalScreen.swift +0 -68
  40. package/ios/Application/Navigation/Overplay/SnackBar.swift +0 -144
  41. package/ios/Application/Navigation/component/Header.swift +0 -178
  42. package/ios/Application/Navigation/component/HeaderBackground.swift +0 -83
  43. package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
  44. package/ios/Application/StackScreen.swift +0 -453
  45. package/ios/Avatar/Avatar.swift +0 -193
  46. package/ios/BaselineView/BaselineView.swift +0 -163
  47. package/ios/Carousel/Carousel.swift +0 -181
  48. package/ios/Collapse/Collapse.swift +0 -182
  49. package/ios/Colors+Radius+Spacing/Theme.swift +0 -295
  50. package/ios/DateTimePicker/DateTimePicker.swift +0 -210
  51. package/ios/DateTimePicker/DateTimePickerTypes.swift +0 -55
  52. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -167
  53. package/ios/DateTimePicker/WheelPicker.swift +0 -161
  54. package/ios/Divider/Divider.swift +0 -16
  55. package/ios/IconButton/IconButton.swift +0 -112
  56. package/ios/InputDropDown/InputDropDown.swift +0 -198
  57. package/ios/InputMoney/InputMoney.swift +0 -335
  58. package/ios/InputOTP/InputOTP.swift +0 -210
  59. package/ios/Loader/Loader.swift +0 -113
  60. package/ios/MoMoUIKits.podspec +0 -5
  61. package/ios/Pagination/PaginationDot.swift +0 -61
  62. package/ios/Pagination/PaginationNumber.swift +0 -35
  63. package/ios/Pagination/PaginationScroll.swift +0 -101
  64. package/ios/Pagination/PaginationWhiteDot.swift +0 -37
  65. package/ios/Popup/PopupNotify.swift +0 -219
  66. package/ios/ProgressInfo/ProgressInfo.swift +0 -294
  67. package/ios/Radio/Radio.swift +0 -70
  68. package/ios/Rating/Rating.swift +0 -82
  69. package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +0 -11
  70. package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +0 -38
  71. package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +0 -38
  72. package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +0 -38
  73. package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +0 -6
  74. package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +0 -38
  75. package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +0 -38
  76. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +0 -38
  77. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +0 -38
  78. package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +0 -38
  79. package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +0 -38
  80. package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +0 -38
  81. package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +0 -38
  82. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +0 -9
  83. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +0 -38
  84. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +0 -38
  85. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +0 -38
  86. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +0 -38
  87. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +0 -38
  88. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +0 -38
  89. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +0 -38
  90. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +0 -38
  91. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +0 -38
  92. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +0 -38
  93. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +0 -38
  94. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +0 -38
  95. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +0 -38
  96. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +0 -38
  97. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +0 -38
  98. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +0 -38
  99. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +0 -38
  100. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +0 -38
  101. package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +0 -38
  102. package/ios/Skeleton/Skeleton.swift +0 -99
  103. package/ios/Slider/Slider.swift +0 -237
  104. package/ios/Stepper/Stepper.swift +0 -220
  105. package/ios/Steps/Steps.swift +0 -451
  106. package/ios/SuggestAction/SuggestAction.swift +0 -97
  107. package/ios/TabView/TabView.swift +0 -530
  108. package/ios/Tag/Tag.swift +0 -98
  109. package/ios/Title/Title.swift +0 -269
  110. package/ios/Tooltip/Tooltip.swift +0 -482
  111. package/ios/Typography/FontScaleStore.swift +0 -19
  112. package/ios/Uploader/Uploader.swift +0 -183
  113. package/ios-demo/MoMoUIKitsDemo.podspec +0 -20
  114. package/ios-demo/Resources/dot_loading.json +0 -558
  115. package/ios-demo/Resources/icon.json +0 -4052
  116. package/ios-demo/Resources/lottie_circle_loader.json +0 -1
  117. package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +0 -48
  118. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +0 -25
  119. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +0 -26
  120. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +0 -19
  121. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +0 -33
  122. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +0 -48
  123. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +0 -21
  124. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +0 -17
  125. package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +0 -28
  126. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +0 -31
  127. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +0 -24
  128. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +0 -110
  129. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +0 -93
  130. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +0 -269
  131. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +0 -117
  132. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +0 -89
  133. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +0 -100
  134. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +0 -126
  135. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +0 -63
  136. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +0 -20
  137. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +0 -93
  138. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +0 -107
  139. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +0 -124
  140. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +0 -14
  141. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +0 -49
  142. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -278
  143. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +0 -58
  144. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +0 -78
  145. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +0 -138
  146. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +0 -111
  147. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +0 -136
  148. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +0 -107
  149. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +0 -73
  150. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +0 -100
  151. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +0 -32
  152. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +0 -57
  153. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +0 -70
  154. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -227
  155. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +0 -72
  156. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +0 -175
  157. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +0 -121
  158. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +0 -76
  159. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +0 -89
  160. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +0 -32
  161. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +0 -56
  162. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +0 -32
  163. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +0 -150
  164. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +0 -138
  165. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +0 -103
  166. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +0 -94
  167. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +0 -79
  168. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +0 -152
  169. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +0 -33
  170. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +0 -190
  171. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +0 -34
  172. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +0 -182
  173. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +0 -109
  174. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +0 -187
  175. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +0 -87
  176. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +0 -131
  177. package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +0 -51
  178. package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +0 -15
  179. package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +0 -73
  180. package/scripts/gen-ios-color.mjs +0 -136
@@ -1,182 +0,0 @@
1
- import SwiftUI
2
-
3
- public enum CollapseTitleSize {
4
- case small
5
- case medium
6
- case large
7
-
8
- var typography: TypographyStyle {
9
- switch self {
10
- case .small: return .headerSSemibold
11
- case .medium: return .headerDefaultBold
12
- case .large: return .headerMBold
13
- }
14
- }
15
- }
16
-
17
- public struct Collapse<Content: View>: View {
18
- @Environment(\.appTheme) private var theme
19
-
20
- private let title: String
21
- private let description: String?
22
- private let image: String?
23
- private let imageSize: CGFloat
24
- private let subTitle: String?
25
- private let tagLabel: String?
26
- private let tagColor: Tag.TagColor
27
- private let showBorder: Bool
28
- private let expandDefault: Bool
29
- private let titleSize: CollapseTitleSize
30
- private let useBackgroundCollapseButton: Bool
31
- private let backgroundColor: Color?
32
- private let titleColor: Color?
33
- private let onPress: ((Bool) -> Void)?
34
- private let content: (() -> Content)?
35
-
36
- @State private var expanded: Bool
37
-
38
- public init(
39
- title: String,
40
- description: String? = nil,
41
- image: String? = nil,
42
- imageSize: CGFloat = 24,
43
- subTitle: String? = nil,
44
- tagLabel: String? = nil,
45
- tagColor: Tag.TagColor = .default,
46
- showBorder: Bool = false,
47
- expandDefault: Bool = false,
48
- titleSize: CollapseTitleSize = .medium,
49
- useBackgroundCollapseButton: Bool = false,
50
- backgroundColor: Color? = nil,
51
- titleColor: Color? = nil,
52
- onPress: ((Bool) -> Void)? = nil,
53
- @ViewBuilder content: @escaping () -> Content
54
- ) {
55
- self.title = title
56
- self.description = description
57
- self.image = image
58
- self.imageSize = imageSize
59
- self.subTitle = subTitle
60
- self.tagLabel = tagLabel
61
- self.tagColor = tagColor
62
- self.showBorder = showBorder
63
- self.expandDefault = expandDefault
64
- self.titleSize = titleSize
65
- self.useBackgroundCollapseButton = useBackgroundCollapseButton
66
- self.backgroundColor = backgroundColor
67
- self.titleColor = titleColor
68
- self.onPress = onPress
69
- self.content = content
70
- _expanded = State(initialValue: expandDefault)
71
- }
72
-
73
- private var resolvedBackgroundColor: Color {
74
- backgroundColor ?? theme.colors.background.surface
75
- }
76
-
77
- public var body: some View {
78
- VStack(spacing: 0) {
79
- header
80
-
81
- if let content {
82
- if expanded {
83
- VStack(spacing: 0) {
84
- content()
85
- }
86
- .frame(maxWidth: .infinity)
87
- .overlay(
88
- showBorder
89
- ? RoundedRectangle(cornerRadius: 0)
90
- .stroke(theme.colors.border.default, lineWidth: 1)
91
- : nil
92
- )
93
- .transition(.move(edge: .top).combined(with: .opacity))
94
- }
95
- }
96
- }
97
- .frame(maxWidth: .infinity)
98
- .background(resolvedBackgroundColor)
99
- .clipShape(RoundedRectangle(cornerRadius: Radius.S, style: .continuous))
100
- .overlay(
101
- showBorder
102
- ? RoundedRectangle(cornerRadius: Radius.S, style: .continuous)
103
- .stroke(theme.colors.border.default, lineWidth: 1)
104
- : nil
105
- )
106
- }
107
-
108
- private var header: some View {
109
- SwiftUI.Button(action: {
110
- onPress?(expanded)
111
- withAnimation(.easeInOut(duration: 0.3)) {
112
- expanded.toggle()
113
- }
114
- }) {
115
- HStack(alignment: .top, spacing: 0) {
116
- if let image {
117
- ImageView(image, contentMode: .fill)
118
- .frame(width: imageSize, height: imageSize)
119
- .clipShape(RoundedRectangle(cornerRadius: Radius.XS, style: .continuous))
120
- Spacer().frame(width: Spacing.S)
121
- }
122
-
123
- VStack(alignment: .leading, spacing: 0) {
124
- MomoText(
125
- title,
126
- typography: titleSize.typography,
127
- color: titleColor ?? theme.colors.text.default
128
- )
129
- if let description {
130
- MomoText(
131
- description,
132
- typography: .bodyDefaultRegular,
133
- color: theme.colors.text.secondary
134
- )
135
- .lineLimit(2)
136
- }
137
- }
138
- .frame(maxWidth: .infinity, alignment: .leading)
139
-
140
- if subTitle != nil || tagLabel != nil {
141
- Spacer().frame(width: Spacing.S)
142
- if let subTitle {
143
- MomoText(
144
- subTitle,
145
- typography: .bodyDefaultRegular,
146
- color: theme.colors.text.secondary
147
- )
148
- .lineLimit(1)
149
- } else if let tagLabel {
150
- Tag(label: tagLabel, color: tagColor)
151
- }
152
- }
153
-
154
- Spacer().frame(width: Spacing.S)
155
- chevron
156
- }
157
- .padding(.horizontal, Spacing.M)
158
- .padding(.vertical, Spacing.S)
159
- .frame(maxWidth: .infinity)
160
- .contentShape(Rectangle())
161
- }
162
- .buttonStyle(.plain)
163
- }
164
-
165
- private var chevron: some View {
166
- Group {
167
- if useBackgroundCollapseButton {
168
- Icon(source: "arrow_chevron_down_small", size: 16, color: theme.colors.primary)
169
- .rotationEffect(.degrees(expanded ? 180 : 0))
170
- .frame(width: 24, height: 24)
171
- .background(
172
- RoundedRectangle(cornerRadius: Radius.M, style: .continuous)
173
- .fill(theme.colors.background.tonal)
174
- )
175
- } else {
176
- Icon(source: "arrow_chevron_down_small", size: 24, color: theme.colors.text.default)
177
- .rotationEffect(.degrees(expanded ? 180 : 0))
178
- }
179
- }
180
- .animation(.easeInOut(duration: 0.3), value: expanded)
181
- }
182
- }
@@ -1,295 +0,0 @@
1
- //
2
- // Theme.swift
3
- // MoMoUIKits
4
- //
5
- // Created by sophia on 25/2/26.
6
- //
7
-
8
- import Foundation
9
- import SwiftUI
10
-
11
- // MARK: - Background
12
-
13
- public struct Background {
14
- public let `default`: Color
15
- public let surface: Color
16
- public let tonal: Color
17
- public let pressed: Color
18
- public let selected: Color
19
- public let disable: Color
20
-
21
- public init(
22
- default defaultColor: Color,
23
- surface: Color,
24
- tonal: Color,
25
- pressed: Color,
26
- selected: Color,
27
- disable: Color
28
- ) {
29
- self.default = defaultColor
30
- self.surface = surface
31
- self.tonal = tonal
32
- self.pressed = pressed
33
- self.selected = selected
34
- self.disable = disable
35
- }
36
- }
37
-
38
- // MARK: - TextColors
39
-
40
- public struct TextColors {
41
- public let `default`: Color
42
- public let secondary: Color
43
- public let hint: Color
44
- public let disable: Color
45
-
46
- public init(
47
- default defaultColor: Color,
48
- secondary: Color,
49
- hint: Color,
50
- disable: Color
51
- ) {
52
- self.default = defaultColor
53
- self.secondary = secondary
54
- self.hint = hint
55
- self.disable = disable
56
- }
57
- }
58
-
59
- // MARK: - BorderColors
60
-
61
- public struct BorderColors {
62
- public let `default`: Color
63
- public let disable: Color
64
-
65
- public init(default defaultColor: Color, disable: Color) {
66
- self.default = defaultColor
67
- self.disable = disable
68
- }
69
- }
70
-
71
- // MARK: - ColorSet
72
-
73
- public struct ColorSet {
74
- public let primary: Color
75
- public let secondary: Color
76
- public let container: Color
77
-
78
- public init(primary: Color, secondary: Color, container: Color) {
79
- self.primary = primary
80
- self.secondary = secondary
81
- self.container = container
82
- }
83
- }
84
-
85
- // MARK: - ColorScheme
86
-
87
- public struct ColorScheme {
88
- public let primary: Color
89
- public let secondary: Color
90
- public let gradient: Color
91
- public let background: Background
92
- public let text: TextColors
93
- public let border: BorderColors
94
- public let success: ColorSet
95
- public let warning: ColorSet
96
- public let error: ColorSet
97
- public let highlight: ColorSet
98
- public let interactive: ColorSet
99
-
100
- public init(
101
- primary: Color,
102
- secondary: Color,
103
- gradient: Color,
104
- background: Background,
105
- text: TextColors,
106
- border: BorderColors,
107
- success: ColorSet,
108
- warning: ColorSet,
109
- error: ColorSet,
110
- highlight: ColorSet,
111
- interactive: ColorSet
112
- ) {
113
- self.primary = primary
114
- self.secondary = secondary
115
- self.gradient = gradient
116
- self.background = background
117
- self.text = text
118
- self.border = border
119
- self.success = success
120
- self.warning = warning
121
- self.error = error
122
- self.highlight = highlight
123
- self.interactive = interactive
124
- }
125
- }
126
-
127
- // MARK: - ThemeAssets
128
-
129
- public struct ThemeAssets {
130
- public let headerBackground: String?
131
-
132
- public init(headerBackground: String? = nil) {
133
- self.headerBackground = headerBackground
134
- }
135
-
136
- public var isHeaderImage: Bool {
137
- guard let url = headerBackground else { return false }
138
- return !url.isEmpty
139
- }
140
- }
141
-
142
- // MARK: - Theme
143
-
144
- public struct Theme {
145
- public let dark: Bool
146
- public let colors: ColorScheme
147
- public let font: String
148
- public let assets: ThemeAssets
149
-
150
- public init(dark: Bool, colors: ColorScheme, font: String, assets: ThemeAssets) {
151
- self.dark = dark
152
- self.colors = colors
153
- self.font = font
154
- self.assets = assets
155
- }
156
-
157
- public func copy(
158
- dark: Bool? = nil,
159
- colors: ColorScheme? = nil,
160
- font: String? = nil,
161
- assets: ThemeAssets? = nil
162
- ) -> Theme {
163
- Theme(
164
- dark: dark ?? self.dark,
165
- colors: colors ?? self.colors,
166
- font: font ?? self.font,
167
- assets: assets ?? self.assets
168
- )
169
- }
170
- }
171
-
172
- // MARK: - Default Theme (Light)
173
-
174
- public let defaultTheme = Theme(
175
- dark: false,
176
- colors: ColorScheme(
177
- primary: Color.momoAsset("ThemeColors/primary"),
178
- secondary: Color.momoAsset("ThemeColors/secondary"),
179
- gradient: Color.momoAsset("ThemeColors/gradient"),
180
- background: Background(
181
- default: Color.momoAsset("ThemeColors/background-default"),
182
- surface: Color.momoAsset("ThemeColors/background-surface"),
183
- tonal: Color.momoAsset("ThemeColors/background-tonal"),
184
- pressed: Color.momoAsset("ThemeColors/background-pressed"),
185
- selected: Color.momoAsset("ThemeColors/background-selected"),
186
- disable: Color.momoAsset("ThemeColors/background-disable")
187
- ),
188
- text: TextColors(
189
- default: Color.momoAsset("ThemeColors/text-default"),
190
- secondary: Color.momoAsset("ThemeColors/text-secondary"),
191
- hint: Color.momoAsset("ThemeColors/text-hint"),
192
- disable: Color.momoAsset("ThemeColors/text-disable")
193
- ),
194
- border: BorderColors(
195
- default: Color.momoAsset("ThemeColors/border-default"),
196
- disable: Color.momoAsset("ThemeColors/border-disable")
197
- ),
198
- success: ColorSet(
199
- primary: Colors.green03,
200
- secondary: Colors.green07,
201
- container: Colors.green08
202
- ),
203
- warning: ColorSet(
204
- primary: Colors.orange03,
205
- secondary: Colors.orange07,
206
- container: Colors.orange08
207
- ),
208
- error: ColorSet(
209
- primary: Colors.red03,
210
- secondary: Colors.red07,
211
- container: Colors.red08
212
- ),
213
- highlight: ColorSet(
214
- primary: Colors.mint03,
215
- secondary: Colors.mint07,
216
- container: Colors.mint08
217
- ),
218
- interactive: ColorSet(
219
- primary: Colors.blue03,
220
- secondary: Colors.blue07,
221
- container: Colors.blue08
222
- )
223
- ),
224
- font: "SFProText",
225
- assets: ThemeAssets(headerBackground: nil)
226
- )
227
-
228
- // MARK: - Dark Theme
229
-
230
- public let darkTheme = Theme(
231
- dark: true,
232
- colors: ColorScheme(
233
- primary: Colors.pink04,
234
- secondary: Colors.pink08,
235
- gradient: Color(hex: "FDCADE"),
236
- background: Background(
237
- default: Color(hex: "121212"),
238
- surface: Color(hex: "1E1E1E"),
239
- tonal: Colors.pink10,
240
- pressed: Color(hex: "1A1A1A"),
241
- selected: Colors.pink11,
242
- disable: Color(hex: "303030")
243
- ),
244
- text: TextColors(
245
- default: Color.white,
246
- secondary: Color(hex: "B0B0B0"),
247
- hint: Color(hex: "727272"),
248
- disable: Color(hex: "505050")
249
- ),
250
- border: BorderColors(
251
- default: Color(hex: "2A2A2A"),
252
- disable: Color(hex: "242424")
253
- ),
254
- success: ColorSet(
255
- primary: Colors.green03,
256
- secondary: Colors.green07,
257
- container: Colors.green08
258
- ),
259
- warning: ColorSet(
260
- primary: Colors.orange03,
261
- secondary: Colors.orange07,
262
- container: Colors.orange08
263
- ),
264
- error: ColorSet(
265
- primary: Colors.red03,
266
- secondary: Colors.red07,
267
- container: Colors.red08
268
- ),
269
- highlight: ColorSet(
270
- primary: Colors.mint03,
271
- secondary: Colors.mint07,
272
- container: Colors.mint08
273
- ),
274
- interactive: ColorSet(
275
- primary: Colors.blue03,
276
- secondary: Colors.blue07,
277
- container: Colors.blue08
278
- )
279
- ),
280
- font: "SFProText",
281
- assets: ThemeAssets(headerBackground: nil)
282
- )
283
-
284
- // MARK: - AppTheme Environment Key
285
-
286
- private struct AppThemeKey: EnvironmentKey {
287
- static let defaultValue: Theme = defaultTheme
288
- }
289
-
290
- public extension EnvironmentValues {
291
- var appTheme: Theme {
292
- get { self[AppThemeKey.self] }
293
- set { self[AppThemeKey.self] = newValue }
294
- }
295
- }
@@ -1,210 +0,0 @@
1
- import SwiftUI
2
-
3
- // MARK: - Constants
4
-
5
- private let datePickerHeight: CGFloat = 210
6
- private let datePickerWithLabelsHeight: CGFloat = 238
7
-
8
- // MARK: - DateTimePicker
9
-
10
- /// A wheel-style date/time picker matching Compose `DateTimePicker`.
11
- ///
12
- /// The `format` string drives which columns are shown:
13
- /// - `DD` day, `MM` month, `YYYY` year, `HH` hour, `mm` minute.
14
- /// - `"HH:mm"` shows hour + minute; a lone `"HH"` switches the hour wheel to a
15
- /// 12-hour clock with an AM/PM column.
16
- public struct DateTimePicker: View {
17
- // MARK: Lifecycle
18
-
19
- public init(
20
- format: String = "DD-MM-YYYY",
21
- minuteInterval: Int = 1,
22
- selectedValue: Date? = nil,
23
- minDate: Date? = nil,
24
- maxDate: Date? = nil,
25
- arrayLabelTime: [String] = [],
26
- onChange: @escaping (Date) -> Void
27
- ) {
28
- self.format = format
29
- self.minuteInterval = minuteInterval
30
- self.selectedValue = selectedValue
31
- self.minDate = minDate
32
- self.maxDate = maxDate
33
- self.arrayLabelTime = arrayLabelTime
34
- self.onChange = onChange
35
-
36
- let calendar = Calendar.current
37
- let effectiveSelected = selectedValue ?? DateTimePickerUtils.getCurrentDateTime()
38
- let effectiveMin = minDate ?? DateTimePickerUtils.createRelativeDate(years: -10)
39
- let effectiveMax = maxDate ?? DateTimePickerUtils.createRelativeDate(years: 10)
40
-
41
- // needCheckRange is true only when the caller supplied no bounds.
42
- let needCheckRange = (minDate == nil && maxDate == nil)
43
-
44
- let initialValue: Date
45
- if !needCheckRange {
46
- initialValue = effectiveSelected
47
- } else if effectiveSelected < effectiveMin {
48
- initialValue = effectiveMin
49
- } else if effectiveSelected > effectiveMax {
50
- initialValue = effectiveMax
51
- } else {
52
- initialValue = effectiveSelected
53
- }
54
-
55
- let comps = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: initialValue)
56
- self._currentData = State(initialValue: DateTimePickerData(
57
- day: comps.day ?? 1,
58
- month: comps.month ?? 1,
59
- year: comps.year ?? 2000,
60
- hour: comps.hour ?? 0,
61
- minute: comps.minute ?? 0
62
- ))
63
-
64
- self.effectiveMinComponents = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: effectiveMin)
65
- self.effectiveMaxComponents = calendar.dateComponents([.year, .month, .day, .hour, .minute], from: effectiveMax)
66
- self.needCheckRange = needCheckRange
67
- }
68
-
69
- // MARK: Public
70
-
71
- public var body: some View {
72
- let components = DateTimePickerUtils.getDateComponents(
73
- format: format,
74
- currentData: currentData,
75
- minDate: effectiveMinComponents,
76
- maxDate: effectiveMaxComponents,
77
- minuteInterval: minuteInterval
78
- )
79
- let pickerHeight = arrayLabelTime.isEmpty ? datePickerHeight : datePickerWithLabelsHeight
80
-
81
- return HStack(spacing: Spacing.M) {
82
- ForEach(Array(components.enumerated()), id: \.offset) { index, component in
83
- let hasLabel = index < arrayLabelTime.count && !arrayLabelTime[index].isEmpty
84
-
85
- VStack(spacing: 0) {
86
- if hasLabel {
87
- MomoText(arrayLabelTime[index], typography: .actionSBold, color: Colors.text)
88
- .padding(.bottom, Spacing.S)
89
- }
90
-
91
- WheelPicker(
92
- name: component.name,
93
- data: component.data,
94
- selectedData: selectedDataFor(component.name),
95
- onChange: onWheelChange
96
- )
97
- }
98
- .frame(maxWidth: .infinity)
99
- }
100
- }
101
- .frame(maxWidth: .infinity)
102
- .frame(height: pickerHeight)
103
- .background(Colors.background)
104
- .padding(.horizontal, Spacing.M)
105
- .onAppear { emitIfValid() }
106
- }
107
-
108
- // MARK: Internal
109
-
110
- let format: String
111
- let minuteInterval: Int
112
- let selectedValue: Date?
113
- let minDate: Date?
114
- let maxDate: Date?
115
- let arrayLabelTime: [String]
116
- let onChange: (Date) -> Void
117
-
118
- @State private var currentData: DateTimePickerData
119
-
120
- private let effectiveMinComponents: DateComponents
121
- private let effectiveMaxComponents: DateComponents
122
- private let needCheckRange: Bool
123
-
124
- private func selectedDataFor(_ name: String) -> String {
125
- switch name {
126
- case "day": return DateTimePickerUtils.paddingNum(currentData.day)
127
- case "month": return DateTimePickerUtils.paddingNum(currentData.month)
128
- case "year": return String(currentData.year)
129
- case "hour": return DateTimePickerUtils.paddingNum(currentData.hour)
130
- case "minute": return DateTimePickerUtils.paddingNum(currentData.minute)
131
- case "timeMode": return currentData.timeMode
132
- default: return ""
133
- }
134
- }
135
-
136
- /// Mirrors Compose `onWheelChangeValue`: applies value and coerces day/month
137
- /// to stay within the effective min/max bounds.
138
- private func onWheelChange(_ name: String, _ value: String) {
139
- var day = name == "day" ? (Int(value) ?? currentData.day) : currentData.day
140
- var month = name == "month" ? (Int(value) ?? currentData.month) : currentData.month
141
- let year = name == "year" ? (Int(value) ?? currentData.year) : currentData.year
142
- let hour = name == "hour" ? (Int(value) ?? currentData.hour) : currentData.hour
143
- let minute = name == "minute" ? (Int(value) ?? currentData.minute) : currentData.minute
144
- let timeMode = name == "timeMode" ? value : currentData.timeMode
145
-
146
- let maxYear = effectiveMaxComponents.year ?? year
147
- let minYear = effectiveMinComponents.year ?? year
148
- let maxMonth = effectiveMaxComponents.month ?? 12
149
- let minMonth = effectiveMinComponents.month ?? 1
150
- let maxDayBound = effectiveMaxComponents.day ?? 31
151
- let minDayBound = effectiveMinComponents.day ?? 1
152
-
153
- if name == "year" {
154
- if year == maxYear {
155
- month = min(max(month, 1), maxMonth)
156
- } else if year == minYear {
157
- month = min(max(month, minMonth), 12)
158
- }
159
- }
160
-
161
- if name == "month" || name == "year" {
162
- let maxDayOfMonth: Int
163
- switch month {
164
- case 4, 6, 9, 11: maxDayOfMonth = 30
165
- case 2: maxDayOfMonth = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28
166
- default: maxDayOfMonth = 31
167
- }
168
-
169
- if year == maxYear && month == maxMonth {
170
- day = min(max(day, 1), maxDayBound)
171
- } else if year == minYear && month == minMonth {
172
- day = min(max(day, minDayBound), maxDayOfMonth)
173
- } else if day > maxDayOfMonth {
174
- day = maxDayOfMonth
175
- }
176
- }
177
-
178
- currentData = DateTimePickerData(
179
- day: day,
180
- month: month,
181
- year: year,
182
- hour: hour,
183
- minute: minute,
184
- timeMode: timeMode
185
- )
186
- emitIfValid()
187
- }
188
-
189
- /// Emit `onChange` only when the assembled date is valid and (when bounds were
190
- /// not supplied) within the effective min/max range. Mirrors the Compose
191
- /// `snapshotFlow.mapNotNull` filter.
192
- private func emitIfValid() {
193
- guard let date = currentData.toDate() else { return }
194
- if !needCheckRange {
195
- onChange(date)
196
- return
197
- }
198
- let calendar = Calendar.current
199
- guard
200
- let minDate = calendar.date(from: effectiveMinComponents),
201
- let maxDate = calendar.date(from: effectiveMaxComponents)
202
- else {
203
- onChange(date)
204
- return
205
- }
206
- if date >= minDate && date <= maxDate {
207
- onChange(date)
208
- }
209
- }
210
- }