@momo-kits/native-kits 0.167.1-duo.1-debug → 0.167.1-duo.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 (146) hide show
  1. package/CLAUDE.md +7 -0
  2. package/ios/native-kits.podspec +1 -1
  3. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  4. package/package.json +1 -1
  5. package/.claude/settings.local.json +0 -185
  6. package/build.gradle.kts +0 -11
  7. package/compose/build.gradle.kts +0 -190
  8. package/compose/build.gradle.kts.backup +0 -190
  9. package/compose/compose.podspec +0 -47
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -151
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -52
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -124
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +0 -183
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -207
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +0 -39
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +0 -86
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +0 -76
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +0 -76
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +0 -293
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +0 -33
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -831
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +0 -110
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +0 -378
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +0 -69
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -113
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -76
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -475
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -266
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -240
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -264
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  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 -84
  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 -334
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -98
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -310
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -323
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -199
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -91
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -552
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -88
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -234
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -188
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -16
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -188
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -297
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -52
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -38
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -39
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -299
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -129
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -106
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -201
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -393
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -596
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -175
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -225
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -360
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -83
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -75
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -309
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -37
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -364
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -132
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  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 -71
  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 -115
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -40
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -213
  138. package/gradle/libs.versions.toml +0 -69
  139. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  140. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  141. package/gradle.properties +0 -26
  142. package/gradlew +0 -252
  143. package/gradlew.bat +0 -94
  144. package/ios-demo/README.md +0 -120
  145. package/local.properties +0 -8
  146. package/settings.gradle.kts +0 -64
@@ -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
- )
@@ -1,360 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import vn.momo.kits.modifier.InternalApi
4
-
5
- import androidx.compose.animation.core.animateFloatAsState
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.Row
11
- import androidx.compose.foundation.layout.Spacer
12
- import androidx.compose.foundation.layout.fillMaxWidth
13
- import androidx.compose.foundation.layout.height
14
- import androidx.compose.foundation.layout.offset
15
- import androidx.compose.foundation.layout.padding
16
- import androidx.compose.foundation.layout.size
17
- import androidx.compose.foundation.layout.width
18
- import androidx.compose.foundation.layout.wrapContentHeight
19
- import androidx.compose.foundation.shape.RoundedCornerShape
20
- import androidx.compose.runtime.Composable
21
- import androidx.compose.runtime.getValue
22
- import androidx.compose.ui.Alignment
23
- import androidx.compose.ui.Modifier
24
- import androidx.compose.ui.draw.clipToBounds
25
- import androidx.compose.ui.graphics.graphicsLayer
26
- import androidx.compose.ui.graphics.Brush
27
- import androidx.compose.ui.graphics.Color
28
- import androidx.compose.ui.layout.onGloballyPositioned
29
- import androidx.compose.ui.platform.LocalDensity
30
- import androidx.compose.ui.text.style.TextAlign
31
- import androidx.compose.ui.unit.Dp
32
- import androidx.compose.ui.unit.dp
33
- import vn.momo.kits.components.Icon
34
- import vn.momo.kits.components.Image
35
- import vn.momo.kits.components.InputSearchProps
36
- import vn.momo.kits.const.AppStatusBar
37
- import vn.momo.kits.const.AppTheme
38
- import vn.momo.kits.const.Colors
39
- import vn.momo.kits.components.PopupNotifyProps
40
- import vn.momo.kits.application.IsShowBaseLineDebug
41
- import vn.momo.kits.const.Spacing
42
- import vn.momo.kits.modifier.activeOpacityClickable
43
- import vn.momo.kits.modifier.conditional
44
- import vn.momo.kits.modifier.setAutomationId
45
- import vn.momo.kits.navigation.LocalHeaderRightWidthPx
46
- import vn.momo.kits.navigation.LocalNavigator
47
- import vn.momo.kits.navigation.LocalOptions
48
- import vn.momo.kits.navigation.LocalScrollState
49
- import vn.momo.kits.navigation.getInputSearchType
50
- import vn.momo.kits.utils.horizontalSafeAreaPadding
51
-
52
- @InternalApi
53
- const val HEADER_HEIGHT = 52
54
- internal enum class InputSearchType { None, Header, Animated }
55
- enum class TitlePosition { LEFT, CENTER }
56
-
57
- @Suppress("FrequentlyChangingValue")
58
- @Composable
59
- internal fun Header(onBackHandler: (() -> Unit)? = null) {
60
- val options = LocalOptions.current
61
- val navigator = LocalNavigator.current
62
- val scrollState = LocalScrollState.current
63
- val headerRightWidthPx = LocalHeaderRightWidthPx.current
64
- val inputSearchType = getInputSearchType(options)
65
-
66
- val opacityHeight = when (val header = options.headerType) {
67
- is HeaderType.Animated -> with(LocalDensity.current) { header.layoutOffSet.roundToPx() }
68
- else -> HEADER_HEIGHT
69
- }
70
- val opacity by animateFloatAsState(
71
- targetValue = if (options.headerType is HeaderType.Transparent) {
72
- 0f
73
- } else {
74
- (scrollState.value / opacityHeight.toFloat())
75
- .coerceIn(0f, 1f)
76
- }
77
- )
78
-
79
- val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
80
-
81
- val animatedAlpha by animateFloatAsState(targetValue = opacity, label = "BackgroundAlpha")
82
-
83
- val background = if (options.headerType is HeaderType.Transparent)
84
- options.backgroundColor ?: AppTheme.current.colors.background.surface
85
- else
86
- AppTheme.current.colors.background.surface
87
-
88
- if (options.headerType == HeaderType.None) return
89
-
90
- val titlePosition = options.titlePosition
91
- val titleColor = headerColor.tintIconColor
92
- .copy(alpha = if (inputSearchType == InputSearchType.Animated) 1f - animatedAlpha else 1f)
93
- // Centered title needs a full-width overlay to stay screen-centered, not boxed between back button and header right.
94
- val centerTitle = titlePosition == TitlePosition.CENTER && options.headerTitle is HeaderTitle.Default
95
-
96
- val headerImage = AppTheme.current.assets.headerBackground
97
- .takeUnless { options.headerType is HeaderType.Transparent }
98
-
99
- Box(
100
- Modifier.height(AppStatusBar.current + HEADER_HEIGHT.dp)
101
- .fillMaxWidth()
102
- .conditional(headerImage.isNullOrEmpty()) {
103
- background(background.copy(alpha = animatedAlpha))
104
- }
105
- .conditional(IsShowBaseLineDebug) {
106
- border(1.dp, Colors.blue_03)
107
- },
108
- contentAlignment = Alignment.BottomCenter
109
- ) {
110
- if (!headerImage.isNullOrEmpty()) {
111
- Box(
112
- Modifier
113
- .matchParentSize()
114
- .clipToBounds()
115
- .graphicsLayer { alpha = animatedAlpha }
116
- .background(background)
117
- ) {
118
- Image(
119
- source = headerImage,
120
- loading = false,
121
- modifier = Modifier
122
- .fillMaxWidth()
123
- .wrapContentHeight(Alignment.Top, unbounded = true)
124
- .height(HEADER_BACKGROUND_HEIGHT),
125
- )
126
- }
127
- }
128
- Row(
129
- modifier = Modifier.height(HEADER_HEIGHT.dp)
130
- .fillMaxWidth()
131
- .horizontalSafeAreaPadding()
132
- .padding(horizontal = Spacing.M),
133
- verticalAlignment = Alignment.CenterVertically,
134
- horizontalArrangement = Arrangement.SpaceBetween
135
- ) {
136
- if(!options.hiddenBack) {
137
- BackButton(
138
- borderColor = headerColor.borderColor,
139
- backgroundButton = headerColor.backgroundButton,
140
- tintIconColor = headerColor.tintIconColor,
141
- onBackHandler = {
142
- navigator.onBackSafe { }
143
- }
144
- )
145
- Spacer(Modifier.width(Spacing.S))
146
- }
147
-
148
- if (centerTitle) {
149
- Spacer(Modifier.weight(1f))
150
- } else {
151
- HeaderContent(
152
- headerTitle = options.headerTitle,
153
- tintIconColor = titleColor,
154
- titlePosition = titlePosition,
155
- modifier = Modifier.weight(1f)
156
- )
157
- }
158
- Box(Modifier.onGloballyPositioned {
159
- if(headerRightWidthPx.intValue != it.size.width) headerRightWidthPx.intValue = it.size.width
160
- }){
161
- HeaderRight(options.headerRight, options.tintColor, headerColor)
162
- }
163
- }
164
- if (centerTitle) {
165
- Box(
166
- modifier = Modifier.height(HEADER_HEIGHT.dp)
167
- .fillMaxWidth()
168
- .padding(horizontal = Spacing.M),
169
- contentAlignment = Alignment.Center
170
- ) {
171
- HeaderContent(
172
- headerTitle = options.headerTitle,
173
- tintIconColor = titleColor,
174
- titlePosition = titlePosition,
175
- modifier = Modifier.fillMaxWidth()
176
- )
177
- }
178
- }
179
- VerticalShadow(opacity)
180
- }
181
- }
182
-
183
- @Composable
184
- private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
185
- Box(
186
- modifier = Modifier
187
- .size(28.dp)
188
- .background(backgroundButton, RoundedCornerShape(100))
189
- .border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
190
- .activeOpacityClickable(onClick = onBackHandler)
191
- .padding(Spacing.XS)
192
- .setAutomationId("btn_navigation_back"),
193
- contentAlignment = Alignment.Center
194
- ) {
195
- Icon(
196
- source = "arrow-back",
197
- color = tintIconColor,
198
- size = 20.dp,
199
- )
200
- }
201
- }
202
-
203
- @Composable
204
- internal fun HeaderContent(
205
- headerTitle: HeaderTitle,
206
- tintIconColor: Color,
207
- titlePosition: TitlePosition = TitlePosition.LEFT,
208
- modifier: Modifier = Modifier,
209
- ){
210
- Box(
211
- modifier = modifier,
212
- contentAlignment = if (titlePosition == TitlePosition.CENTER) Alignment.Center else Alignment.CenterStart
213
- ) {
214
- when (headerTitle){
215
- is HeaderTitle.Default -> {
216
- HeaderTitle(
217
- title = headerTitle.title,
218
- color = tintIconColor,
219
- modifier = Modifier.fillMaxWidth(fraction = if (titlePosition == TitlePosition.CENTER) 0.5f else 1f),
220
- textAlign = if (titlePosition == TitlePosition.CENTER) TextAlign.Center else TextAlign.Start
221
- )
222
- }
223
- is HeaderTitle.Journey -> {
224
- HeaderJourney(
225
- data = headerTitle,
226
- tintIconColor = tintIconColor
227
- )
228
- }
229
- is HeaderTitle.Location -> {
230
- HeaderLocation(
231
- data = headerTitle,
232
- tintIconColor = tintIconColor
233
- )
234
- }
235
- is HeaderTitle.User -> {
236
- HeaderUser(
237
- data = headerTitle
238
- )
239
- }
240
- }
241
- }
242
- }
243
-
244
- @Composable
245
- internal fun VerticalShadow(opacity: Float){
246
- if(opacity == 1f){
247
- Box(modifier = Modifier
248
- .fillMaxWidth()
249
- .height(6.dp)
250
- .offset(x = 0.dp, y = 6.dp)
251
- .background(
252
- brush = Brush.verticalGradient(
253
- colors = listOf(Color.Black.copy(alpha = 0.05f), Color.Transparent)
254
- )
255
- )
256
- )
257
- }
258
- }
259
-
260
- sealed class HeaderTitle {
261
- class Default(val title: String) : HeaderTitle()
262
-
263
- class User(
264
- val title: String,
265
- val subTitle: String? = null,
266
- val image: List<String>? = null,
267
- val dotColor: Color? = null,
268
- val tintColor: Color? = null,
269
- val onPress: (() -> Unit)? = null,
270
- val icons: List<String> = emptyList(),
271
- val isLoading: Boolean = false
272
- ) : HeaderTitle()
273
-
274
- class Location(
275
- val description: String? = null,
276
- val location: String,
277
- val tintColor: String? = null,
278
- val onPress: (() -> Unit)? = null,
279
- val isLoading: Boolean = false
280
- ) : HeaderTitle()
281
-
282
- class Journey(
283
- val start: String,
284
- val end: String? = null,
285
- val description: String? = null,
286
- val icon: String,
287
- val iconColor: String? = null,
288
- val tintColor: String? = null,
289
- val onPress: (() -> Unit)? = null,
290
- val isLoading: Boolean = false
291
- ) : HeaderTitle()
292
- }
293
-
294
- sealed class HeaderType {
295
- interface DefaultOrExtended {
296
- val useAnimated: Boolean
297
- val inputSearchProps: InputSearchProps?
298
- }
299
-
300
- data class Default(
301
- override val useAnimated: Boolean = false,
302
- override val inputSearchProps: InputSearchProps? = null
303
- ) : HeaderType(), DefaultOrExtended
304
-
305
- data class Extended(
306
- override val useAnimated: Boolean = false,
307
- override val inputSearchProps: InputSearchProps? = null
308
- ) : HeaderType(), DefaultOrExtended
309
-
310
- data object None : HeaderType()
311
-
312
- data class Animated(
313
- val aspectRatio: AnimatedHeaderRatio = AnimatedHeaderRatio.RATIO_16_9,
314
- val isSurface: Boolean = true,
315
- val layoutOffSet: Dp = 56.dp,
316
- val height: Dp? = null,
317
- val composable: @Composable (scrollState: Int) -> Unit = {}
318
- ) : HeaderType()
319
-
320
- data class Transparent(
321
- val isFullScreenContent: Boolean = false
322
- ) : HeaderType()
323
- }
324
-
325
- data class HeaderBackProps(
326
- val preventBack: PopupNotifyProps? = null,
327
- )
328
-
329
- @InternalApi
330
- data class HeaderColor(val tintIconColor: Color, val backgroundButton: Color, val borderColor: Color)
331
- internal fun getHeaderColor(headerType: HeaderType, opacity: Float, tintColor: Color?, defaultColor: Color): HeaderColor{
332
- return if(headerType is HeaderType.Animated) {
333
- if (opacity == 1f || !headerType.isSurface)
334
- HeaderColor(
335
- tintIconColor = Colors.black_17,
336
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
337
- borderColor = Colors.black_20.copy(alpha = 0.2f)
338
- )
339
- else
340
- HeaderColor(
341
- tintIconColor = Colors.black_01,
342
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
343
- borderColor = Color.Transparent
344
- )
345
- }
346
- else {
347
- if (tintColor == Colors.black_01)
348
- HeaderColor(
349
- tintIconColor = tintColor,
350
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
351
- borderColor = Colors.black_01.copy(alpha = 0.2f)
352
- )
353
- else
354
- HeaderColor(
355
- tintIconColor = tintColor ?: defaultColor,
356
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
357
- borderColor = Colors.black_20.copy(alpha = 0.2f)
358
- )
359
- }
360
- }
@@ -1,83 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.animation.core.animateFloatAsState
4
- import androidx.compose.foundation.background
5
- import androidx.compose.foundation.layout.Box
6
- import androidx.compose.foundation.layout.fillMaxSize
7
- import androidx.compose.foundation.layout.fillMaxWidth
8
- import androidx.compose.foundation.layout.height
9
- import androidx.compose.runtime.Composable
10
- import androidx.compose.runtime.getValue
11
- import androidx.compose.ui.Modifier
12
- import androidx.compose.ui.geometry.Offset
13
- import androidx.compose.ui.graphics.Brush
14
- import androidx.compose.ui.graphics.Color
15
- import androidx.compose.ui.platform.LocalDensity
16
- import androidx.compose.ui.unit.dp
17
- import vn.momo.kits.components.Image
18
- import vn.momo.kits.const.AppStatusBar
19
- import vn.momo.kits.const.AppTheme
20
- import vn.momo.kits.modifier.conditional
21
- import vn.momo.kits.navigation.LocalOptions
22
- import vn.momo.kits.navigation.LocalScrollState
23
-
24
- enum class AnimatedHeaderRatio(val value: Float){
25
- RATIO_16_9(16f / 9f),
26
- RATIO_1_1(1f),
27
- RATIO_3_2(3f / 2f)
28
- }
29
-
30
- internal val HEADER_BACKGROUND_HEIGHT = 154.dp
31
-
32
- @Suppress("FrequentlyChangingValue")
33
- @Composable
34
- internal fun HeaderBackground() {
35
- val density = LocalDensity.current
36
- val theme = AppTheme.current
37
- val options = LocalOptions.current
38
- val scrollState = LocalScrollState.current
39
- val backgroundColor = options.backgroundColor ?: AppTheme.current.colors.background.default
40
-
41
- val minHeight = AppStatusBar.current + HEADER_HEIGHT.dp
42
- val maxHeight = HEADER_BACKGROUND_HEIGHT
43
- val opacity by animateFloatAsState(
44
- targetValue = (1 - (scrollState.value * 1f / HEADER_HEIGHT * 1f)).coerceIn(0f, 1f),
45
- )
46
-
47
- val color = if (opacity == 0f) backgroundColor else Color(0xFFFDCADE)
48
- val height = when (options.headerType) {
49
- is HeaderType.Default -> minHeight
50
- is HeaderType.Extended -> {
51
- if (AppTheme.current.isHeaderImage()){
52
- if (opacity == 0f) minHeight else maxHeight
53
- } else {
54
- maxHeight
55
- }
56
- }
57
- else -> 0.dp
58
- }
59
-
60
- Box(Modifier.fillMaxWidth().height(height).background(backgroundColor)) {
61
- Box(Modifier
62
- .height(maxHeight)
63
- .fillMaxWidth()
64
- .conditional(!theme.isHeaderImage()) {
65
- background(Brush.linearGradient(
66
- colors = listOf(
67
- color,
68
- backgroundColor
69
- ),
70
- start = Offset(0f, 0f),
71
- end = Offset(0f, with(density) { maxHeight.toPx() })
72
- )
73
- )
74
- }
75
- ){
76
- if (!theme.isHeaderImage()) return@Box
77
- Image(
78
- source = theme.assets.headerBackground!!,
79
- modifier = Modifier.fillMaxSize(),
80
- )
81
- }
82
- }
83
- }