@momo-kits/native-kits 0.167.1-beta.4-debug → 0.167.1-duo.1

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 (155) hide show
  1. package/.claude/settings.local.json +178 -7
  2. package/CLAUDE.md +7 -0
  3. package/ios/Application/Navigation/Overplay/ModalScreen.swift +3 -0
  4. package/ios/Popup/PopupDisplay.swift +1 -0
  5. package/ios/Popup/PopupNotify.swift +8 -1
  6. package/ios/Popup/PopupPromotion.swift +3 -3
  7. package/ios/Typography/FontScale.swift +3 -3
  8. package/ios/native-kits.podspec +1 -1
  9. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  10. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +1 -0
  11. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +1 -0
  12. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +2 -2
  13. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +2 -0
  14. package/package.json +1 -1
  15. package/build.gradle.kts +0 -11
  16. package/compose/build.gradle.kts +0 -190
  17. package/compose/build.gradle.kts.backup +0 -190
  18. package/compose/compose.podspec +0 -47
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  20. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  21. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  22. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  23. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -151
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -831
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -475
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -266
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -264
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -552
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -296
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -52
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -38
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -39
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -299
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -201
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -595
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -175
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -358
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -83
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -75
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -37
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -364
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -71
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  141. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  142. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  143. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  144. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  145. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  146. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -213
  147. package/gradle/libs.versions.toml +0 -69
  148. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  149. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  150. package/gradle.properties +0 -26
  151. package/gradlew +0 -252
  152. package/gradlew.bat +0 -94
  153. package/ios-demo/README.md +0 -120
  154. package/local.properties +0 -8
  155. 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,56 +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.LaunchedEffect
6
- import androidx.compose.runtime.remember
7
- import vn.momo.kits.const.AppTheme
8
- import vn.momo.kits.const.Theme
9
- import vn.momo.kits.navigation.LocalMaxApi
10
- import vn.momo.kits.platform.ProvideOsFontScale
11
- import vn.momo.maxapi.IMaxApi
12
-
13
-
14
- @Composable
15
- fun WidgetContainer(
16
- theme: Theme? = null,
17
- miniAppContext: MiniAppContext? = null,
18
- maxApi: IMaxApi? = null,
19
- localize: Localize? = null,
20
- content: @Composable () -> Unit,
21
- ) {
22
- val parentContext = LocalContext.current
23
- val mergedContext = remember(parentContext, miniAppContext) {
24
- MiniAppContext.merge(parentContext, miniAppContext)
25
- }
26
- val resolvedTheme = theme ?: AppTheme.current
27
- val resolvedLocalize = localize ?: LocalLocalize.current
28
- val resolvedMaxApi = maxApi ?: LocalMaxApi.current
29
-
30
- LaunchedEffect(resolvedMaxApi, localize) {
31
- val api = resolvedMaxApi ?: return@LaunchedEffect
32
- val target = localize ?: return@LaunchedEffect
33
- runCatching {
34
- api.getLanguage(callback = { data ->
35
- if (parseLanguage(data) == Localize.EN) target.changeLanguage(Localize.EN)
36
- })
37
- }
38
- }
39
-
40
- ProvideOsFontScale {
41
- CompositionLocalProvider(
42
- AppTheme provides resolvedTheme,
43
- LocalContext provides mergedContext,
44
- LocalLocalize provides resolvedLocalize,
45
- LocalMaxApi provides resolvedMaxApi,
46
- ) {
47
- content()
48
- }
49
- }
50
- }
51
-
52
- private fun parseLanguage(raw: Map<String, Any?>?): String? {
53
- val code = (raw?.get("response") as? String)?.trim()?.lowercase()
54
- if (code.isNullOrEmpty()) return null
55
- return if (code.startsWith(Localize.EN)) Localize.EN else Localize.VI
56
- }
@@ -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
- }