@momo-kits/native-kits 0.163.1-beta.3-debug → 0.163.1-beta.3

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 (136) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -189
  4. package/compose/build.gradle.kts.backup +0 -189
  5. package/compose/compose.podspec +0 -47
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -123
  8. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -108
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -294
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -826
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -107
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -140
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -112
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -477
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -214
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -216
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -180
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -217
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -470
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -134
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -203
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -175
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -269
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -253
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -94
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -175
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -360
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -557
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -155
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -223
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -319
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -81
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -34
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -360
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -128
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -70
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -58
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -184
  129. package/gradle/libs.versions.toml +0 -67
  130. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  131. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  132. package/gradle.properties +0 -26
  133. package/gradlew +0 -252
  134. package/gradlew.bat +0 -94
  135. package/local.properties +0 -8
  136. package/settings.gradle.kts +0 -64
@@ -1,378 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import androidx.compose.animation.core.Animatable
4
- import androidx.compose.animation.core.animateFloatAsState
5
- import androidx.compose.animation.core.tween
6
- import androidx.compose.foundation.ScrollState
7
- import androidx.compose.foundation.background
8
- import androidx.compose.foundation.gestures.detectTapGestures
9
- import androidx.compose.foundation.layout.*
10
- import androidx.compose.foundation.rememberScrollState
11
- import androidx.compose.foundation.verticalScroll
12
- import androidx.compose.runtime.*
13
- import androidx.compose.ui.Alignment
14
- import androidx.compose.ui.Modifier
15
- import androidx.compose.ui.graphics.Color
16
- import androidx.compose.ui.input.pointer.pointerInput
17
- import androidx.compose.ui.layout.LayoutCoordinates
18
- import androidx.compose.ui.layout.onGloballyPositioned
19
- import androidx.compose.ui.platform.LocalDensity
20
- import androidx.compose.ui.platform.LocalSoftwareKeyboardController
21
- import androidx.compose.ui.unit.Dp
22
- import androidx.compose.ui.unit.IntOffset
23
- import androidx.compose.ui.unit.dp
24
- import androidx.compose.ui.zIndex
25
- import kotlinx.coroutines.*
26
- import vn.momo.kits.components.InputSearchProps
27
- import vn.momo.kits.const.AppNavigationBar
28
- import vn.momo.kits.const.AppTheme
29
- import vn.momo.kits.const.Colors
30
- import vn.momo.kits.const.Spacing
31
- import vn.momo.kits.modifier.conditional
32
- import vn.momo.kits.modifier.DeprecatedModifier
33
- import vn.momo.kits.modifier.shadow
34
- import vn.momo.kits.navigation.component.SnackBar
35
- import vn.momo.kits.platform.supportsImePadding
36
- import vn.momo.kits.utils.getAppStatusBarHeight
37
- import vn.momo.kits.utils.getNavigationBarHeight
38
- import kotlin.time.Duration.Companion.milliseconds
39
-
40
- enum class HeaderType {
41
- DEFAULT,
42
- EXTENDED,
43
- NONE
44
- }
45
-
46
- const val HEADER_HEIGHT = 52
47
-
48
- @Deprecated("Use NavigationContainer(StackScreen) instead", ReplaceWith("NavigationContainer(StackScreen)"))
49
- @Composable
50
- fun Screen(
51
- backgroundColor: Color? = null,
52
- tintColor: Color? = null,
53
- headerTransparent: Boolean = false,
54
- fullScreenContent: Boolean = false,
55
- isBack: Boolean = true,
56
- headerType: HeaderType = HeaderType.DEFAULT,
57
- verticalArrangement: Arrangement.Vertical = Arrangement.Top,
58
- horizontalAlignment: Alignment.Horizontal = Alignment.Start,
59
- title: String = "Stack",
60
- titlePosition: TitlePosition = TitlePosition.LEFT,
61
- goBack: (() -> Unit)? = null,
62
- scrollable: Boolean = true,
63
- scrollState: ScrollState = rememberScrollState(),
64
- onContentLayout: ((LayoutCoordinates) -> Unit)? = null,
65
- useAvoidKeyboard: Boolean = true,
66
- footer: @Composable (() -> Unit)? = null,
67
- headerRight: @Composable (() -> Unit)? = null,
68
- fabProps: FabProps? = null,
69
- animatedHeader: AnimatedHeader? = null,
70
- layoutOffset: Dp = 56.dp,
71
- inputSearchProps: InputSearchProps? = null,
72
- useAnimationSearch: Boolean = false,
73
- headerRightWidth: Dp = 0.dp,
74
- content: @Composable () -> Unit,
75
- ) {
76
- val statusBarHeight = getAppStatusBarHeight()
77
- val keyboardController = LocalSoftwareKeyboardController.current
78
-
79
- val isKeyboardVisible = isKeyboardVisible()
80
- val indicator = getNavigationBarHeight()
81
- val bottomPadding = if (isKeyboardVisible) 0.dp else indicator
82
-
83
- val headerHeight = if (animatedHeader !== null)
84
- with(LocalDensity.current) { layoutOffset.roundToPx() }
85
- else HEADER_HEIGHT
86
- val opacity by animateFloatAsState(
87
- targetValue = ((scrollState.value.toFloat() / headerHeight)).coerceIn(0f, 1f),
88
- )
89
-
90
- val headerAnimated =
91
- @Composable {
92
- Box(
93
- modifier = Modifier
94
- .fillMaxWidth()
95
- .aspectRatio(animatedHeader?.aspectRatio?.value ?: AnimatedHeaderRatio.RATIO_16_9.value)
96
- ) {
97
- animatedHeader?.composable?.invoke(scrollState.value)
98
- }
99
- }
100
- val helper = remember { ScreenHelper() }
101
-
102
- DisposableEffect(Unit) {
103
- onDispose { helper.dispose() }
104
- }
105
-
106
- CompositionLocalProvider(
107
- LocalScreenHelper provides helper
108
- ) {
109
- Box(
110
- Modifier.fillMaxSize()
111
- .background(backgroundColor ?: AppTheme.current.colors.background.default)
112
- .conditional(useAvoidKeyboard && supportsImePadding()) {
113
- imePadding()
114
- }.then(DeprecatedModifier())
115
- ) {
116
- val footerHeightPx = remember { mutableStateOf(0) }
117
-
118
- Box(Modifier.zIndex(1f)) {
119
- if (animatedHeader === null) {
120
- HeaderBackground(
121
- headerType = headerType,
122
- scrollState = scrollState.value,
123
- headerTransparent = headerTransparent
124
- )
125
- }
126
- }
127
-
128
- Box(Modifier.zIndex(5f)) {
129
- Header(
130
- headerType = headerType,
131
- title = title,
132
- titlePosition = titlePosition,
133
- headerRight = headerRight,
134
- headerRightWidth = headerRightWidth,
135
- goBack = goBack,
136
- opacity = opacity,
137
- animatedHeader = animatedHeader,
138
- inputSearchProps = inputSearchProps,
139
- scrollState = scrollState.value,
140
- useAnimationSearch = useAnimationSearch,
141
- tintColor = tintColor
142
- )
143
- }
144
-
145
- Box(Modifier.zIndex(2f).fillMaxSize()){
146
- Column(
147
- modifier = Modifier.fillMaxSize()
148
- .padding( top = when {
149
- animatedHeader != null -> 0.dp
150
- headerType == HeaderType.NONE -> 0.dp
151
- fullScreenContent -> 0.dp
152
- else -> statusBarHeight + HEADER_HEIGHT.dp
153
- })
154
- .pointerInput(Unit) {
155
- detectTapGestures(onTap = {
156
- keyboardController?.hide()
157
- })
158
- }
159
- .zIndex(1f),
160
- ) {
161
-
162
- Column(
163
- modifier = Modifier
164
- .conditional(scrollable) { weight(1f) }
165
- .conditional(onContentLayout != null) {
166
- onGloballyPositioned(onContentLayout ?: {})
167
- }
168
- .conditional(scrollable) { verticalScroll(scrollState) },
169
- verticalArrangement = verticalArrangement,
170
- horizontalAlignment = horizontalAlignment
171
- ) {
172
- Box {
173
- if (animatedHeader !== null) headerAnimated()
174
- Column {
175
- if (animatedHeader !== null) {
176
- Spacer(modifier = Modifier.padding(top = statusBarHeight + HEADER_HEIGHT.dp + layoutOffset))
177
- }
178
-
179
- if (useAnimationSearch && inputSearchProps != null && headerType == HeaderType.EXTENDED) {
180
- Spacer(modifier = Modifier.padding(top = (HEADER_HEIGHT.dp + Spacing.S)))
181
- }
182
- content()
183
- }
184
- }
185
- }
186
-
187
- footer?.let {
188
- val footerHeight = with(LocalDensity.current) { footerHeightPx.value.toDp() }
189
- Spacer(Modifier.height(footerHeight))
190
- }
191
- }
192
- }
193
-
194
- Box(Modifier.zIndex(4f).align(Alignment.BottomCenter)) {
195
- footer?.let {
196
- Footer(
197
- footer = footer,
198
- bottom = bottomPadding,
199
- onFooterMeasured = { footerHeightPx.value = it }
200
- )
201
- }
202
- }
203
-
204
- Column (Modifier.zIndex(6f)) {
205
- if (fabProps != null) {
206
- FloatingButton(
207
- scrollPosition = fabProps.scrollState?.value ?: scrollState.value,
208
- onClick = fabProps.onClick,
209
- containerColor = AppTheme.current.colors.primary,
210
- bottom = fabProps.bottom
211
- ?: if (footer != null) bottomPadding + 76.dp else bottomPadding + 12.dp,
212
- icon = fabProps.icon,
213
- iconColor = fabProps.iconColor,
214
- text = fabProps.label,
215
- size = fabProps.size,
216
- position = fabProps.position ?: FABPosition.END,
217
- )
218
- }
219
- }
220
-
221
- Box(
222
- modifier = Modifier
223
- .align(Alignment.BottomCenter)
224
- .zIndex(3f)
225
- ) {
226
- ScreenSnackBarHost(if (footer == null) 0 else footerHeightPx.value)
227
- }
228
- }
229
- }
230
- }
231
-
232
- @Composable
233
- internal fun isKeyboardVisible(): Boolean {
234
- val ime = WindowInsets.ime
235
- val density = LocalDensity.current
236
- val bottom = ime.getBottom(density)
237
- return bottom > 0
238
- }
239
-
240
- @Composable
241
- fun Footer(
242
- footer: @Composable (() -> Unit)? = null,
243
- bottom: Dp = 0.dp,
244
- onFooterMeasured: ((Int) -> Unit)? = null
245
- ) {
246
- Box(
247
- Modifier
248
- .shadow(
249
- color = Colors.black_20.copy(alpha = 0.05f),
250
- blurRadius = 24f,
251
- offsetX = 0.dp,
252
- offsetY = (-4).dp
253
- )
254
- .background(AppTheme.current.colors.background.surface)
255
- .onGloballyPositioned {
256
- onFooterMeasured?.invoke(it.size.height)
257
- }
258
-
259
- ) {
260
- Box(
261
- Modifier.fillMaxWidth()
262
- .padding(bottom = bottom)
263
- .padding(vertical = Spacing.S, horizontal = Spacing.M)
264
- ) {
265
- footer?.invoke()
266
- }
267
- }
268
- }
269
-
270
-
271
- class ScreenHelper {
272
-
273
- private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
274
-
275
- internal var snackBarState by mutableStateOf<SnackBarData?>(null)
276
-
277
- internal var requestHide by mutableStateOf(false)
278
-
279
- fun showSnackBar(snackBar: SnackBar, onDismiss: (() -> Unit)? = null) {
280
- scope.launch {
281
- requestHide = false
282
- snackBarState = SnackBarData(snackBar, onDismiss)
283
- }
284
- }
285
-
286
- fun hideSnackBar() {
287
- scope.launch {
288
- requestHide = true
289
- }
290
- }
291
-
292
- internal fun removeSnackBarNow() {
293
- snackBarState = null
294
- requestHide = false
295
- }
296
-
297
- fun dispose() {
298
- scope.cancel()
299
- }
300
- }
301
- data class SnackBarData(
302
- val type: SnackBar,
303
- val onDismiss: (() -> Unit)?
304
- )
305
-
306
- val LocalScreenHelper = staticCompositionLocalOf<ScreenHelper> {
307
- error("No Screen helper provided")
308
- }
309
-
310
- @Composable
311
- internal fun ScreenSnackBarHost(footerHeightPx: Int) {
312
- val helper = LocalScreenHelper.current
313
- val snackBarData = helper.snackBarState ?: return
314
- val density = LocalDensity.current
315
- val navigationBar = AppNavigationBar.current
316
-
317
- val footerHeight = if (footerHeightPx > 0) {
318
- footerHeightPx
319
- } else {
320
- with(density) {
321
- navigationBar.toPx()
322
- }
323
- }.toInt()
324
-
325
- var startPosition by remember { mutableStateOf(Float.MAX_VALUE) }
326
- val targetPosition = 0f
327
-
328
- var offsetY by remember { mutableStateOf(Animatable(startPosition)) }
329
-
330
- LaunchedEffect(startPosition) {
331
- if (startPosition != Float.MAX_VALUE){
332
- offsetY.snapTo(startPosition)
333
- offsetY.animateTo(targetPosition, tween(350))
334
- }
335
- }
336
-
337
- LaunchedEffect(helper.requestHide) {
338
- if (helper.requestHide) {
339
- offsetY.animateTo(startPosition, tween(200))
340
- helper.removeSnackBarNow()
341
- snackBarData.onDismiss?.invoke()
342
- }
343
- }
344
-
345
- LaunchedEffect(snackBarData.type.duration) {
346
- val duration = snackBarData.type.duration
347
- if (duration != null) {
348
- delay(duration.milliseconds)
349
- helper.hideSnackBar()
350
- }
351
- }
352
-
353
- DisposableEffect(Unit) {
354
- onDispose { snackBarData.onDismiss?.invoke() }
355
- }
356
-
357
- Box(
358
- modifier = Modifier
359
- .offset { IntOffset(0, offsetY.value.toInt() - footerHeight) }
360
- .onGloballyPositioned {
361
- if (startPosition != it.size.height.toFloat()) {
362
- startPosition = it.size.height.toFloat()
363
- offsetY = Animatable(startPosition)
364
- }
365
- }
366
- .fillMaxWidth()
367
- ) {
368
- when (val type = snackBarData.type) {
369
- is SnackBar.Custom -> type.content()
370
- is SnackBar.Toast -> {}
371
- }
372
- }
373
- }
374
-
375
-
376
-
377
-
378
-
@@ -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
- internal 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,157 +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.fillMaxSize
7
- import androidx.compose.foundation.layout.offset
8
- import androidx.compose.foundation.layout.size
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.runtime.remember
12
- import androidx.compose.ui.Alignment
13
- import androidx.compose.ui.Modifier
14
- import androidx.compose.ui.draw.clip
15
- import androidx.compose.ui.semantics.contentDescription
16
- import androidx.compose.ui.semantics.semantics
17
- import androidx.compose.ui.unit.dp
18
- import androidx.compose.ui.zIndex
19
- import vn.momo.kits.application.IsShowBaseLineDebug
20
- import vn.momo.kits.const.AppTheme
21
- import vn.momo.kits.const.Colors
22
- import vn.momo.kits.const.Spacing
23
- import vn.momo.kits.const.Typography
24
- import vn.momo.kits.modifier.conditional
25
- import vn.momo.kits.modifier.setAutomationId
26
-
27
- private const val LOGO_MOMO_URL =
28
- "https://static.momocdn.net/app/img/kits/logo_momo_circle.png"
29
- private const val ICON_SUPPORT_DEFAULT_URL =
30
- "https://static.momocdn.net/app/img/kits/_indicator.png"
31
-
32
- enum class AvatarSize(val sizeDp: Int, val iconSizeDp: Int) {
33
- SIZE_24(24, 16),
34
- SIZE_32(32, 16),
35
- SIZE_40(40, 24),
36
- SIZE_48(48, 32),
37
- SIZE_56(56, 32),
38
- SIZE_72(72, 40),
39
- }
40
-
41
- @Composable
42
- fun Avatar(
43
- modifier: Modifier = Modifier,
44
- size: AvatarSize = AvatarSize.SIZE_32,
45
- rounded: Boolean = true,
46
- name: String? = null,
47
- image: String? = null,
48
- showIconMomo: Boolean = false,
49
- showIconSupport: Boolean = false,
50
- iconSupport: String = ICON_SUPPORT_DEFAULT_URL,
51
- accessibilityLabel: String? = null,
52
- ) {
53
- val theme = AppTheme.current
54
-
55
- val cornerRadius = remember(rounded, size) {
56
- if (rounded) (size.sizeDp / 2).dp else Spacing.XS
57
- }
58
- val shape = remember(cornerRadius) { RoundedCornerShape(cornerRadius) }
59
-
60
- val badgeSizeDp = remember(size) { (size.iconSizeDp / 2).dp }
61
- val badgeShape = remember(size) {
62
- RoundedCornerShape((size.iconSizeDp / 4).dp)
63
- }
64
-
65
- val shouldShowIconTop = showIconMomo && rounded
66
- val shouldShowIconBottom = showIconSupport && rounded
67
-
68
- val initials = remember(name) {
69
- name?.let { avatarInitials(it) }
70
- }
71
-
72
- val automationId = remember(accessibilityLabel, name) {
73
- accessibilityLabel ?: "Avatar${if (name != null) "/$name" else ""}"
74
- }
75
-
76
- Box(
77
- modifier = modifier
78
- .size(size.sizeDp.dp)
79
- .conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) }
80
- .setAutomationId(automationId)
81
- .semantics { contentDescription = automationId },
82
- ) {
83
- // Inner box with clip — holds avatar content
84
- Box(
85
- modifier = Modifier
86
- .fillMaxSize()
87
- .clip(shape)
88
- .background(color = Colors.pink_09)
89
- .border(width = 1.dp, color = theme.colors.border.default, shape = shape),
90
- contentAlignment = Alignment.Center,
91
- ) {
92
- when {
93
- image != null -> {
94
- Image(
95
- source = image,
96
- modifier = Modifier
97
- .fillMaxSize()
98
- .clip(shape)
99
- .semantics { contentDescription = "$automationId|img" },
100
- )
101
- }
102
-
103
- name != null -> {
104
- Text(
105
- text = initials ?: "",
106
- style = Typography.descriptionXsRegular,
107
- color = Colors.pink_03,
108
- modifier = Modifier
109
- .semantics { contentDescription = "$automationId|text" },
110
- )
111
- }
112
-
113
- else -> {
114
- Icon(
115
- source = "basic_person",
116
- size = size.iconSizeDp.dp,
117
- color = Colors.pink_03,
118
- modifier = Modifier
119
- .semantics { contentDescription = "$automationId|icon" },
120
- )
121
- }
122
- }
123
- }
124
-
125
- // Badge icons — outside clip so they are not cut by border
126
- if (shouldShowIconTop) {
127
- Image(
128
- source = LOGO_MOMO_URL,
129
- modifier = Modifier
130
- .zIndex(1f)
131
- .align(Alignment.TopEnd)
132
- .offset(x = 1.dp, y = (-1).dp)
133
- .size(badgeSizeDp)
134
- .clip(badgeShape)
135
- .semantics { contentDescription = "$automationId|top-icon" },
136
- )
137
- }
138
-
139
- if (shouldShowIconBottom) {
140
- Image(
141
- source = iconSupport,
142
- modifier = Modifier
143
- .zIndex(1f)
144
- .align(Alignment.BottomEnd)
145
- .offset(x = 1.dp, y = 1.dp)
146
- .size(badgeSizeDp)
147
- .clip(badgeShape)
148
- .semantics { contentDescription = "$automationId|bottom-icon" },
149
- )
150
- }
151
- }
152
- }
153
-
154
- private fun avatarInitials(name: String): String {
155
- val words = name.trim().split(" ").filter { it.isNotEmpty() }
156
- return words.takeLast(2).joinToString("") { it.first().uppercaseChar().toString() }
157
- }
@@ -1,82 +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.text.style.TextOverflow
15
- import androidx.compose.ui.unit.dp
16
- import vn.momo.kits.application.IsShowBaseLineDebug
17
- import vn.momo.kits.const.*
18
- import vn.momo.kits.modifier.conditional
19
-
20
-
21
- @Composable
22
- fun Badge(label: String = "Label", backgroundColor: Color? = null, modifier: Modifier = Modifier) {
23
- val primaryColors = listOf(
24
- Color(0xFFF0F0F0),
25
- Color(0xFFEB2F96),
26
- Color(0xFF962AF0),
27
- Color(0xFF4E4BFF),
28
- Color(0xFF007AFF),
29
- Color(0xFF13C2C2),
30
- Color(0xFF34C759),
31
- Color(0xFFA0D911),
32
- Color(0xFFFFCC00),
33
- Color(0xFFFA8C16),
34
- Color(0xFFFA541C),
35
- Color(0xFFF5222D)
36
- )
37
-
38
- fun isNumber(label: String): Boolean {
39
- val numberRegex = "^\\d+$".toRegex()
40
- return numberRegex.matches(label)
41
- }
42
-
43
- fun formatTitle(label: String): String {
44
- if (isNumber(label) && label.toInt() > 99) {
45
- return "99+"
46
- }
47
- return label
48
- }
49
-
50
- var badgeColor =
51
- if (isNumber(label)) {
52
- AppTheme.current.colors.error.primary
53
- } else {
54
- AppTheme.current.colors.warning.primary
55
- }
56
-
57
- if (backgroundColor != null && primaryColors.contains(backgroundColor)) {
58
- badgeColor = backgroundColor
59
- }
60
- val scaleSize = scaleSize(16f)
61
-
62
- Box(
63
- modifier = modifier
64
- .height(scaleSize.dp)
65
- .widthIn(min = scaleSize.dp)
66
- .background(color = badgeColor, shape = RoundedCornerShape(Radius.M))
67
- .border(width = 1.dp, shape = RoundedCornerShape(Radius.M), color = Colors.black_01)
68
- .conditional(IsShowBaseLineDebug) {
69
- border(1.dp, Colors.blue_03)
70
- }
71
- .padding(horizontal = Spacing.XS),
72
- contentAlignment = Alignment.Center
73
- ) {
74
- Text(
75
- text = formatTitle(label),
76
- color = Colors.black_01,
77
- style = Typography.actionXxsBold,
78
- maxLines = 1,
79
- overflow = TextOverflow.Ellipsis
80
- )
81
- }
82
- }