@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,214 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.CompositionLocalProvider
5
- import androidx.compose.runtime.Immutable
6
- import androidx.compose.runtime.LaunchedEffect
7
- import androidx.compose.runtime.getValue
8
- import androidx.compose.runtime.mutableStateOf
9
- import androidx.compose.runtime.remember
10
- import androidx.compose.runtime.setValue
11
- import androidx.compose.runtime.staticCompositionLocalOf
12
- import androidx.compose.ui.unit.Dp
13
- import vn.momo.kits.components.TrustBannerData
14
- import vn.momo.kits.const.AppStatusBar
15
- import vn.momo.kits.const.AppTheme
16
- import vn.momo.kits.const.Theme
17
- import vn.momo.kits.const.ThemeAssets
18
- import vn.momo.kits.const.defaultTheme
19
- import vn.momo.kits.platform.getStatusBarHeight
20
-
21
- @Deprecated("Use IMaxApi instead", ReplaceWith("IMaxApi"))
22
- interface ComposeApi {
23
- fun request(funcName: String, params: Any?): String
24
- fun request(funcName: String, params: Any?, onResponse: ((String) -> Unit)?): String
25
- fun requestCallback(funcName: String, params: Any?, onResponse: ((String) -> Unit)?)
26
- fun removeCallback(id: String)
27
- }
28
-
29
- class Navigator {
30
- fun push(content: @Composable () -> Unit) {
31
- //implement
32
- }
33
-
34
- fun present(content: @Composable () -> Unit) {
35
- //implement
36
- }
37
-
38
- fun reset(content: @Composable () -> Unit) {
39
- //implement
40
- }
41
-
42
- fun pop() {
43
- //implement
44
- }
45
-
46
- fun replace(content: @Composable () -> Unit) {
47
- //implement
48
- }
49
-
50
- fun popToTop() {
51
- //implement
52
- }
53
-
54
- fun showModal(
55
- onClose: () -> Unit = {},
56
- canBackgroundClose: Boolean = true,
57
- content: @Composable () -> Unit,
58
- ) {
59
- //implement
60
- }
61
-
62
- fun showBottomSheet(content: @Composable () -> Unit) {
63
- //implement
64
- }
65
- }
66
-
67
- @Immutable
68
- data class MiniAppContext(
69
- val appIcon: String = "",
70
- val appName: Any? = null,
71
- val appId: String = "",
72
- val appCode: String = "",
73
- val description: Any? = null,
74
- val support: Map<String, Any?> = emptyMap(),
75
- val toolkitConfig: Map<String, Any?> = emptyMap(),
76
- val providerId: String = "",
77
- val permissions: List<Map<String, Any>>? = emptyList()
78
- ) {
79
- companion object {
80
- private const val KEY_ICON = "icon"
81
- private const val KEY_NAME = "name"
82
- private const val KEY_APP_ID = "appId"
83
- private const val KEY_CODE = "code"
84
- private const val KEY_DESCRIPTION = "description"
85
- private const val KEY_SUPPORT = "support"
86
- private const val KEY_TOOLKIT_CFG = "toolkitConfig"
87
- private const val KEY_PERMISSIONS = "permissions"
88
- private const val KEY_ORIGIN_APP = "originAppId"
89
-
90
- fun toMap(context: MiniAppContext?): Map<String, Any?> = mapOf(
91
- "icon" to (context?.appIcon ?: ""),
92
- "name" to context?.appName,
93
- "appId" to (context?.appId ?: ""),
94
- "code" to (context?.appCode ?: ""),
95
- "description" to (context?.description ?: ""),
96
- "support" to (context?.support ?: emptyMap<String, Any?>()),
97
- "toolkitConfig" to (context?.toolkitConfig ?: emptyMap<String, Any?>()),
98
- "providerId" to (context?.providerId ?: ""),
99
- "permissions" to (context?.permissions ?: emptyList<Map<String, Any>>())
100
- )
101
-
102
- fun fromMap(data: Map<String, Any?>?): MiniAppContext = MiniAppContext(
103
- appIcon = data.string(KEY_ICON) ?: "",
104
- appName = data?.get(KEY_NAME),
105
- appId = data.string(KEY_APP_ID) ?: "",
106
- appCode = data.string(KEY_CODE) ?: "",
107
- description = data?.get(KEY_DESCRIPTION),
108
- support = data.mapStringAny(KEY_SUPPORT),
109
- toolkitConfig = data.mapStringAny(KEY_TOOLKIT_CFG),
110
- providerId = computeProviderId(
111
- originAppId = data.string(KEY_ORIGIN_APP),
112
- appId = data.string(KEY_APP_ID)
113
- ),
114
- permissions = data.listOfMapStringAny(KEY_PERMISSIONS)
115
- )
116
-
117
- private fun computeProviderId(originAppId: String?, appId: String?): String {
118
- val id = when {
119
- !originAppId.isNullOrBlank() -> originAppId
120
- !appId.isNullOrBlank() -> appId
121
- else -> null
122
- } ?: return "unknown"
123
-
124
- val parts = id.split('.')
125
- return parts.getOrNull(1) ?: "unknown"
126
- }
127
- }
128
- }
129
-
130
- private fun Map<String, Any?>?.string(key: String): String? =
131
- (this?.get(key) as? String)
132
-
133
- @Suppress("UNCHECKED_CAST")
134
- private fun Map<String, Any?>?.mapStringAny(key: String): Map<String, Any?> =
135
- (this?.get(key) as? Map<String, Any?>) ?: emptyMap()
136
-
137
- @Suppress("UNCHECKED_CAST")
138
- private fun Map<String, Any?>?.listOfMapStringAny(key: String): List<Map<String, Any>> =
139
- (this?.get(key) as? List<Map<String, Any>>) ?: emptyList()
140
-
141
- @Deprecated("Use LocalApi instead", ReplaceWith("LocalApi"))
142
- val PlatformApi = staticCompositionLocalOf<Any?> { null }
143
-
144
- @Deprecated("Use LocalNavigator instead", ReplaceWith("LocalNavigator"))
145
- val AppNavigator = staticCompositionLocalOf<Navigator?> {
146
- null
147
- }
148
-
149
- val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
150
- null
151
- }
152
-
153
- val AppConfig = staticCompositionLocalOf<KitConfig?> {
154
- null
155
- }
156
-
157
- val AppLanguage = staticCompositionLocalOf<String?> {
158
- null
159
- }
160
-
161
- @Immutable
162
- data class KitConfig(
163
- val trustBanner: TrustBannerData? = null,
164
- val headerBar: String? = null,
165
- val headerGradient: String? = null,
166
- )
167
-
168
- internal var DesignSystemWhiteList: Boolean? = null
169
-
170
- @Deprecated("Use NavigationContainer instead", ReplaceWith("NavigationContainer"))
171
- @Composable
172
- fun ApplicationContainer(
173
- theme: Theme = defaultTheme,
174
- composeApi: ComposeApi? = null,
175
- statusBarHeight: Dp? = AppStatusBar.current,
176
- applicationContext: MiniAppContext? = null,
177
- config: KitConfig? = null,
178
- language: String? = null,
179
- isWhiteList: Boolean = false,
180
- content: @Composable () -> Unit,
181
- ) {
182
- var appTheme by remember { mutableStateOf(theme) }
183
-
184
- LaunchedEffect(Unit) {
185
- DesignSystemWhiteList = isWhiteList
186
- try {
187
- val headerBar = config?.headerBar
188
- if (headerBar != null && appTheme.assets.headerBackground == null) {
189
- appTheme = appTheme.copy(
190
- assets = ThemeAssets(
191
- headerBackground = headerBar
192
- )
193
- )
194
- }
195
- } catch (e: Exception) {
196
- print("@@ == NavigationContainer get config error $e")
197
- }
198
- }
199
-
200
- val appStatusBarHeight = statusBarHeight ?: getStatusBarHeight()
201
-
202
- CompositionLocalProvider(
203
- AppTheme provides appTheme,
204
- PlatformApi provides composeApi,
205
- AppNavigator provides Navigator(),
206
- AppStatusBar provides appStatusBarHeight,
207
- ApplicationContext provides applicationContext,
208
- AppConfig provides config,
209
- AppLanguage provides language,
210
- ) {
211
- content()
212
- }
213
-
214
- }
@@ -1,235 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import androidx.compose.animation.core.animateFloatAsState
4
- import androidx.compose.foundation.ScrollState
5
- import androidx.compose.foundation.background
6
- import androidx.compose.foundation.gestures.detectTapGestures
7
- import androidx.compose.foundation.layout.Arrangement
8
- import androidx.compose.foundation.layout.Box
9
- import androidx.compose.foundation.layout.Column
10
- import androidx.compose.foundation.layout.Spacer
11
- import androidx.compose.foundation.layout.WindowInsets
12
- import androidx.compose.foundation.layout.asPaddingValues
13
- import androidx.compose.foundation.layout.aspectRatio
14
- import androidx.compose.foundation.layout.fillMaxSize
15
- import androidx.compose.foundation.layout.fillMaxWidth
16
- import androidx.compose.foundation.layout.ime
17
- import androidx.compose.foundation.layout.imePadding
18
- import androidx.compose.foundation.layout.padding
19
- import androidx.compose.foundation.layout.systemBars
20
- import androidx.compose.foundation.rememberScrollState
21
- import androidx.compose.foundation.verticalScroll
22
- import androidx.compose.runtime.Composable
23
- import androidx.compose.runtime.getValue
24
- import androidx.compose.ui.Alignment
25
- import androidx.compose.ui.Modifier
26
- import androidx.compose.ui.graphics.Color
27
- import androidx.compose.ui.input.pointer.pointerInput
28
- import androidx.compose.ui.layout.LayoutCoordinates
29
- import androidx.compose.ui.layout.onGloballyPositioned
30
- import androidx.compose.ui.platform.LocalDensity
31
- import androidx.compose.ui.platform.LocalSoftwareKeyboardController
32
- import androidx.compose.ui.unit.Dp
33
- import androidx.compose.ui.unit.dp
34
- import androidx.compose.ui.unit.min
35
- import androidx.compose.ui.zIndex
36
- import vn.momo.kits.components.InputSearchProps
37
- import vn.momo.kits.const.AppTheme
38
- import vn.momo.kits.const.Colors
39
- import vn.momo.kits.const.Spacing
40
- import vn.momo.kits.modifier.conditional
41
- import vn.momo.kits.modifier.shadow
42
- import vn.momo.kits.platform.getAndroidBuildVersion
43
- import vn.momo.kits.utils.getAppStatusBarHeight
44
-
45
- enum class HeaderType {
46
- DEFAULT,
47
- EXTENDED,
48
- NONE
49
- }
50
-
51
- const val HEADER_HEIGHT = 52
52
-
53
- @Deprecated("Use NavigationContainer(StackScreen) instead", ReplaceWith("NavigationContainer(StackScreen)"))
54
- @Composable
55
- fun Screen(
56
- backgroundColor: Color? = null,
57
- tintColor: Color? = null,
58
- headerTransparent: Boolean = false,
59
- isBack: Boolean = true,
60
- headerType: HeaderType = HeaderType.DEFAULT,
61
- verticalArrangement: Arrangement.Vertical = Arrangement.Top,
62
- horizontalAlignment: Alignment.Horizontal = Alignment.Start,
63
- title: String = "Stack",
64
- titlePosition: TitlePosition = TitlePosition.LEFT,
65
- goBack: (() -> Unit)? = null,
66
- scrollable: Boolean = true,
67
- scrollState: ScrollState = rememberScrollState(),
68
- onContentLayout: ((LayoutCoordinates) -> Unit)? = null,
69
- useAvoidKeyboard: Boolean = true,
70
- footer: @Composable (() -> Unit)? = null,
71
- headerRight: @Composable (() -> Unit)? = null,
72
- fabProps: FabProps? = null,
73
- animatedHeader: AnimatedHeader? = null,
74
- layoutOffset: Dp = 56.dp,
75
- inputSearchProps: InputSearchProps? = null,
76
- useAnimationSearch: Boolean = false,
77
- headerRightWidth: Dp = 0.dp,
78
- content: @Composable () -> Unit,
79
- ) {
80
- val statusBarHeight = getAppStatusBarHeight()
81
- val keyboardController = LocalSoftwareKeyboardController.current
82
-
83
- val isKeyboardVisible = isKeyboardVisible()
84
- val indicator = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
85
- val bottomPadding = min(indicator, if (isKeyboardVisible) 0.dp else 21.dp)
86
-
87
- val headerHeight = if (animatedHeader !== null)
88
- with(LocalDensity.current) { layoutOffset.roundToPx() }
89
- else HEADER_HEIGHT
90
- val opacity by animateFloatAsState(
91
- targetValue = ((scrollState.value.toFloat() / headerHeight)).coerceIn(0f, 1f),
92
- )
93
-
94
- val headerAnimated =
95
- @Composable {
96
- Box(
97
- modifier = Modifier
98
- .fillMaxWidth()
99
- .aspectRatio(animatedHeader?.aspectRatio?.value ?: AnimatedHeaderRatio.RATIO_16_9.value)
100
- ) {
101
- animatedHeader?.composable?.invoke(scrollState.value)
102
- }
103
- }
104
-
105
- Box(
106
- Modifier.fillMaxSize()
107
- .background(backgroundColor ?: AppTheme.current.colors.background.default)
108
- .conditional(useAvoidKeyboard && getAndroidBuildVersion() > 29) {
109
- imePadding()
110
- }
111
- ) {
112
-
113
- if (animatedHeader === null) {
114
- HeaderBackground(
115
- headerType = headerType,
116
- scrollState = scrollState.value,
117
- headerTransparent = headerTransparent
118
- )
119
- }
120
-
121
- Header(
122
- headerType = headerType,
123
- title = title,
124
- titlePosition = titlePosition,
125
- headerRight = headerRight,
126
- headerRightWidth = headerRightWidth,
127
- goBack = goBack,
128
- opacity = opacity,
129
- animatedHeader = animatedHeader,
130
- inputSearchProps = inputSearchProps,
131
- scrollState = scrollState.value,
132
- useAnimationSearch = useAnimationSearch,
133
- tintColor = tintColor
134
- )
135
-
136
- Column(
137
- modifier = Modifier.fillMaxSize()
138
- .padding( top = when {
139
- animatedHeader != null -> 0.dp
140
- headerType == HeaderType.NONE -> 0.dp
141
- headerTransparent -> 0.dp
142
- else -> statusBarHeight + HEADER_HEIGHT.dp
143
- })
144
- .pointerInput(Unit) {
145
- detectTapGestures(onTap = {
146
- keyboardController?.hide()
147
- })
148
- }
149
- .zIndex(1f),
150
- ) {
151
-
152
- Column(
153
- modifier = Modifier
154
- .conditional(scrollable) { weight(1f) }
155
- .conditional(onContentLayout != null) {
156
- onGloballyPositioned(onContentLayout ?: {})
157
- }
158
- .conditional(scrollable) { verticalScroll(scrollState) },
159
- verticalArrangement = verticalArrangement,
160
- horizontalAlignment = horizontalAlignment
161
- ) {
162
- Box {
163
- if (animatedHeader !== null) headerAnimated()
164
- Column {
165
- if (animatedHeader !== null) {
166
- Spacer(modifier = Modifier.padding(top = statusBarHeight + HEADER_HEIGHT.dp + layoutOffset))
167
- }
168
-
169
- if (useAnimationSearch && inputSearchProps != null && headerType == HeaderType.EXTENDED) {
170
- Spacer(modifier = Modifier.padding(top = (HEADER_HEIGHT.dp + Spacing.S)))
171
- }
172
- content()
173
- }
174
- }
175
- }
176
-
177
- footer?.let {
178
- Footer(footer, bottomPadding)
179
- }
180
- }
181
-
182
- if (fabProps != null) {
183
- FloatingButton(
184
- scrollPosition = fabProps.scrollState?.value ?: scrollState.value,
185
- onClick = fabProps.onClick,
186
- containerColor = AppTheme.current.colors.primary,
187
- bottom = fabProps.bottom
188
- ?: if (footer != null) bottomPadding + 76.dp else bottomPadding + 12.dp,
189
- icon = fabProps.icon,
190
- iconColor = fabProps.iconColor,
191
- text = fabProps.label,
192
- size = fabProps.size,
193
- position = fabProps.position ?: FABPosition.END,
194
- )
195
- }
196
- }
197
- }
198
-
199
- @Composable
200
- internal fun isKeyboardVisible(): Boolean {
201
- val ime = WindowInsets.ime
202
- val density = LocalDensity.current
203
- val bottom = ime.getBottom(density)
204
- return bottom > 0
205
- }
206
-
207
- @Composable
208
- fun Footer(footer: @Composable (() -> Unit)? = null, bottom: Dp = 0.dp) {
209
- Box(
210
- Modifier
211
- .shadow(
212
- color = Colors.black_20.copy(alpha = 0.05f),
213
- blurRadius = 24f,
214
- offsetX = 0.dp,
215
- offsetY = (-4).dp
216
- )
217
- .background(AppTheme.current.colors.background.surface)
218
- ) {
219
- Box(
220
- Modifier.fillMaxWidth()
221
- .padding(bottom = bottom)
222
- .padding(vertical = Spacing.S, horizontal = Spacing.M)
223
- ) {
224
- footer?.invoke()
225
- }
226
- }
227
- }
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
@@ -1,69 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import androidx.compose.animation.animateColorAsState
4
- import androidx.compose.animation.core.animateFloatAsState
5
- import androidx.compose.runtime.Composable
6
- import androidx.compose.runtime.getValue
7
- import androidx.compose.ui.graphics.Color
8
- import androidx.compose.ui.unit.Dp
9
- import androidx.compose.ui.unit.dp
10
- import vn.momo.kits.const.AppTheme
11
- import vn.momo.kits.const.Colors
12
- import vn.momo.kits.platform.getScreenDimensions
13
-
14
- data class HeaderAnimations(
15
- val opacity: Float,
16
- val backgroundSearch: Color,
17
- val translateX: Float,
18
- val width: Float,
19
- val translateY: Float
20
- )
21
-
22
- private const val SCREEN_PADDING = 12
23
- private const val BACK_WIDTH = 28
24
-
25
- @Deprecated("Use vn.momo.kits.navigation.component.Header instead", ReplaceWith("vn.momo.kits.navigation.component.Header"))
26
- @Composable
27
- fun useHeaderSearchAnimation(
28
- opacityAni: Float,
29
- scrollState: Int,
30
- headerRightWidth: Dp,
31
- isBack: Boolean
32
- ): HeaderAnimations {
33
- val screenWidth = getScreenDimensions().width
34
- val leftPosition = if (isBack) (BACK_WIDTH + 20).dp else 12.dp
35
- val searchWidth = screenWidth - (SCREEN_PADDING * 2)
36
-
37
- val backgroundSearch by animateColorAsState(
38
- targetValue = animateColor(
39
- Colors.black_01,
40
- AppTheme.current.colors.background.default,
41
- opacityAni
42
- ),
43
- )
44
-
45
- val animatedTranslateX by animateFloatAsState(
46
- targetValue = (scrollState / HEADER_HEIGHT * 1f).coerceIn(
47
- 0f,
48
- 1f
49
- ) * (leftPosition.value - 12) + 12,
50
- )
51
-
52
- val animatedWidth by animateFloatAsState(
53
- targetValue = (scrollState / HEADER_HEIGHT * 1f).coerceIn(
54
- 0f,
55
- 1f
56
- ) * ((searchWidth - leftPosition.value - headerRightWidth.value + 12) - searchWidth) + searchWidth,
57
- )
58
-
59
- val animatedTranslateY by animateFloatAsState(
60
- targetValue = (1 - (scrollState / HEADER_HEIGHT * 1f).coerceIn(0f, 1f)) * HEADER_HEIGHT
61
- )
62
- return HeaderAnimations(
63
- opacity = opacityAni,
64
- backgroundSearch = backgroundSearch,
65
- translateX = animatedTranslateX,
66
- width = animatedWidth,
67
- translateY = animatedTranslateY
68
- )
69
- }
@@ -1,77 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.layout.Box
6
- import androidx.compose.foundation.layout.height
7
- import androidx.compose.foundation.layout.padding
8
- import androidx.compose.foundation.layout.widthIn
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.ui.Alignment
12
- import androidx.compose.ui.Modifier
13
- import androidx.compose.ui.graphics.Color
14
- import androidx.compose.ui.unit.dp
15
- import vn.momo.kits.const.AppTheme
16
- import vn.momo.kits.const.Colors
17
- import vn.momo.kits.const.Radius
18
- import vn.momo.kits.const.Spacing
19
- import vn.momo.kits.const.Typography
20
- import vn.momo.kits.const.scaleSize
21
-
22
-
23
- @Composable
24
- fun Badge(label: String = "Label", backgroundColor: Color? = null) {
25
- val primaryColors = listOf(
26
- Color(0xFFF0F0F0),
27
- Color(0xFFEB2F96),
28
- Color(0xFF962AF0),
29
- Color(0xFF4E4BFF),
30
- Color(0xFF007AFF),
31
- Color(0xFF13C2C2),
32
- Color(0xFF34C759),
33
- Color(0xFFA0D911),
34
- Color(0xFFFFCC00),
35
- Color(0xFFFA8C16),
36
- Color(0xFFFA541C),
37
- Color(0xFFF5222D)
38
- )
39
-
40
- fun isNumber(label: String): Boolean {
41
- val numberRegex = "^\\d+$".toRegex()
42
- return numberRegex.matches(label)
43
- }
44
-
45
- fun formatTitle(label: String): String {
46
- if (isNumber(label) && label.toInt() > 99) {
47
- return "99+"
48
- }
49
- return label
50
- }
51
-
52
- var badgeColor =
53
- if (isNumber(label)) {
54
- AppTheme.current.colors.error.primary
55
- } else {
56
- AppTheme.current.colors.warning.primary
57
- }
58
-
59
- if (backgroundColor != null && primaryColors.contains(backgroundColor)) {
60
- badgeColor = backgroundColor
61
- }
62
-
63
- Box(
64
- modifier = Modifier
65
- .height(scaleSize(16.toFloat()).dp)
66
- .widthIn(min = scaleSize(16.toFloat()).dp)
67
- .background(color = badgeColor, shape = RoundedCornerShape(Radius.M))
68
- .border(width = 1.dp, shape = RoundedCornerShape(Radius.M), color = Colors.black_01)
69
- .padding(horizontal = Spacing.XS), contentAlignment = Alignment.Center
70
- ) {
71
- Text(
72
- text = formatTitle(label),
73
- color = Colors.black_01,
74
- style = Typography.actionXxsBold
75
- )
76
- }
77
- }
@@ -1,27 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.layout.Box
6
- import androidx.compose.foundation.layout.size
7
- import androidx.compose.foundation.shape.RoundedCornerShape
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Modifier
10
- import androidx.compose.ui.unit.dp
11
- import vn.momo.kits.const.Colors
12
- import vn.momo.kits.const.Radius
13
-
14
- enum class DotSize(val size: Int) {
15
- Small(10),
16
- Large(16)
17
- }
18
-
19
- @Composable
20
- fun BadgeDot(size: DotSize = DotSize.Large, modifier: Modifier = Modifier) {
21
- Box(
22
- modifier = modifier
23
- .size(size.size.dp)
24
- .border(width = 1.dp, color = Colors.black_01, shape = RoundedCornerShape(Radius.S))
25
- .background(color = Colors.red_03, shape = RoundedCornerShape(Radius.S))
26
- )
27
- }