@momo-kits/native-kits 0.163.1-sp.2-debug → 0.163.1-sp.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 (143) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -190
  4. package/compose/build.gradle.kts.backup +0 -190
  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/OsFontScale.android.kt +0 -7
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -150
  9. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  22. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -106
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -826
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -23
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -112
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -477
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -214
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -216
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -259
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -182
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -328
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -97
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -217
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -470
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -131
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -203
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -175
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -276
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -52
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -36
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -39
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -252
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -100
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -172
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -360
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -581
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -156
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -320
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -81
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -34
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -360
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -69
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -105
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -207
  135. package/gradle/libs.versions.toml +0 -69
  136. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  137. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  138. package/gradle.properties +0 -26
  139. package/gradlew +0 -252
  140. package/gradlew.bat +0 -94
  141. package/ios-demo/README.md +0 -120
  142. package/local.properties +0 -8
  143. package/settings.gradle.kts +0 -64
@@ -1,156 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.animation.core.tween
4
- import androidx.compose.animation.fadeIn
5
- import androidx.compose.animation.fadeOut
6
- import androidx.compose.animation.scaleIn
7
- import androidx.compose.animation.scaleOut
8
- import androidx.compose.foundation.background
9
- import androidx.compose.foundation.layout.*
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.runtime.LaunchedEffect
12
- import androidx.compose.ui.Alignment
13
- import androidx.compose.ui.Modifier
14
- import androidx.compose.ui.unit.dp
15
- import androidx.navigation.compose.NavHost
16
- import androidx.navigation.compose.composable
17
- import androidx.navigation.compose.rememberNavController
18
- import vn.momo.kits.const.AppNavigationBar
19
- import vn.momo.kits.const.AppTheme
20
- import vn.momo.kits.const.Spacing
21
- import vn.momo.kits.navigation.KeyboardOptions
22
- import vn.momo.kits.navigation.LocalNavigation
23
- import vn.momo.kits.navigation.LocalNavigator
24
- import vn.momo.kits.navigation.NavigationOptions
25
- import vn.momo.kits.navigation.StackScreen
26
- import vn.momo.kits.navigation.component.HeaderType
27
-
28
- private var bottomTabOptionItems : MutableList<NavigationOptions?> = mutableListOf()
29
- internal fun setBottomTabOption(index: Int, options: NavigationOptions){
30
- if (index in bottomTabOptionItems.indices) {
31
- bottomTabOptionItems[index] = options
32
- }
33
- }
34
- internal fun getBottomTabOption(index: Int): NavigationOptions? {
35
- return if (index in bottomTabOptionItems.indices) {
36
- bottomTabOptionItems[index]
37
- } else null
38
- }
39
-
40
- @Composable
41
- fun BottomTab(
42
- items: List<BottomTabItem>,
43
- floatingButton: BottomTabFloatingButton? = null
44
- ) {
45
- val navigation = LocalNavigation.current
46
- val navigator = LocalNavigator.current
47
- val navController = rememberNavController()
48
-
49
- bottomTabOptionItems = items.mapIndexed { index, item ->
50
- item.options ?: NavigationOptions()
51
- }.toMutableList()
52
-
53
-
54
- LaunchedEffect(Unit){
55
- navigation.markAsBottomTabRoot()
56
- navigation.setOptions(
57
- headerType = HeaderType.None,
58
- keyboardOptions = KeyboardOptions(useAvoidKeyboard = false)
59
- )
60
- }
61
-
62
- Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) {
63
- Box(modifier = Modifier
64
- .fillMaxSize()
65
- ) {
66
- NavHost(
67
- navController = navController,
68
- startDestination = "option0"
69
- ) {
70
- items.forEachIndexed { index, item ->
71
- composable(
72
- route = "option$index",
73
- enterTransition = {
74
- fadeIn(animationSpec = tween(200)) +
75
- scaleIn(
76
- initialScale = 0.97f,
77
- animationSpec = tween(200)
78
- )
79
- },
80
- exitTransition = {
81
- fadeOut(animationSpec = tween(200)) +
82
- scaleOut(
83
- targetScale = 0.97f,
84
- animationSpec = tween(200)
85
- )
86
- },
87
- popEnterTransition = {
88
- fadeIn(animationSpec = tween(200)) +
89
- scaleIn(
90
- initialScale = 0.97f,
91
- animationSpec = tween(200)
92
- )
93
- },
94
- popExitTransition = {
95
- fadeOut(animationSpec = tween(200)) +
96
- scaleOut(
97
- targetScale = 0.97f,
98
- animationSpec = tween(200)
99
- )
100
- }
101
- ) {
102
- val option = getBottomTabOption(index)
103
-
104
- StackScreen(
105
- content = item.screen,
106
- navigationOptions = option,
107
- bottomTabIndex = index,
108
- onBackHandler = {
109
- if (index != 0) {
110
- navController.popBackStack(
111
- navController.graph.startDestinationRoute!!,
112
- inclusive = false
113
- )
114
- } else {
115
- navigator.pop()
116
- }
117
- }
118
- )
119
- }
120
- }
121
- }
122
- }
123
- Column {
124
- BottomTabBar(
125
- items = items,
126
- floatingButton = floatingButton,
127
- navController = navController,
128
- onTabSelected = {
129
- val currentRoute = navController.currentBackStackEntry?.destination?.route
130
- val targetRoute = "option$it"
131
- if (currentRoute != targetRoute) {
132
- navController.navigate(targetRoute)
133
- }
134
- }
135
- )
136
- Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
137
- }
138
- }
139
- }
140
-
141
- data class BottomTabItem(
142
- val name: String,
143
- val label: String,
144
- val icon: String,
145
- val showDot: Boolean = false,
146
- val badgeLabel: String? = null,
147
- val screen: @Composable () -> Unit,
148
- val options: NavigationOptions? = null,
149
- val initialParams: Any? = null
150
- )
151
-
152
- data class BottomTabFloatingButton(
153
- val icon: String,
154
- val label: String,
155
- val onPress: () -> Unit,
156
- )
@@ -1,225 +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.*
9
- import androidx.compose.foundation.shape.CircleShape
10
- import androidx.compose.foundation.shape.RoundedCornerShape
11
- import androidx.compose.runtime.Composable
12
- import androidx.compose.runtime.getValue
13
- import androidx.compose.ui.Alignment
14
- import androidx.compose.ui.Modifier
15
- import androidx.compose.ui.draw.clip
16
- import androidx.compose.ui.graphics.Brush
17
- import androidx.compose.ui.graphics.Color
18
- import androidx.compose.ui.text.style.TextAlign
19
- import androidx.compose.ui.text.style.TextOverflow
20
- import androidx.compose.ui.unit.dp
21
- import androidx.navigation.NavController
22
- import androidx.navigation.compose.currentBackStackEntryAsState
23
- import vn.momo.kits.application.IsShowBaseLineDebug
24
- import vn.momo.kits.components.*
25
- import vn.momo.kits.const.*
26
- import vn.momo.kits.modifier.InternalApi
27
- import vn.momo.kits.modifier.conditional
28
- import vn.momo.kits.modifier.noFeedbackClickable
29
- import vn.momo.kits.platform.getScreenDimensions
30
-
31
- internal val floatingButtonWidth = 75.dp
32
- @InternalApi
33
- const val BOTTOM_TAB_BAR_HEIGHT = 64
34
-
35
- @Composable
36
- internal fun BottomTabBar(
37
- items: List<BottomTabItem>,
38
- floatingButton: BottomTabFloatingButton? = null,
39
- navController: NavController,
40
- onTabSelected: (Int) -> Unit,
41
- ) {
42
- val currentRoute = navController.currentBackStackEntryAsState().value?.destination?.route
43
- val selectedIndex = items.indexOfFirst { "option${items.indexOf(it)}" == currentRoute }
44
-
45
- val screenWidth = getScreenDimensions().width.dp
46
- val mid = items.size / 2
47
-
48
- val tabWidth = if (floatingButton != null) {
49
- (screenWidth - floatingButtonWidth) / items.size
50
- } else {
51
- screenWidth / items.size
52
- }
53
- val adjustSize = if(floatingButton != null && selectedIndex >= mid) floatingButtonWidth else 0.dp
54
- val targetOffset = tabWidth * selectedIndex + tabWidth / 2 - screenWidth / 2 + adjustSize
55
-
56
- val indicatorOffsetX by animateDpAsState(
57
- targetValue = targetOffset,
58
- animationSpec = tween(durationMillis = 250, easing = FastOutSlowInEasing),
59
- label = "IndicatorX"
60
- )
61
-
62
- Box(
63
- contentAlignment = Alignment.BottomCenter
64
- ) {
65
- Row(
66
- modifier = Modifier
67
- .fillMaxWidth()
68
- .height(BOTTOM_TAB_BAR_HEIGHT.dp)
69
- .background(AppTheme.current.colors.background.surface)
70
- .conditional(IsShowBaseLineDebug) {
71
- border(1.dp, Colors.blue_03)
72
- },
73
- horizontalArrangement = Arrangement.SpaceAround,
74
- ) {
75
- if (floatingButton == null) {
76
- RenderTabBarItem(items, 0, items.size, selectedIndex, onTabSelected)
77
- } else {
78
- RenderTabBarItem(items, 0, mid, selectedIndex, onTabSelected)
79
- Spacer(modifier = Modifier.width(floatingButtonWidth).padding(horizontal = Spacing.XXS))
80
- RenderTabBarItem(items, mid, items.size, selectedIndex, onTabSelected)
81
- }
82
- }
83
-
84
- Box(modifier = Modifier
85
- .offset(x = indicatorOffsetX, y = (-BOTTOM_TAB_BAR_HEIGHT + 2).dp)
86
- .height(2.dp)
87
- .width(44.dp)
88
- .background(
89
- color = AppTheme.current.colors.primary ,
90
- shape = RoundedCornerShape(bottomStart = 2.dp, bottomEnd = 2.dp)
91
- )
92
- )
93
-
94
- Box(modifier = Modifier
95
- .fillMaxWidth()
96
- .height(6.dp)
97
- .offset(x = 0.dp, y = (-BOTTOM_TAB_BAR_HEIGHT).dp)
98
- .background(
99
- brush = Brush.verticalGradient(
100
- colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
101
- )
102
- )
103
- )
104
- floatingButton?.let { FloatingButton(it) }
105
- }
106
- }
107
-
108
- @Composable
109
- internal fun RowScope.RenderTabBarItem(
110
- items: List<BottomTabItem>,
111
- fromIndex: Int,
112
- toIndex: Int,
113
- selectedIndex: Int,
114
- onTabSelected: (Int) -> Unit
115
- ){
116
- for (index in fromIndex until toIndex) {
117
- Box(modifier = Modifier.weight(1f)) {
118
- TabBarItem(
119
- item = items[index],
120
- selected = index == selectedIndex,
121
- onClick = { onTabSelected(index) }
122
- )
123
- }
124
- }
125
- }
126
-
127
- @Composable
128
- internal fun TabBarItem(item: BottomTabItem, selected: Boolean, onClick: () -> Unit) {
129
- fun isNumber(label: String): Boolean {
130
- val numberRegex = "^\\d+$".toRegex()
131
- return numberRegex.matches(label)
132
- }
133
- fun formatLabel(label: String): String? {
134
- if (isNumber(label) && label.toInt() == 0) {
135
- return null
136
- }
137
- return label
138
- }
139
- val badgeLabel = item.badgeLabel?.let { formatLabel(it) }
140
-
141
- Box(modifier = Modifier
142
- .fillMaxSize()
143
- .padding(horizontal = Spacing.XXS)
144
- .conditional(IsShowBaseLineDebug) {
145
- border(1.dp, Colors.blue_03)
146
- }
147
- .noFeedbackClickable {
148
- onClick()
149
- },
150
- contentAlignment = Alignment.BottomStart
151
- ){
152
- Column(
153
- modifier = Modifier
154
- .fillMaxSize()
155
- .padding(horizontal = Spacing.S, vertical = Spacing.S)
156
- .noFeedbackClickable {
157
- onClick()
158
- },
159
- horizontalAlignment = Alignment.CenterHorizontally,
160
- verticalArrangement = Arrangement.Center
161
- ) {
162
- Icon(
163
- source = item.icon,
164
- size = 28.dp,
165
- modifier = Modifier.padding(Spacing.XS),
166
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint)
167
- Text(
168
- text = item.label,
169
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint,
170
- style = if (selected) Typography.labelXsMedium else Typography.descriptionXsRegular,
171
- maxLines = 1,
172
- overflow = TextOverflow.Ellipsis
173
- )
174
- }
175
- if (badgeLabel != null) {
176
- if (badgeLabel.isEmpty())
177
- BadgeDot(
178
- size = DotSize.Small,
179
- modifier = Modifier.offset(x = 50.dp, y = (-48).dp)
180
- )
181
- else
182
- Badge(badgeLabel, modifier = Modifier.offset(x = 44.dp, y = (-42).dp))
183
- }
184
- }
185
- }
186
-
187
- @Composable
188
- internal fun FloatingButton(data: BottomTabFloatingButton) {
189
- Column(
190
- modifier = Modifier
191
- .width(floatingButtonWidth)
192
- .padding(horizontal = Spacing.XXS, vertical = Spacing.S)
193
- .conditional(IsShowBaseLineDebug) {
194
- border(1.dp, Colors.blue_03)
195
- }
196
- .noFeedbackClickable {
197
- data.onPress()
198
- },
199
- verticalArrangement = Arrangement.Bottom,
200
- horizontalAlignment = Alignment.CenterHorizontally
201
-
202
- ){
203
- CurvedContainer()
204
- Box(
205
- modifier = Modifier
206
- .size(48.dp)
207
- .clip(CircleShape)
208
- .background(AppTheme.current.colors.primary),
209
- contentAlignment = Alignment.Center
210
- ) {
211
- Icon(source = data.icon, color = Color.White, size = 28.dp)
212
- }
213
- Spacer(modifier = Modifier.height(4.dp))
214
- Text(
215
- text = data.label,
216
- style = Typography.labelXsMedium,
217
- color = Colors.black_01,
218
- textAlign = TextAlign.Center,
219
- modifier = Modifier
220
- .height(14.dp)
221
- .fillMaxWidth()
222
- .background(AppTheme.current.colors.primary, shape = RoundedCornerShape(size = Radius.XL))
223
- )
224
- }
225
- }
@@ -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
- internal 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,169 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.animation.*
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.foundation.ScrollState
9
- import androidx.compose.foundation.background
10
- import androidx.compose.foundation.border
11
- import androidx.compose.foundation.interaction.MutableInteractionSource
12
- import androidx.compose.foundation.layout.*
13
- import androidx.compose.material3.AlertDialogDefaults
14
- import androidx.compose.material3.FloatingActionButton
15
- import androidx.compose.material3.FloatingActionButtonDefaults
16
- import androidx.compose.material3.FloatingActionButtonElevation
17
- import androidx.compose.runtime.*
18
- import androidx.compose.runtime.saveable.rememberSaveable
19
- import androidx.compose.ui.Alignment
20
- import androidx.compose.ui.Modifier
21
- import androidx.compose.ui.graphics.Color
22
- import androidx.compose.ui.unit.Dp
23
- import androidx.compose.ui.unit.dp
24
- import kotlinx.coroutines.delay
25
- import kotlinx.coroutines.flow.MutableStateFlow
26
- import kotlinx.coroutines.flow.collectLatest
27
- import kotlinx.coroutines.launch
28
- import vn.momo.kits.application.IsShowBaseLineDebug
29
- import vn.momo.kits.components.Icon
30
- import vn.momo.kits.components.Text
31
- import vn.momo.kits.const.Colors
32
- import vn.momo.kits.const.Typography
33
- import vn.momo.kits.modifier.conditional
34
- import kotlin.time.Duration.Companion.milliseconds
35
-
36
- enum class FABSize { SMALL, DEFAULT }
37
- enum class FABPosition { END, CENTER }
38
-
39
- data class FloatingButtonProps(
40
- val icon: String,
41
- val iconColor: Color? = null,
42
- val label: String? = null,
43
- val onClick: () -> Unit,
44
- val size: FABSize = FABSize.DEFAULT,
45
- val bottom: Dp? = null,
46
- val scrollState: ScrollState? = null,
47
- val position: FABPosition? = FABPosition.END,
48
- )
49
-
50
- private val FabSmallSize = 36.dp
51
- private val FabDefaultSize = 48.dp
52
- private val FabExpandedWidth = 80.dp
53
- private val FabIconSizeSmall = 12.dp
54
- private val FabIconSizeDefault = 24.dp
55
- private val FabPaddingHorizontal = 12.dp
56
-
57
- @Composable
58
- internal fun FloatingButton(
59
- scrollPosition: Int,
60
- bottom: Dp,
61
- onClick: () -> Unit,
62
- containerColor: Color,
63
- contentColor: Color = containerColor,
64
- icon: String,
65
- iconColor: Color? = null,
66
- text: String? = null,
67
- elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(4.dp),
68
- size: FABSize = FABSize.DEFAULT,
69
- position: FABPosition = FABPosition.END,
70
- keyboardSize: Dp = 0.dp,
71
- ) {
72
- val scrollStateFlow = remember { MutableStateFlow(scrollPosition) }
73
- var lastScrollPosition by rememberSaveable { mutableStateOf(0) }
74
- var isExpanded by rememberSaveable { mutableStateOf(false) }
75
-
76
- val coroutineScope = rememberCoroutineScope()
77
-
78
- // Animations
79
- val baseSize = if (size == FABSize.SMALL) FabSmallSize else FabDefaultSize
80
- val width by animateDpAsState(
81
- targetValue = if (isExpanded && text != null) FabExpandedWidth else baseSize,
82
- animationSpec = tween(100, easing = CubicBezierEasing(0.2f, 0.2f, 0.2f, 0.2f))
83
- )
84
-
85
- // Scroll listener
86
- LaunchedEffect(text) {
87
- if (text != null) {
88
- coroutineScope.launch {
89
- scrollStateFlow.collectLatest { newScroll ->
90
- isExpanded = newScroll <= lastScrollPosition
91
- delay(100.milliseconds)
92
- lastScrollPosition = newScroll
93
- }
94
- }
95
- }
96
- }
97
-
98
- LaunchedEffect(scrollPosition) {
99
- scrollStateFlow.value = scrollPosition
100
- }
101
-
102
- Box(
103
- modifier = Modifier
104
- .fillMaxSize()
105
- .padding(end = 12.dp, bottom = bottom)
106
- .offset(y = -keyboardSize)
107
- .background(Color.Transparent),
108
- contentAlignment = if (position == FABPosition.END) Alignment.BottomEnd else Alignment.BottomCenter,
109
- ) {
110
- FloatingActionButton(
111
- onClick = onClick,
112
- shape = AlertDialogDefaults.shape,
113
- containerColor = containerColor,
114
- contentColor = contentColor,
115
- elevation = elevation,
116
- interactionSource = remember { MutableInteractionSource() },
117
- modifier = Modifier
118
- .sizeIn(minWidth = width)
119
- .height(baseSize)
120
- .conditional(IsShowBaseLineDebug) {
121
- border(1.dp, Colors.blue_03)
122
- }
123
- ) {
124
- Row(
125
- modifier = Modifier.padding(
126
- start = if (isExpanded) FabPaddingHorizontal else 0.dp,
127
- end = if (isExpanded) FabPaddingHorizontal else 0.dp,
128
- ),
129
- verticalAlignment = Alignment.CenterVertically,
130
- horizontalArrangement = if (isExpanded) Arrangement.Start else Arrangement.Center
131
- ) {
132
- Icon(
133
- source = icon,
134
- size = if (size == FABSize.SMALL) FabIconSizeSmall else FabIconSizeDefault,
135
- color = iconColor ?: Color.White
136
- )
137
-
138
- AnimatedVisibility(
139
- visible = isExpanded,
140
- enter = fadeInExpandAnimation,
141
- exit = fadeOutShrinkAnimation,
142
- ) {
143
- Row {
144
- Spacer(Modifier.width(12.dp))
145
- Text(
146
- text = text ?: "",
147
- color = Color.White,
148
- style = Typography.actionDefaultBold
149
- )
150
- }
151
- }
152
- }
153
- }
154
- }
155
- }
156
-
157
- private val fadeOutShrinkAnimation = fadeOut(
158
- animationSpec = tween(100, easing = LinearEasing)
159
- ) + shrinkHorizontally(
160
- animationSpec = tween(100, easing = LinearEasing),
161
- shrinkTowards = Alignment.Start
162
- )
163
-
164
- private val fadeInExpandAnimation = fadeIn(
165
- animationSpec = tween(100, easing = LinearEasing)
166
- ) + expandHorizontally(
167
- animationSpec = tween(100, easing = LinearEasing),
168
- expandFrom = Alignment.Start
169
- )