@momo-kits/native-kits 0.152.1-beta.2 → 0.152.2-beta.121

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 (154) hide show
  1. package/package.json +7 -6
  2. package/shared/build.gradle.kts +74 -0
  3. package/CODE_OF_CONDUCT.md +0 -133
  4. package/CONTRIBUTING.md +0 -114
  5. package/LICENSE +0 -20
  6. package/README.md +0 -7
  7. package/build.gradle.kts +0 -32
  8. package/compose/MoMoComposeKits.podspec +0 -54
  9. package/compose/build.gradle.kts +0 -149
  10. package/compose/src/androidMain/AndroidManifest.xml +0 -2
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -105
  12. package/compose/src/commonMain/composeResources/files/lottie_circle_loader.json +0 -1
  13. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  14. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  22. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  23. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  24. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  25. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  26. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -306
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -715
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -214
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -235
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -77
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -27
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -334
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -345
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -90
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -131
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -58
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -143
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -179
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -111
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -384
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -160
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -234
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -223
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -232
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -236
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -228
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -50
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -34
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -85
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -33
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -338
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -95
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -64
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -89
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -84
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -208
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -172
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -199
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -237
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -13
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -189
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -257
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -59
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -49
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -232
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -111
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -94
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -159
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -232
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -459
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -169
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -216
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -180
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -251
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -31
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -385
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -38
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -62
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -88
  109. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -144
  110. package/gradle.properties +0 -19
  111. package/gradlew +0 -240
  112. package/gradlew.bat +0 -91
  113. package/ios/Application/ApplicationEnvironment.swift +0 -50
  114. package/ios/Application/Components.swift +0 -260
  115. package/ios/Application/ComposeApi.swift +0 -22
  116. package/ios/Application/FloatingButton.swift +0 -172
  117. package/ios/Application/HeaderRight.swift +0 -271
  118. package/ios/Application/Screen.swift +0 -242
  119. package/ios/Badge/BadgeDot.swift +0 -31
  120. package/ios/Button/Button.swift +0 -211
  121. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +0 -126
  122. package/ios/Checkbox/Checkbox.swift +0 -81
  123. package/ios/Chip/Chip.swift +0 -96
  124. package/ios/Colors+Radius+Spacing/Colors.swift +0 -172
  125. package/ios/Colors+Radius+Spacing/Radius.swift +0 -22
  126. package/ios/Colors+Radius+Spacing/Spacing.swift +0 -12
  127. package/ios/Extensions/Color++.swift +0 -25
  128. package/ios/Icon/Icon.swift +0 -51
  129. package/ios/Image/Image.swift +0 -70
  130. package/ios/Input/Input.swift +0 -207
  131. package/ios/Input/InputPhoneNumber.swift +0 -176
  132. package/ios/Input/InputSearch.swift +0 -238
  133. package/ios/Input/InputTextArea.swift +0 -242
  134. package/ios/Lottie/LottieView.swift +0 -86
  135. package/ios/OTPKeyboard/KeyboardButton.swift +0 -41
  136. package/ios/OTPKeyboard/OTPKeyboard.swift +0 -145
  137. package/ios/Popup/PopupDisplay.swift +0 -284
  138. package/ios/Popup/PopupInput.swift +0 -96
  139. package/ios/Popup/PopupPromotion.swift +0 -73
  140. package/ios/PopupView/FullscreenPopup.swift +0 -251
  141. package/ios/PopupView/Modifiers.swift +0 -158
  142. package/ios/PopupView/PopupView.swift +0 -289
  143. package/ios/PopupView/Utils++.swift +0 -281
  144. package/ios/ScrollIndicator/ScrollIndicator.swift +0 -110
  145. package/ios/Swipeable/SwipeCell.swift +0 -278
  146. package/ios/Swipeable/SwipeCellModel.swift +0 -86
  147. package/ios/Switch/Switch.swift +0 -44
  148. package/ios/Template/Logo/Logo.swift +0 -75
  149. package/ios/Template/TrustBanner/TrustBanner.swift +0 -120
  150. package/ios/Theme.md +0 -18
  151. package/ios/Typography/Text.swift +0 -140
  152. package/ios/Typography/Typography.swift +0 -95
  153. package/ios/native-kits.podspec +0 -18
  154. package/settings.gradle.kts +0 -25
@@ -1,271 +0,0 @@
1
- import SwiftUI
2
- import Foundation
3
-
4
- public struct HeaderRightData {
5
- var useShortcut: Bool
6
- var useMore: Bool
7
- var tools: [ToolGroup]
8
- var toolCallback: ((String) -> Void)?
9
- var useSystemTools: Bool
10
-
11
- public init(
12
- useShortcut: Bool = false,
13
- useMore: Bool = false,
14
- tools: [ToolGroup] = [],
15
- toolCallback: ((String) -> Void)? = nil,
16
- useSystemTools: Bool = true
17
- ) {
18
- self.useShortcut = useShortcut
19
- self.useMore = useMore
20
- self.tools = tools
21
- self.toolCallback = toolCallback
22
- self.useSystemTools = useSystemTools
23
- }
24
- }
25
-
26
- public struct Tool {
27
- var key: String
28
- var icon: String
29
- var showBadge: Bool
30
- var name: [String: String]
31
- var showRightIcon: Bool
32
-
33
- public init(
34
- key: String,
35
- icon: String,
36
- name: [String: String] = [:],
37
- showBadge: Bool = false,
38
- showRightIcon: Bool = true
39
- ) {
40
- self.key = key
41
- self.icon = icon
42
- self.showBadge = showBadge
43
- self.name = name
44
- self.showRightIcon = showRightIcon
45
- }
46
-
47
- func toMap() -> [String: Any] {
48
- return [
49
- "key": key,
50
- "icon": icon,
51
- "showBadge": showBadge,
52
- "name": name,
53
- "showRightIcon": showRightIcon
54
- ]
55
- }
56
- }
57
-
58
- public struct ToolGroup {
59
- var title: [String: String]
60
- var items: [Tool]
61
-
62
- public init(
63
- title: [String: String] = [:],
64
- items: [Tool]
65
- ) {
66
- self.title = title
67
- self.items = items
68
- }
69
-
70
- func toMap() -> [String: Any] {
71
- return [
72
- "title": title,
73
- "items": items.map { $0.toMap() }
74
- ]
75
- }
76
- }
77
-
78
- struct NavigationButtonConfig {
79
- let icon: String
80
- let onPress: () -> Void
81
- }
82
-
83
- // MARK: - Components
84
- public struct HeaderRight: View {
85
- public init(headerRight: HeaderRightData? = nil, tintColor: Color? = nil) {
86
- self.headerRight = headerRight
87
- self.tintColor = tintColor
88
- }
89
- var headerRight: HeaderRightData?
90
- var tintColor: Color? = nil
91
-
92
- public var body: some View {
93
- HStack(alignment: .center) {
94
- ToolkitHeaderRight(headerRight: headerRight, tintColor: tintColor)
95
- }
96
- }
97
- }
98
-
99
- struct ToolkitHeaderRight: View {
100
- var headerRight: HeaderRightData?
101
- var tintColor: Color?
102
- @State private var isFavorite: Bool = false
103
- @State private var isLoading: Bool = false
104
- @EnvironmentObject private var environment: ApplicationEnvironment
105
-
106
- // MARK: - Actions
107
- private func onPressShortcut() {
108
- environment.composeApi?.request(
109
- funcName: "onToolAction",
110
- params: ["item": ["key": "onFavorite"]]
111
- ) { _ in
112
- isFavorite.toggle()
113
- }
114
- }
115
-
116
- private func onPressHelpCenter() {
117
- let context = environment.applicationContext
118
- let paramMap: [String: Any] = [
119
- "appId": context?.appId,
120
- "code": context?.appCode,
121
- "name": context?.appName,
122
- "icon": context?.appIcon,
123
- "description": context?.description
124
- ]
125
- environment.composeApi?.request(
126
- funcName: "showHelpCenter",
127
- params: paramMap
128
- ) { _ in }
129
- }
130
-
131
- private func onPressClose() {
132
- environment.composeApi?.request(
133
- funcName: "dismissAll",
134
- params: ""
135
- ) { _ in }
136
- }
137
-
138
- private func onPressMore() {
139
- let context = environment.applicationContext
140
- let params: [String: Any] = [
141
- "useSystemTools": headerRight?.useSystemTools,
142
- "tools": headerRight?.tools.map { $0.toMap() } ?? [],
143
- "context": [
144
- "appId": context?.appId,
145
- "code": context?.appCode,
146
- "name": context?.appName,
147
- "icon": context?.appIcon,
148
- "description": context?.description,
149
- "support": context?.support,
150
- "toolkitConfig": context?.toolkitConfig,
151
- "providerId": context?.providerId,
152
- "permissions": context?.permissions
153
- ]
154
- ]
155
- environment.composeApi?.request(
156
- funcName: "showTools",
157
- params: params
158
- ) { response in
159
- do {
160
- if let jsonData = response.data(using: .utf8),
161
- let json = try JSONSerialization.jsonObject(with: jsonData) as? [String: Any],
162
- let toolResponse = json["response"] as? String {
163
- headerRight?.toolCallback?(toolResponse)
164
- }
165
- } catch {
166
- print("Error parsing response:", error)
167
- }
168
- }
169
- }
170
-
171
- private func getNavigationButtonConfig() -> NavigationButtonConfig {
172
- let totalTools = headerRight?.tools.reduce(0) { $0 + $1.items.count } ?? 0
173
- var icon = isFavorite ? "pin_star_checked" : "pin_star"
174
- var onClickHandler: () -> Void = onPressShortcut
175
-
176
- if totalTools > 1 || headerRight?.useMore == true {
177
- icon = "navigation_more_icon"
178
- onClickHandler = onPressMore
179
- } else if totalTools == 1, let singleTool = headerRight?.tools.first?.items.first {
180
- icon = singleTool.icon
181
- onClickHandler = {
182
- headerRight?.toolCallback?(singleTool.key)
183
- }
184
- }
185
-
186
- return NavigationButtonConfig(icon: icon, onPress: onClickHandler)
187
- }
188
-
189
- var body: some View {
190
- let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
191
- let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
192
- let navButtonConfig = getNavigationButtonConfig()
193
- let showBadge = headerRight?.tools.contains { group in
194
- group.items.contains { $0.showBadge }
195
- } ?? false
196
-
197
- HStack(alignment: .center, spacing: 0) {
198
- if headerRight?.useShortcut == true {
199
- NavigationButton(
200
- disabled: isLoading,
201
- icon: navButtonConfig.icon,
202
- showBadge: showBadge,
203
- onClick: navButtonConfig.onPress,
204
- tintColor: tintColor
205
- )
206
- }
207
-
208
- HStack(alignment: .center, spacing: 0) {
209
- Icon(source: "help_center", size: 20, color: tintColor ?? Colors.black17)
210
- .padding(4)
211
- .onTapGesture {
212
- onPressHelpCenter()
213
- }
214
-
215
- Rectangle()
216
- .fill(tintColor ?? Colors.black20)
217
- .frame(width: 0.5, height: 12)
218
-
219
- Icon(source: "16_basic_home", size: 20, color: tintColor ?? Colors.black17)
220
- .padding(4)
221
- .onTapGesture {
222
- onPressClose()
223
- }
224
- }
225
- .frame(width: 65, height: 28)
226
- .background(backgroundButtonColor)
227
- .cornerRadius(14)
228
- .overlay(
229
- RoundedRectangle(cornerRadius: 14)
230
- .stroke(borderColor, lineWidth: 0.2)
231
- )
232
- .padding(.leading, Spacing.S)
233
- }
234
- }
235
- }
236
-
237
- struct NavigationButton: View {
238
- var disabled: Bool
239
- var icon: String
240
- var showBadge: Bool
241
- var onClick: () -> Void
242
- var tintColor: Color?
243
-
244
- var body: some View {
245
- let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
246
- let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
247
-
248
- ZStack {
249
- Circle()
250
- .fill(backgroundButtonColor)
251
- .overlay(
252
- Circle()
253
- .stroke(borderColor, lineWidth: 0.2)
254
- )
255
-
256
- Icon(source: icon, size: 16, color: tintColor)
257
-
258
- if showBadge {
259
- BadgeDot(size: .small)
260
- .offset(x: -2, y: -2)
261
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topTrailing)
262
- }
263
- }
264
- .frame(width: 28, height: 28)
265
- .onTapGesture {
266
- if !disabled {
267
- onClick()
268
- }
269
- }
270
- }
271
- }
@@ -1,242 +0,0 @@
1
- //
2
- // Screen.swift
3
- // Pods
4
- //
5
- // Created by sophia on 5/2/25.
6
- //
7
-
8
- import SwiftUI
9
-
10
- public struct Screen<Content: View>: View {
11
- // MARK: - Properties
12
-
13
- var backgroundColor: Color?
14
- var headerTransparent: Bool = false
15
- var tintColor: Color? = Colors.black17
16
- var isBack: Bool
17
- var headerType: HeaderType
18
- var verticalAlignment: VerticalAlignment
19
- var horizontalAlignment: HorizontalAlignment
20
- var title: String
21
- var titlePosition: TitlePosition
22
- var goBack: (() -> Void)?
23
- var scrollable: Bool
24
- var onContentLayout: ((CGRect) -> Void)?
25
- var useAvoidKeyboard: Bool
26
- var footer: (() -> AnyView)?
27
- var headerRight: (()->any View)? = {HeaderRight()}
28
- var animatedHeader: AnimatedHeader? = nil
29
- var layoutOffset: CGFloat
30
- var inputSearchProps: InputSearchProps?
31
- var fabProps: FabProps?
32
- var content: () -> Content
33
-
34
- public init(
35
- backgroundColor: Color? = nil,
36
- headerTransparent: Bool = false,
37
- tintColor: Color = Colors.black17,
38
- isBack: Bool = true,
39
- headerType: HeaderType = .default,
40
- verticalAlignment: VerticalAlignment = .top,
41
- horizontalAlignment: HorizontalAlignment = .leading,
42
- title: String = "Stack",
43
- titlePosition: TitlePosition = .left,
44
- goBack: (() -> Void)? = nil,
45
- scrollable: Bool = true,
46
- onContentLayout: ((CGRect) -> Void)? = nil,
47
- useAvoidKeyboard: Bool = true,
48
- footer: (() -> AnyView)? = nil,
49
- headerRight: (()->any View)? = {HeaderRight()},
50
- animatedHeader: AnimatedHeader? = nil,
51
- layoutOffset: CGFloat = 56,
52
- inputSearchProps: InputSearchProps? = nil,
53
- fabProps: FabProps? = nil,
54
- @ViewBuilder content: @escaping () -> Content
55
- ) {
56
- self.backgroundColor = backgroundColor
57
- self.headerTransparent = headerTransparent
58
- self.tintColor = tintColor
59
- self.isBack = isBack
60
- self.headerType = headerType
61
- self.verticalAlignment = verticalAlignment
62
- self.horizontalAlignment = horizontalAlignment
63
- self.title = title
64
- self.titlePosition = titlePosition
65
- self.goBack = goBack
66
- self.scrollable = scrollable
67
- self.onContentLayout = onContentLayout
68
- self.useAvoidKeyboard = useAvoidKeyboard
69
- self.footer = footer
70
- self.headerRight = headerRight
71
- self.animatedHeader = animatedHeader
72
- self.layoutOffset = layoutOffset
73
- self.inputSearchProps = inputSearchProps
74
- self.fabProps = fabProps
75
- self.content = content
76
- }
77
-
78
- @State private var scrollOffset: CGFloat = 0
79
- @State private var keyboardHeight: CGFloat = 0
80
-
81
- // MARK: - Body
82
-
83
- public var body: some View {
84
- GeometryReader { geometry in
85
- let topInset = geometry.safeAreaInsets.top
86
- let keyboardSize: CGFloat = useAvoidKeyboard ? max(keyboardHeight, 0) : 0
87
- let height = geometry.size.height
88
- let bottomInset = geometry.safeAreaInsets.bottom
89
- let screenHeight = height + topInset + bottomInset
90
-
91
- ZStack(alignment: .top) {
92
- // Background color
93
- (backgroundColor ?? Color.white)
94
- .edgesIgnoringSafeArea(.all)
95
-
96
- VStack(spacing: 0) {
97
- ZStack(alignment: fabProps?.position == .center ? .bottom : .bottomTrailing) {
98
- VStack(alignment: horizontalAlignment, spacing: 0) {
99
- if animatedHeader != nil || headerTransparent == true {
100
- ZStack(alignment: .top) {
101
- // MARK: - Header
102
- Header(
103
- headerType: headerType,
104
- titlePosition: titlePosition,
105
- title: title,
106
- headerRight: headerRight,
107
- goBack: goBack,
108
- opacity: min(scrollOffset / 114, 1),
109
- animatedHeader: animatedHeader,
110
- scrollState: scrollOffset,
111
- inputSearchProps: inputSearchProps,
112
- tintColor: tintColor
113
- )
114
-
115
- .background(
116
- HeaderBackground(
117
- headerType: headerType,
118
- scrollState: scrollOffset,
119
- isTransparent: headerTransparent
120
- )
121
- .overlay(animatedHeader?.composable(scrollOffset)
122
- .frame(maxWidth: .infinity)
123
- .aspectRatio(animatedHeader?.aspectRatio.value, contentMode: .fill)
124
- )
125
- )
126
-
127
- VStack {
128
- if scrollable {
129
- ScrollView(.vertical, showsIndicators: false) {
130
- VStack {
131
- content()
132
- }
133
- .background(GeometryReader { geo -> Color in
134
- DispatchQueue.main.async {
135
- self.scrollOffset = -geo.frame(in: .global).origin.y
136
- }
137
- return Color.clear
138
- })
139
- }
140
- } else {
141
- content()
142
- }
143
- }
144
- }
145
- } else {
146
- // MARK: - Header
147
- Header(
148
- headerType: headerType,
149
- titlePosition: titlePosition,
150
- title: title,
151
- headerRight: headerRight,
152
- goBack: goBack,
153
- opacity: min(scrollOffset / 114, 1),
154
- animatedHeader: animatedHeader,
155
- scrollState: scrollOffset,
156
- inputSearchProps: inputSearchProps,
157
- tintColor: tintColor
158
- )
159
- .background(
160
- HeaderBackground(
161
- headerType: headerType,
162
- scrollState: scrollOffset,
163
- isTransparent: headerTransparent
164
- )
165
- .edgesIgnoringSafeArea(.top)
166
- )
167
-
168
- if scrollable {
169
- ScrollView(.vertical, showsIndicators: false) {
170
- VStack {
171
- content()
172
- }
173
- .background(GeometryReader { geo -> Color in
174
- DispatchQueue.main.async {
175
- self.scrollOffset = -geo.frame(in: .global).origin.y
176
- }
177
- return Color.clear
178
- })
179
- }
180
- } else {
181
- content()
182
- }
183
- }
184
- }
185
-
186
- if let fabProps = fabProps {
187
- FloatingButton(
188
- props: fabProps,
189
- keyboardOffset: useAvoidKeyboard ? keyboardSize : 0,
190
- scrollOffset: scrollOffset
191
- )
192
- .padding(.horizontal, Spacing.M)
193
- }
194
- }
195
-
196
-
197
- // MARK: - Footer
198
- if let footerView = footer?() {
199
- Footer(footerView: footerView, keyboardSize: keyboardSize)
200
- }
201
- }
202
- }
203
- }
204
- }
205
-
206
- // MARK: - Keyboard Handling
207
-
208
- private func observeKeyboard() {
209
- NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillChangeFrameNotification, object: nil, queue: .main) { notification in
210
- if useAvoidKeyboard,
211
- let endFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect {
212
- withAnimation(.easeOut(duration: 0.25)) {
213
- keyboardHeight = UIScreen.main.bounds.height - endFrame.origin.y
214
- }
215
- }
216
- }
217
- }
218
- }
219
-
220
- // MARK: - Footer
221
-
222
- struct Footer: View {
223
- var footerView: AnyView
224
- var keyboardSize: CGFloat
225
-
226
- var body: some View {
227
- VStack {
228
- footerView
229
- }
230
- .padding(.vertical, Spacing.S)
231
- .padding(.horizontal, Spacing.M)
232
- .padding(.bottom, keyboardSize)
233
- .background(Colors.black01)
234
- .overlay(
235
- Rectangle()
236
- .fill(Colors.black20.opacity(0.1))
237
- .frame(height: 4)
238
- .shadow(color: Colors.black20.opacity(0.2), radius: 10, y: -2),
239
- alignment: .top
240
- )
241
- }
242
- }
@@ -1,31 +0,0 @@
1
- import SwiftUI
2
-
3
- public enum DotSize {
4
- case small
5
- case large
6
-
7
- var size: CGFloat {
8
- switch self {
9
- case .small: return 10
10
- case .large: return 16
11
- }
12
- }
13
- }
14
-
15
- public struct BadgeDot: View {
16
- var size: DotSize
17
-
18
- public init(size: DotSize = .large) {
19
- self.size = size
20
- }
21
-
22
- public var body: some View {
23
- Circle()
24
- .fill(Colors.red03)
25
- .frame(width: size.size, height: size.size)
26
- .overlay(
27
- Circle()
28
- .stroke(Colors.black01, lineWidth: 1)
29
- )
30
- }
31
- }