@momo-kits/native-kits 0.157.2-debug → 0.157.2

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 (117) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -180
  4. package/compose/build.gradle.kts.backup +0 -180
  5. package/compose/compose.podspec +0 -54
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -110
  7. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -57
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -107
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -201
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -222
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -48
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -305
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -720
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -121
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -405
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -85
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -340
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -198
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -94
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -136
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -543
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -148
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -188
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -116
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -448
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -172
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -255
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -231
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -233
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -254
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -241
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -364
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -92
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -352
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -103
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -70
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -17
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -96
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -96
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -92
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -130
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -214
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -576
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -177
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -205
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -239
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -191
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -306
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -13
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -185
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -285
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -2
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -35
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -2
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -59
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -68
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -14
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -50
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -239
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -119
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -98
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -161
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -331
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -497
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -162
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -243
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -187
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -279
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -80
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -306
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -32
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -370
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -42
  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/Tracking.kt +0 -15
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -88
  110. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -149
  111. package/gradle/libs.versions.toml +0 -57
  112. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  113. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  114. package/gradle.properties +0 -26
  115. package/gradlew +0 -252
  116. package/gradlew.bat +0 -94
  117. package/settings.gradle.kts +0 -52
@@ -1,243 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.animation.core.FastOutSlowInEasing
4
- import androidx.compose.animation.core.animateDpAsState
5
- import androidx.compose.animation.core.tween
6
- import androidx.compose.foundation.background
7
- import androidx.compose.foundation.border
8
- import androidx.compose.foundation.layout.Arrangement
9
- import androidx.compose.foundation.layout.Box
10
- import androidx.compose.foundation.layout.Column
11
- import androidx.compose.foundation.layout.Row
12
- import androidx.compose.foundation.layout.RowScope
13
- import androidx.compose.foundation.layout.Spacer
14
- import androidx.compose.foundation.layout.fillMaxSize
15
- import androidx.compose.foundation.layout.fillMaxWidth
16
- import androidx.compose.foundation.layout.height
17
- import androidx.compose.foundation.layout.offset
18
- import androidx.compose.foundation.layout.padding
19
- import androidx.compose.foundation.layout.size
20
- import androidx.compose.foundation.layout.width
21
- import androidx.compose.foundation.shape.CircleShape
22
- import androidx.compose.foundation.shape.RoundedCornerShape
23
- import androidx.compose.runtime.Composable
24
- import androidx.compose.runtime.getValue
25
- import androidx.compose.ui.Alignment
26
- import androidx.compose.ui.Modifier
27
- import androidx.compose.ui.draw.clip
28
- import androidx.compose.ui.graphics.Brush
29
- import androidx.compose.ui.graphics.Color
30
- import androidx.compose.ui.text.style.TextAlign
31
- import androidx.compose.ui.text.style.TextOverflow
32
- import androidx.compose.ui.unit.dp
33
- import androidx.navigation.NavController
34
- import androidx.navigation.compose.currentBackStackEntryAsState
35
- import vn.momo.kits.components.Badge
36
- import vn.momo.kits.components.Icon
37
- import vn.momo.kits.components.Text
38
- import vn.momo.kits.const.AppTheme
39
- import vn.momo.kits.const.Colors
40
- import vn.momo.kits.const.Radius
41
- import vn.momo.kits.const.Spacing
42
- import vn.momo.kits.application.IsShowBaseLineDebug
43
- import vn.momo.kits.components.BadgeDot
44
- import vn.momo.kits.components.DotSize
45
- import vn.momo.kits.const.Typography
46
- import vn.momo.kits.modifier.conditional
47
- import vn.momo.kits.modifier.noFeedbackClickable
48
- import vn.momo.kits.platform.getScreenDimensions
49
-
50
- val floatingButtonWidth = 75.dp
51
- const val BOTTOM_TAB_BAR_HEIGHT = 64
52
-
53
- @Composable
54
- fun BottomTabBar(
55
- items: List<BottomTabItem>,
56
- floatingButton: BottomTabFloatingButton? = null,
57
- navController: NavController,
58
- onTabSelected: (Int) -> Unit,
59
- ) {
60
- val currentRoute = navController.currentBackStackEntryAsState().value?.destination?.route
61
- val selectedIndex = items.indexOfFirst { "option${items.indexOf(it)}" == currentRoute }
62
-
63
- val screenWidth = getScreenDimensions().width.dp
64
- val mid = items.size / 2
65
-
66
- val tabWidth = if (floatingButton != null) {
67
- (screenWidth - floatingButtonWidth) / items.size
68
- } else {
69
- screenWidth / items.size
70
- }
71
- val adjustSize = if(floatingButton != null && selectedIndex >= mid) floatingButtonWidth else 0.dp
72
- val targetOffset = tabWidth * selectedIndex + tabWidth / 2 - screenWidth / 2 + adjustSize
73
-
74
- val indicatorOffsetX by animateDpAsState(
75
- targetValue = targetOffset,
76
- animationSpec = tween(durationMillis = 250, easing = FastOutSlowInEasing),
77
- label = "IndicatorX"
78
- )
79
-
80
- Box(
81
- contentAlignment = Alignment.BottomCenter
82
- ) {
83
- Row(
84
- modifier = Modifier
85
- .fillMaxWidth()
86
- .height(BOTTOM_TAB_BAR_HEIGHT.dp)
87
- .background(AppTheme.current.colors.background.surface)
88
- .conditional(IsShowBaseLineDebug) {
89
- border(1.dp, Colors.blue_03)
90
- },
91
- horizontalArrangement = Arrangement.SpaceAround,
92
- ) {
93
- if (floatingButton == null) {
94
- renderTabBarItem(items, 0, items.size, selectedIndex, onTabSelected)
95
- } else {
96
- renderTabBarItem(items, 0, mid, selectedIndex, onTabSelected)
97
- Spacer(modifier = Modifier.width(floatingButtonWidth).padding(horizontal = Spacing.XXS))
98
- renderTabBarItem(items, mid, items.size, selectedIndex, onTabSelected)
99
- }
100
- }
101
-
102
- Box(modifier = Modifier
103
- .offset(x = indicatorOffsetX, y = (-BOTTOM_TAB_BAR_HEIGHT + 2).dp)
104
- .height(2.dp)
105
- .width(44.dp)
106
- .background(
107
- color = AppTheme.current.colors.primary ,
108
- shape = RoundedCornerShape(bottomStart = 2.dp, bottomEnd = 2.dp)
109
- )
110
- )
111
-
112
- Box(modifier = Modifier
113
- .fillMaxWidth()
114
- .height(6.dp)
115
- .offset(x = 0.dp, y = (-BOTTOM_TAB_BAR_HEIGHT).dp)
116
- .background(
117
- brush = Brush.verticalGradient(
118
- colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
119
- )
120
- )
121
- )
122
- floatingButton?.let { FloatingButton(it) }
123
- }
124
- }
125
-
126
- @Composable
127
- fun RowScope.renderTabBarItem(
128
- items: List<BottomTabItem>,
129
- fromIndex: Int,
130
- toIndex: Int,
131
- selectedIndex: Int,
132
- onTabSelected: (Int) -> Unit
133
- ){
134
- for (index in fromIndex until toIndex) {
135
- Box(modifier = Modifier.weight(1f)) {
136
- TabBarItem(
137
- item = items[index],
138
- selected = index == selectedIndex,
139
- onClick = { onTabSelected(index) }
140
- )
141
- }
142
- }
143
- }
144
-
145
- @Composable
146
- fun TabBarItem(item: BottomTabItem, selected: Boolean, onClick: () -> Unit) {
147
- fun isNumber(label: String): Boolean {
148
- val numberRegex = "^\\d+$".toRegex()
149
- return numberRegex.matches(label)
150
- }
151
- fun formatLabel(label: String): String? {
152
- if (isNumber(label) && label.toInt() == 0) {
153
- return null
154
- }
155
- return label
156
- }
157
- val badgeLabel = item.badgeLabel?.let { formatLabel(it) }
158
-
159
- Box(modifier = Modifier
160
- .fillMaxSize()
161
- .padding(horizontal = Spacing.XXS)
162
- .conditional(IsShowBaseLineDebug) {
163
- border(1.dp, Colors.blue_03)
164
- }
165
- .noFeedbackClickable {
166
- onClick()
167
- },
168
- contentAlignment = Alignment.BottomStart
169
- ){
170
- Column(
171
- modifier = Modifier
172
- .fillMaxSize()
173
- .padding(horizontal = Spacing.S, vertical = Spacing.S)
174
- .noFeedbackClickable {
175
- onClick()
176
- },
177
- horizontalAlignment = Alignment.CenterHorizontally,
178
- verticalArrangement = Arrangement.Center
179
- ) {
180
- Icon(
181
- source = item.icon,
182
- size = 28.dp,
183
- modifier = Modifier.padding(Spacing.XS),
184
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint)
185
- Text(
186
- text = item.label,
187
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint,
188
- style = if (selected) Typography.labelXsMedium else Typography.descriptionXsRegular,
189
- maxLines = 1,
190
- overflow = TextOverflow.Ellipsis
191
- )
192
- }
193
- if (badgeLabel != null) {
194
- if (badgeLabel.isEmpty())
195
- BadgeDot(
196
- size = DotSize.Small,
197
- modifier = Modifier.offset(x = 50.dp, y = (-48).dp)
198
- )
199
- else
200
- Badge(badgeLabel, modifier = Modifier.offset(x = 44.dp, y = (-42).dp))
201
- }
202
- }
203
- }
204
-
205
- @Composable
206
- fun FloatingButton(data: BottomTabFloatingButton) {
207
- Column(
208
- modifier = Modifier
209
- .width(floatingButtonWidth)
210
- .padding(horizontal = Spacing.XXS, vertical = Spacing.S)
211
- .conditional(IsShowBaseLineDebug) {
212
- border(1.dp, Colors.blue_03)
213
- }
214
- .noFeedbackClickable {
215
- data.onPress()
216
- },
217
- verticalArrangement = Arrangement.Bottom,
218
- horizontalAlignment = Alignment.CenterHorizontally
219
-
220
- ){
221
- CurvedContainer()
222
- Box(
223
- modifier = Modifier
224
- .size(48.dp)
225
- .clip(CircleShape)
226
- .background(AppTheme.current.colors.primary),
227
- contentAlignment = Alignment.Center
228
- ) {
229
- Icon(source = data.icon, color = Color.White, size = 28.dp)
230
- }
231
- Spacer(modifier = Modifier.height(4.dp))
232
- Text(
233
- text = data.label,
234
- style = Typography.labelXsMedium,
235
- color = Colors.black_01,
236
- textAlign = TextAlign.Center,
237
- modifier = Modifier
238
- .height(14.dp)
239
- .fillMaxWidth()
240
- .background(AppTheme.current.colors.primary, shape = RoundedCornerShape(size = Radius.XL))
241
- )
242
- }
243
- }
@@ -1,86 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.foundation.Canvas
4
- import androidx.compose.foundation.layout.Box
5
- import androidx.compose.foundation.layout.height
6
- import androidx.compose.foundation.layout.offset
7
- import androidx.compose.foundation.layout.width
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Alignment
10
- import androidx.compose.ui.Modifier
11
- import androidx.compose.ui.graphics.Path
12
- import androidx.compose.ui.platform.LocalDensity
13
- import androidx.compose.ui.unit.Dp
14
- import androidx.compose.ui.unit.IntOffset
15
- import androidx.compose.ui.unit.dp
16
- import androidx.compose.ui.zIndex
17
- import vn.momo.kits.const.AppTheme
18
-
19
- @Composable
20
- fun CurvedContainer(
21
- circleSize: Dp = 48.dp,
22
- tabBarItemIconSize: Dp = 28.dp,
23
- circleOverSize: Dp = 2.dp,
24
- width: Dp = 71.dp,
25
- height: Dp = 16.dp
26
- ) {
27
- val theme = AppTheme.current
28
- val density = LocalDensity.current
29
- val widthPx = with(density) { width.toPx()}
30
-
31
- val circleSizePx = with(density) { circleSize.toPx() }
32
- val tabBarItemIconSizePx = with(density) { tabBarItemIconSize.toPx() }
33
- val circleOverSizePx = with(density) { circleOverSize.toPx() }
34
-
35
- val circlePositionTop = circleSizePx - tabBarItemIconSizePx - 10f
36
- val circleOverTop = circlePositionTop + circleOverSizePx
37
- val circleR = circleSizePx / 2
38
- val circleOverR = circleR + circleOverSizePx
39
-
40
- val centerX = widthPx / 2
41
-
42
- val curvedPath = getPath(
43
- circleOverTop = circleOverTop,
44
- centerX = centerX,
45
- circleOverR = circleOverR,
46
- widthPx = widthPx
47
- )
48
-
49
- Box(
50
- contentAlignment = Alignment.BottomCenter
51
- ){
52
- Canvas(
53
- modifier = Modifier
54
- .width(width)
55
- .height(height)
56
- .offset{ IntOffset(x = 0, y = 24) }
57
- .zIndex(-1f)
58
- ) {
59
- drawPath(path = curvedPath, color = theme.colors.background.surface)
60
- }
61
- }
62
- }
63
-
64
- private fun getPath(circleOverTop: Float, centerX: Float, circleOverR: Float, widthPx: Float): Path{
65
- return Path().apply {
66
- moveTo(0f, circleOverTop)
67
- lineTo(centerX - circleOverR - 40f, circleOverTop)
68
-
69
- cubicTo(
70
- centerX - circleOverR, circleOverTop,
71
- centerX - circleOverR, 0f,
72
- centerX, 0f
73
- )
74
-
75
- cubicTo(
76
- centerX + circleOverR, 0f,
77
- centerX + circleOverR, circleOverTop,
78
- centerX + circleOverR + 40f, circleOverTop
79
- )
80
-
81
- lineTo(widthPx, circleOverTop)
82
- lineTo(widthPx, 60f)
83
- lineTo(0f, 60f)
84
- close()
85
- }
86
- }
@@ -1,187 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.animation.AnimatedVisibility
4
- import androidx.compose.animation.core.CubicBezierEasing
5
- import androidx.compose.animation.core.LinearEasing
6
- import androidx.compose.animation.core.animateDpAsState
7
- import androidx.compose.animation.core.tween
8
- import androidx.compose.animation.expandHorizontally
9
- import androidx.compose.animation.fadeIn
10
- import androidx.compose.animation.fadeOut
11
- import androidx.compose.animation.shrinkHorizontally
12
- import androidx.compose.foundation.ScrollState
13
- import androidx.compose.foundation.background
14
- import androidx.compose.foundation.border
15
- import androidx.compose.foundation.interaction.MutableInteractionSource
16
- import androidx.compose.foundation.layout.Arrangement
17
- import androidx.compose.foundation.layout.Box
18
- import androidx.compose.foundation.layout.Row
19
- import androidx.compose.foundation.layout.Spacer
20
- import androidx.compose.foundation.layout.fillMaxSize
21
- import androidx.compose.foundation.layout.height
22
- import androidx.compose.foundation.layout.offset
23
- import androidx.compose.foundation.layout.padding
24
- import androidx.compose.foundation.layout.sizeIn
25
- import androidx.compose.foundation.layout.width
26
- import androidx.compose.material3.AlertDialogDefaults
27
- import androidx.compose.material3.FloatingActionButton
28
- import androidx.compose.material3.FloatingActionButtonDefaults
29
- import androidx.compose.material3.FloatingActionButtonElevation
30
- import androidx.compose.runtime.Composable
31
- import androidx.compose.runtime.LaunchedEffect
32
- import androidx.compose.runtime.getValue
33
- import androidx.compose.runtime.mutableStateOf
34
- import androidx.compose.runtime.remember
35
- import androidx.compose.runtime.rememberCoroutineScope
36
- import androidx.compose.runtime.saveable.rememberSaveable
37
- import androidx.compose.runtime.setValue
38
- import androidx.compose.ui.Alignment
39
- import androidx.compose.ui.Modifier
40
- import androidx.compose.ui.graphics.Color
41
- import androidx.compose.ui.unit.Dp
42
- import androidx.compose.ui.unit.dp
43
- import kotlinx.coroutines.delay
44
- import kotlinx.coroutines.flow.MutableStateFlow
45
- import kotlinx.coroutines.flow.collectLatest
46
- import kotlinx.coroutines.launch
47
- import vn.momo.kits.application.IsShowBaseLineDebug
48
- import vn.momo.kits.components.Icon
49
- import vn.momo.kits.components.Text
50
- import vn.momo.kits.const.Colors
51
- import vn.momo.kits.const.Typography
52
- import vn.momo.kits.modifier.conditional
53
-
54
- enum class FABSize { SMALL, DEFAULT }
55
- enum class FABPosition { END, CENTER }
56
-
57
- data class FloatingButtonProps(
58
- val icon: String,
59
- val iconColor: Color? = null,
60
- val label: String? = null,
61
- val onClick: () -> Unit,
62
- val size: FABSize = FABSize.DEFAULT,
63
- val bottom: Dp? = null,
64
- val scrollState: ScrollState? = null,
65
- val position: FABPosition? = FABPosition.END,
66
- )
67
-
68
- private val FabSmallSize = 36.dp
69
- private val FabDefaultSize = 48.dp
70
- private val FabExpandedWidth = 80.dp
71
- private val FabIconSizeSmall = 12.dp
72
- private val FabIconSizeDefault = 24.dp
73
- private val FabPaddingHorizontal = 12.dp
74
-
75
- @Composable
76
- fun FloatingButton(
77
- scrollPosition: Int,
78
- bottom: Dp,
79
- onClick: () -> Unit,
80
- containerColor: Color,
81
- contentColor: Color = containerColor,
82
- icon: String,
83
- iconColor: Color? = null,
84
- text: String? = null,
85
- elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(4.dp),
86
- size: FABSize = FABSize.DEFAULT,
87
- position: FABPosition = FABPosition.END,
88
- keyboardSize: Dp = 0.dp,
89
- ) {
90
- val scrollStateFlow = remember { MutableStateFlow(scrollPosition) }
91
- var lastScrollPosition by rememberSaveable { mutableStateOf(0) }
92
- var isExpanded by rememberSaveable { mutableStateOf(false) }
93
-
94
- val coroutineScope = rememberCoroutineScope()
95
-
96
- // Animations
97
- val baseSize = if (size == FABSize.SMALL) FabSmallSize else FabDefaultSize
98
- val width by animateDpAsState(
99
- targetValue = if (isExpanded && text != null) FabExpandedWidth else baseSize,
100
- animationSpec = tween(100, easing = CubicBezierEasing(0.2f, 0.2f, 0.2f, 0.2f))
101
- )
102
-
103
- // Scroll listener
104
- LaunchedEffect(text) {
105
- if (text != null) {
106
- coroutineScope.launch {
107
- scrollStateFlow.collectLatest { newScroll ->
108
- isExpanded = newScroll <= lastScrollPosition
109
- delay(100)
110
- lastScrollPosition = newScroll
111
- }
112
- }
113
- }
114
- }
115
-
116
- LaunchedEffect(scrollPosition) {
117
- scrollStateFlow.value = scrollPosition
118
- }
119
-
120
- Box(
121
- modifier = Modifier
122
- .fillMaxSize()
123
- .padding(end = 12.dp, bottom = bottom)
124
- .offset(y = -keyboardSize)
125
- .background(Color.Transparent),
126
- contentAlignment = if (position == FABPosition.END) Alignment.BottomEnd else Alignment.BottomCenter,
127
- ) {
128
- FloatingActionButton(
129
- onClick = onClick,
130
- shape = AlertDialogDefaults.shape,
131
- containerColor = containerColor,
132
- contentColor = contentColor,
133
- elevation = elevation,
134
- interactionSource = remember { MutableInteractionSource() },
135
- modifier = Modifier
136
- .sizeIn(minWidth = width)
137
- .height(baseSize)
138
- .conditional(IsShowBaseLineDebug) {
139
- border(1.dp, Colors.blue_03)
140
- }
141
- ) {
142
- Row(
143
- modifier = Modifier.padding(
144
- start = if (isExpanded) FabPaddingHorizontal else 0.dp,
145
- end = if (isExpanded) FabPaddingHorizontal else 0.dp,
146
- ),
147
- verticalAlignment = Alignment.CenterVertically,
148
- horizontalArrangement = if (isExpanded) Arrangement.Start else Arrangement.Center
149
- ) {
150
- Icon(
151
- source = icon,
152
- size = if (size == FABSize.SMALL) FabIconSizeSmall else FabIconSizeDefault,
153
- color = iconColor ?: Color.White
154
- )
155
-
156
- AnimatedVisibility(
157
- visible = isExpanded,
158
- enter = fadeInExpandAnimation,
159
- exit = fadeOutShrinkAnimation,
160
- ) {
161
- Row {
162
- Spacer(Modifier.width(12.dp))
163
- Text(
164
- text = text ?: "",
165
- color = Color.White,
166
- style = Typography.actionDefaultBold
167
- )
168
- }
169
- }
170
- }
171
- }
172
- }
173
- }
174
-
175
- private val fadeOutShrinkAnimation = fadeOut(
176
- animationSpec = tween(100, easing = LinearEasing)
177
- ) + shrinkHorizontally(
178
- animationSpec = tween(100, easing = LinearEasing),
179
- shrinkTowards = Alignment.Start
180
- )
181
-
182
- private val fadeInExpandAnimation = fadeIn(
183
- animationSpec = tween(100, easing = LinearEasing)
184
- ) + expandHorizontally(
185
- animationSpec = tween(100, easing = LinearEasing),
186
- expandFrom = Alignment.Start
187
- )