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

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 (139) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -198
  4. package/compose/compose.podspec +0 -47
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  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/BackGesture.android.kt +0 -12
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -195
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -236
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -293
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -393
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -113
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -739
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -239
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -430
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -100
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -129
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -456
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -204
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -22
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -219
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -144
  132. package/gradle/libs.versions.toml +0 -69
  133. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  134. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  135. package/gradle.properties +0 -24
  136. package/gradlew +0 -252
  137. package/gradlew.bat +0 -94
  138. package/ios-demo/README.md +0 -120
  139. package/settings.gradle.kts +0 -64
@@ -1,456 +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.CompositionLocalProvider
22
- import androidx.compose.runtime.compositionLocalOf
23
- import androidx.compose.runtime.getValue
24
- import androidx.compose.ui.Alignment
25
- import androidx.compose.ui.Modifier
26
- import androidx.compose.ui.draw.clipToBounds
27
- import androidx.compose.ui.draw.drawBehind
28
- import androidx.compose.ui.geometry.Offset
29
- import androidx.compose.ui.graphics.graphicsLayer
30
- import androidx.compose.ui.graphics.Brush
31
- import androidx.compose.ui.graphics.Color
32
- import androidx.compose.ui.layout.onGloballyPositioned
33
- import androidx.compose.ui.platform.LocalDensity
34
- import androidx.compose.ui.text.style.TextAlign
35
- import androidx.compose.ui.unit.Dp
36
- import androidx.compose.ui.unit.dp
37
- import vn.momo.kits.components.Icon
38
- import vn.momo.kits.components.Image
39
- import vn.momo.kits.components.InputSearchProps
40
- import vn.momo.kits.const.AppTheme
41
- import vn.momo.kits.const.Colors
42
- import vn.momo.kits.components.PopupNotifyProps
43
- import vn.momo.kits.application.IsShowBaseLineDebug
44
- import vn.momo.kits.const.Spacing
45
- import vn.momo.kits.layout.DuoMetrics
46
- import vn.momo.kits.layout.getScreenLayout
47
- import vn.momo.kits.modifier.activeOpacityClickable
48
- import vn.momo.kits.modifier.conditional
49
- import vn.momo.kits.modifier.setAutomationId
50
- import vn.momo.kits.navigation.LocalHeaderRightWidthPx
51
- import vn.momo.kits.navigation.LocalNavigator
52
- import vn.momo.kits.navigation.LocalOptions
53
- import vn.momo.kits.navigation.LocalScrollState
54
- import vn.momo.kits.navigation.getInputSearchType
55
- import vn.momo.kits.navigation.usesDuoGlassHeader
56
- import vn.momo.kits.utils.horizontalSafeAreaPadding
57
-
58
- @InternalApi
59
- const val HEADER_HEIGHT = 52
60
- internal enum class InputSearchType { None, Header, Animated }
61
- enum class TitlePosition { LEFT, CENTER }
62
-
63
- private val HEADER_ACTIONS_WIDTH = 172.dp
64
-
65
- // Extra width the 48pt back and toolkit take on the iPhone Duo status bar row.
66
- private val STATUS_BAR_ROW_ACTIONS_EXTRA = 55.dp
67
-
68
- @Suppress("FrequentlyChangingValue")
69
- @Composable
70
- internal fun headerOpacity(): Float {
71
- val options = LocalOptions.current
72
- val scrollState = LocalScrollState.current
73
- val opacityHeight = when (val header = options.headerType) {
74
- is HeaderType.Animated -> with(LocalDensity.current) { header.layoutOffSet.roundToPx() }
75
- else -> HEADER_HEIGHT
76
- }
77
- val opacity by animateFloatAsState(
78
- targetValue = when {
79
- options.headerType is HeaderType.Transparent -> 0f
80
- opacityHeight <= 0 -> if (scrollState.value > 0) 1f else 0f
81
- else -> (scrollState.value / opacityHeight.toFloat()).coerceIn(0f, 1f)
82
- }
83
- )
84
- return opacity
85
- }
86
-
87
- // Back button and toolkit share the bar with the title unless the iPhone Duo side bar holds them.
88
- @Composable
89
- internal fun headerTitleMaxWidth(): Dp {
90
- val layout = getScreenLayout()
91
- val clearance = layout.statusBarClearance
92
- val clearanceWidth = clearance?.let { it.left + it.right } ?: 0.dp
93
- if (layout.sideBar != null) return layout.contentWidth - Spacing.M * 2 - clearanceWidth
94
- return layout.width - HEADER_ACTIONS_WIDTH - (if (clearance != null) STATUS_BAR_ROW_ACTIONS_EXTRA else 0.dp) - clearanceWidth
95
- }
96
-
97
- // Scroll distance over which the Duo glass bar fades in.
98
- private val DUO_GLASS_FADE_DISTANCE = 16.dp
99
-
100
- // RN DuoGlassBackground: translucent surface with a hairline once content scrolls under it.
101
- @Suppress("FrequentlyChangingValue")
102
- @Composable
103
- private fun Modifier.duoGlassBar(): Modifier {
104
- val scrollState = LocalScrollState.current
105
- val fadePx = with(LocalDensity.current) { DUO_GLASS_FADE_DISTANCE.toPx() }
106
- val alpha by animateFloatAsState((scrollState.value / fadePx).coerceIn(0f, 1f), label = "DuoGlassAlpha")
107
- val colors = AppTheme.current.colors
108
- return background(colors.background.surface.copy(alpha = 0.8f * alpha))
109
- .drawBehind {
110
- val stroke = 0.5.dp.toPx()
111
- drawLine(
112
- color = colors.border.default.copy(alpha = alpha),
113
- start = Offset(0f, size.height - stroke / 2),
114
- end = Offset(size.width, size.height - stroke / 2),
115
- strokeWidth = stroke,
116
- )
117
- }
118
- }
119
-
120
- @Composable
121
- internal fun Header(onBackHandler: (() -> Unit)? = null) {
122
- val options = LocalOptions.current
123
- val navigator = LocalNavigator.current
124
- val headerRightWidthPx = LocalHeaderRightWidthPx.current
125
- val inputSearchType = getInputSearchType(options)
126
- val layout = getScreenLayout()
127
- val useSideBar = layout.sideBar != null
128
- // iPhone Duo inner portrait: the row sits on the status bar, between its clusters
129
- val clearance = layout.statusBarClearance
130
- val statusBarRow = clearance != null && !useSideBar
131
- val opacity = headerOpacity()
132
-
133
- val headerColor = getHeaderColor(options.headerType, opacity, options.tintColor, Colors.black_17)
134
-
135
- val animatedAlpha by animateFloatAsState(targetValue = opacity, label = "BackgroundAlpha")
136
-
137
- val background = if (options.headerType is HeaderType.Transparent)
138
- options.backgroundColor ?: AppTheme.current.colors.background.surface
139
- else
140
- AppTheme.current.colors.background.surface
141
-
142
- if (options.headerType == HeaderType.None) return
143
-
144
- val titlePosition = options.titlePosition
145
- val titleColor = headerColor.tintIconColor
146
- .copy(alpha = if (inputSearchType == InputSearchType.Animated) 1f - animatedAlpha else 1f)
147
- // Centered title needs a full-width overlay to stay screen-centered, not boxed between back button and header right.
148
- val centerTitle = titlePosition == TitlePosition.CENTER && options.headerTitle is HeaderTitle.Default
149
-
150
- val useDuoGlass = options.usesDuoGlassHeader(layout)
151
- val headerImage = AppTheme.current.assets.headerBackground
152
- .takeUnless { options.headerType is HeaderType.Transparent || useDuoGlass }
153
-
154
- Box(
155
- Modifier.height(layout.headerHeight)
156
- .fillMaxWidth()
157
- .then(if (useDuoGlass) Modifier.duoGlassBar() else Modifier)
158
- .conditional(headerImage.isNullOrEmpty() && !useDuoGlass) {
159
- background(background.copy(alpha = animatedAlpha))
160
- }
161
- .conditional(IsShowBaseLineDebug) {
162
- border(1.dp, Colors.blue_03)
163
- },
164
- contentAlignment = Alignment.BottomCenter
165
- ) {
166
- if (!headerImage.isNullOrEmpty()) {
167
- Box(
168
- Modifier
169
- .matchParentSize()
170
- .clipToBounds()
171
- .graphicsLayer { alpha = animatedAlpha }
172
- .background(background)
173
- ) {
174
- Image(
175
- source = headerImage,
176
- loading = false,
177
- modifier = Modifier
178
- .fillMaxWidth()
179
- .wrapContentHeight(Alignment.Top, unbounded = true)
180
- .height(HEADER_BACKGROUND_HEIGHT),
181
- )
182
- }
183
- }
184
- Row(
185
- modifier = Modifier.height(layout.headerBarHeight)
186
- .fillMaxWidth()
187
- .horizontalSafeAreaPadding()
188
- .padding(
189
- start = Spacing.M + (clearance?.left ?: 0.dp),
190
- end = Spacing.M + (clearance?.right ?: 0.dp),
191
- ),
192
- verticalAlignment = Alignment.CenterVertically,
193
- horizontalArrangement = Arrangement.SpaceBetween
194
- ) {
195
- if (!options.hiddenBack && !useSideBar) {
196
- if (statusBarRow) {
197
- SideBarButton(
198
- icon = "arrow-back",
199
- headerColor = headerColor,
200
- automationId = "btn_navigation_back",
201
- onClick = { navigator.onBackSafe { } },
202
- )
203
- } else {
204
- BackButton(
205
- borderColor = headerColor.borderColor,
206
- backgroundButton = headerColor.backgroundButton,
207
- tintIconColor = headerColor.tintIconColor,
208
- onBackHandler = {
209
- navigator.onBackSafe { }
210
- }
211
- )
212
- }
213
- Spacer(Modifier.width(Spacing.S))
214
- }
215
-
216
- if (centerTitle) {
217
- Spacer(Modifier.weight(1f))
218
- } else {
219
- HeaderContent(
220
- headerTitle = options.headerTitle,
221
- tintIconColor = titleColor,
222
- titlePosition = titlePosition,
223
- modifier = Modifier.weight(1f)
224
- )
225
- }
226
- Box(Modifier.onGloballyPositioned {
227
- if(headerRightWidthPx.intValue != it.size.width) headerRightWidthPx.intValue = it.size.width
228
- }){
229
- val headerRight = options.headerRight
230
- when {
231
- // on Duo the side bar column holds the header right (toolkit or custom), not this row
232
- useSideBar -> Unit
233
- statusBarRow && headerRight is HeaderRight.Toolkit -> Toolkit(
234
- headerRight = headerRight,
235
- tintColor = options.tintColor,
236
- headerColor = headerColor,
237
- layout = ToolkitLayout.SideBarRow,
238
- )
239
- else -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
240
- HeaderRight(headerRight, options.tintColor, headerColor)
241
- }
242
- }
243
- }
244
- }
245
- if (centerTitle) {
246
- // on the status bar row the clusters are lopsided, so both sides keep the wider one's room
247
- val centerInset = if (clearance != null) {
248
- val back = if (options.hiddenBack || useSideBar) 0.dp else DuoMetrics.controlSize + Spacing.S
249
- val right = with(LocalDensity.current) { headerRightWidthPx.intValue.toDp() }
250
- maxOf(clearance.left + back, clearance.right + right) + Spacing.S
251
- } else {
252
- 0.dp
253
- }
254
- Box(
255
- modifier = Modifier.height(layout.headerBarHeight)
256
- .fillMaxWidth()
257
- .horizontalSafeAreaPadding()
258
- .padding(horizontal = Spacing.M + centerInset),
259
- contentAlignment = Alignment.Center
260
- ) {
261
- HeaderContent(
262
- headerTitle = options.headerTitle,
263
- tintIconColor = titleColor,
264
- titlePosition = titlePosition,
265
- centerWidthFraction = if (clearance != null) 1f else 0.5f,
266
- modifier = Modifier.fillMaxWidth()
267
- )
268
- }
269
- }
270
- VerticalShadow(opacity)
271
- }
272
- }
273
-
274
- @Composable
275
- private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColor: Color, onBackHandler: () -> Unit){
276
- Box(
277
- modifier = Modifier
278
- .size(28.dp)
279
- .background(backgroundButton, RoundedCornerShape(100))
280
- .border(width = 0.2.dp, color = borderColor, shape = RoundedCornerShape(100))
281
- .activeOpacityClickable(onClick = onBackHandler)
282
- .padding(Spacing.XS)
283
- .setAutomationId("btn_navigation_back"),
284
- contentAlignment = Alignment.Center
285
- ) {
286
- Icon(
287
- source = "arrow-back",
288
- color = tintIconColor,
289
- size = 20.dp,
290
- )
291
- }
292
- }
293
-
294
- @Composable
295
- internal fun HeaderContent(
296
- headerTitle: HeaderTitle,
297
- tintIconColor: Color,
298
- titlePosition: TitlePosition = TitlePosition.LEFT,
299
- centerWidthFraction: Float = 0.5f,
300
- modifier: Modifier = Modifier,
301
- ){
302
- Box(
303
- modifier = modifier,
304
- contentAlignment = if (titlePosition == TitlePosition.CENTER) Alignment.Center else Alignment.CenterStart
305
- ) {
306
- when (headerTitle){
307
- is HeaderTitle.Default -> {
308
- HeaderTitle(
309
- title = headerTitle.title,
310
- color = tintIconColor,
311
- modifier = Modifier.fillMaxWidth(fraction = if (titlePosition == TitlePosition.CENTER) centerWidthFraction else 1f),
312
- textAlign = if (titlePosition == TitlePosition.CENTER) TextAlign.Center else TextAlign.Start
313
- )
314
- }
315
- is HeaderTitle.Journey -> {
316
- HeaderJourney(
317
- data = headerTitle,
318
- tintIconColor = tintIconColor
319
- )
320
- }
321
- is HeaderTitle.Location -> {
322
- HeaderLocation(
323
- data = headerTitle,
324
- tintIconColor = tintIconColor
325
- )
326
- }
327
- is HeaderTitle.User -> {
328
- HeaderUser(
329
- data = headerTitle
330
- )
331
- }
332
- }
333
- }
334
- }
335
-
336
- @Composable
337
- internal fun VerticalShadow(opacity: Float){
338
- if(opacity == 1f){
339
- Box(modifier = Modifier
340
- .fillMaxWidth()
341
- .height(6.dp)
342
- .offset(x = 0.dp, y = 6.dp)
343
- .background(
344
- brush = Brush.verticalGradient(
345
- colors = listOf(Color.Black.copy(alpha = 0.05f), Color.Transparent)
346
- )
347
- )
348
- )
349
- }
350
- }
351
-
352
- sealed class HeaderTitle {
353
- class Default(val title: String) : HeaderTitle()
354
-
355
- class User(
356
- val title: String,
357
- val subTitle: String? = null,
358
- val image: List<String>? = null,
359
- val dotColor: Color? = null,
360
- val tintColor: Color? = null,
361
- val onPress: (() -> Unit)? = null,
362
- val icons: List<String> = emptyList(),
363
- val isLoading: Boolean = false
364
- ) : HeaderTitle()
365
-
366
- class Location(
367
- val description: String? = null,
368
- val location: String,
369
- val tintColor: String? = null,
370
- val onPress: (() -> Unit)? = null,
371
- val isLoading: Boolean = false
372
- ) : HeaderTitle()
373
-
374
- class Journey(
375
- val start: String,
376
- val end: String? = null,
377
- val description: String? = null,
378
- val icon: String,
379
- val iconColor: String? = null,
380
- val tintColor: String? = null,
381
- val onPress: (() -> Unit)? = null,
382
- val isLoading: Boolean = false
383
- ) : HeaderTitle()
384
- }
385
-
386
- sealed class HeaderType {
387
- interface DefaultOrExtended {
388
- val useAnimated: Boolean
389
- val inputSearchProps: InputSearchProps?
390
- }
391
-
392
- data class Default(
393
- override val useAnimated: Boolean = false,
394
- override val inputSearchProps: InputSearchProps? = null
395
- ) : HeaderType(), DefaultOrExtended
396
-
397
- data class Extended(
398
- override val useAnimated: Boolean = false,
399
- override val inputSearchProps: InputSearchProps? = null
400
- ) : HeaderType(), DefaultOrExtended
401
-
402
- data object None : HeaderType()
403
-
404
- data class Animated(
405
- val aspectRatio: AnimatedHeaderRatio = AnimatedHeaderRatio.RATIO_16_9,
406
- val isSurface: Boolean = true,
407
- val layoutOffSet: Dp = 56.dp,
408
- val height: Dp? = null,
409
- val composable: @Composable (scrollState: Int) -> Unit = {}
410
- ) : HeaderType()
411
-
412
- data class Transparent(
413
- val isFullScreenContent: Boolean = false
414
- ) : HeaderType()
415
- }
416
-
417
- data class HeaderBackProps(
418
- val preventBack: PopupNotifyProps? = null,
419
- )
420
-
421
- @InternalApi
422
- data class HeaderColor(val tintIconColor: Color, val backgroundButton: Color, val borderColor: Color)
423
-
424
- // The enclosing header's colors, so a custom header right follows the bar (SwiftUI `\.headerColor`).
425
- internal val LocalHeaderColor = compositionLocalOf<HeaderColor?> { null }
426
-
427
- internal fun getHeaderColor(headerType: HeaderType, opacity: Float, tintColor: Color?, defaultColor: Color): HeaderColor{
428
- return if(headerType is HeaderType.Animated) {
429
- if (opacity == 1f || !headerType.isSurface)
430
- HeaderColor(
431
- tintIconColor = Colors.black_17,
432
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
433
- borderColor = Colors.black_20.copy(alpha = 0.2f)
434
- )
435
- else
436
- HeaderColor(
437
- tintIconColor = Colors.black_01,
438
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
439
- borderColor = Color.Transparent
440
- )
441
- }
442
- else {
443
- if (tintColor == Colors.black_01)
444
- HeaderColor(
445
- tintIconColor = tintColor,
446
- backgroundButton = Colors.black_20.copy(alpha = 0.6f),
447
- borderColor = Colors.black_01.copy(alpha = 0.2f)
448
- )
449
- else
450
- HeaderColor(
451
- tintIconColor = tintColor ?: defaultColor,
452
- backgroundButton = Colors.black_01.copy(alpha = 0.6f),
453
- borderColor = Colors.black_20.copy(alpha = 0.2f)
454
- )
455
- }
456
- }
@@ -1,105 +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.fillMaxHeight
7
- import androidx.compose.foundation.layout.fillMaxSize
8
- import androidx.compose.foundation.layout.fillMaxWidth
9
- import androidx.compose.foundation.layout.height
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.runtime.getValue
12
- import androidx.compose.ui.Modifier
13
- import androidx.compose.ui.draw.clipToBounds
14
- import androidx.compose.ui.graphics.graphicsLayer
15
- import androidx.compose.ui.graphics.Brush
16
- import androidx.compose.ui.graphics.Color
17
- import androidx.compose.ui.platform.LocalDensity
18
- import androidx.compose.ui.unit.dp
19
- import vn.momo.kits.components.Image
20
- import vn.momo.kits.const.AppTheme
21
- import vn.momo.kits.layout.getScreenLayout
22
- import vn.momo.kits.modifier.conditional
23
- import vn.momo.kits.navigation.LocalOptions
24
- import vn.momo.kits.navigation.LocalScrollState
25
- import vn.momo.kits.navigation.getInputSearchType
26
- import vn.momo.kits.navigation.usesDuoGlassHeader
27
-
28
- enum class AnimatedHeaderRatio(val value: Float){
29
- RATIO_16_9(16f / 9f),
30
- RATIO_1_1(1f),
31
- RATIO_3_2(3f / 2f)
32
- }
33
-
34
- internal val HEADER_BACKGROUND_HEIGHT = 154.dp
35
-
36
- // RN DuoScrollGradient: extended gradient runs this far below the header
37
- private val DUO_GRADIENT_EXTRA = 52.dp
38
-
39
- @Suppress("FrequentlyChangingValue")
40
- @Composable
41
- internal fun HeaderBackground() {
42
- val density = LocalDensity.current
43
- val theme = AppTheme.current
44
- val options = LocalOptions.current
45
- val scrollState = LocalScrollState.current
46
- val backgroundColor = options.backgroundColor ?: AppTheme.current.colors.background.default
47
-
48
- val layout = getScreenLayout()
49
- val minHeight = layout.headerHeight
50
- val maxHeight = HEADER_BACKGROUND_HEIGHT
51
- val opacity by animateFloatAsState(
52
- targetValue = (1 - (scrollState.value * 1f / HEADER_HEIGHT * 1f)).coerceIn(0f, 1f),
53
- )
54
-
55
- val color = if (opacity == 0f) backgroundColor else Color(0xFFFDCADE)
56
- val height = when (options.headerType) {
57
- is HeaderType.Default -> minHeight
58
- is HeaderType.Extended -> {
59
- if (AppTheme.current.isHeaderImage()){
60
- if (opacity == 0f) minHeight else maxHeight
61
- } else {
62
- maxHeight
63
- }
64
- }
65
- else -> 0.dp
66
- }
67
-
68
- // iPhone Duo glass header: the gradient leaves with the content, as the quick return header does
69
- val useDuoGlass = options.usesDuoGlassHeader(layout)
70
- // RN HeaderExtendHeader with search on the side bar layout: the gradient fills the header box,
71
- // which for extended shrinks from 52pt below the header over the first 100pt of scroll
72
- val duoSearch = layout.sideBar != null && getInputSearchType(options) != InputSearchType.None
73
- val fillsBox = useDuoGlass || duoSearch
74
- val duoModifier = when {
75
- useDuoGlass -> {
76
- val extra = if (options.headerType is HeaderType.Extended) DUO_GRADIENT_EXTRA else 0.dp
77
- Modifier.height(minHeight + extra).graphicsLayer { translationY = -scrollState.value.toFloat() }
78
- }
79
- duoSearch && options.headerType is HeaderType.Extended -> {
80
- val progress = (with(density) { scrollState.value.toDp() } / 100.dp).coerceIn(0f, 1f)
81
- Modifier.height(minHeight + DUO_GRADIENT_EXTRA * (1 - progress))
82
- }
83
- duoSearch -> Modifier.height(minHeight)
84
- else -> Modifier.height(height)
85
- }
86
-
87
- Box(Modifier.fillMaxWidth().then(duoModifier).clipToBounds().background(backgroundColor)) {
88
- // on Duo the fade spans the gradient box; a banner image keeps its 375:154 shape, clipped
89
- Box(Modifier
90
- .fillMaxWidth()
91
- .then(if (fillsBox && !theme.isHeaderImage()) Modifier.fillMaxHeight() else Modifier.height(maxHeight))
92
- .conditional(!theme.isHeaderImage()) {
93
- // RN spans the gradient over 375:154 and clips it, so a default header shows only its top
94
- val endY = if (fillsBox) Float.POSITIVE_INFINITY else with(density) { maxHeight.toPx() }
95
- background(Brush.verticalGradient(colors = listOf(color, backgroundColor), endY = endY))
96
- }
97
- ){
98
- if (!theme.isHeaderImage()) return@Box
99
- Image(
100
- source = theme.assets.headerBackground!!,
101
- modifier = Modifier.fillMaxSize(),
102
- )
103
- }
104
- }
105
- }
@@ -1,106 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.foundation.layout.Arrangement
4
- import androidx.compose.foundation.layout.Box
5
- import androidx.compose.foundation.layout.Column
6
- import androidx.compose.foundation.layout.Row
7
- import androidx.compose.foundation.layout.Spacer
8
- import androidx.compose.foundation.layout.fillMaxWidth
9
- import androidx.compose.foundation.layout.height
10
- import androidx.compose.foundation.layout.width
11
- import androidx.compose.foundation.layout.widthIn
12
- import androidx.compose.foundation.shape.RoundedCornerShape
13
- import androidx.compose.runtime.Composable
14
- import androidx.compose.ui.Alignment
15
- import androidx.compose.ui.Modifier
16
- import androidx.compose.ui.draw.clip
17
- import androidx.compose.ui.graphics.Color
18
- import androidx.compose.ui.text.style.TextOverflow
19
- import androidx.compose.ui.unit.dp
20
- import vn.momo.kits.components.Icon
21
- import vn.momo.kits.components.Skeleton
22
- import vn.momo.kits.components.Text
23
- import vn.momo.kits.const.Spacing
24
- import vn.momo.kits.const.Typography
25
- import vn.momo.kits.modifier.activeOpacityClickable
26
-
27
- @Composable
28
- internal fun HeaderJourney(
29
- data: HeaderTitle,
30
- tintIconColor: Color,
31
- ) {
32
- if (data !is HeaderTitle.Journey) return
33
- if (data.isLoading) return TitleJourneyShimmer()
34
-
35
- val maxWidth = headerTitleMaxWidth()
36
- val tint = parseHeaderTint(data.tintColor) ?: tintIconColor
37
- val iconTint = parseHeaderTint(data.iconColor) ?: tint
38
-
39
- Column(
40
- modifier = Modifier
41
- .widthIn(max = maxWidth)
42
- .activeOpacityClickable(enabled = data.onPress != null, onClick = { data.onPress?.invoke() }),
43
- verticalArrangement = Arrangement.Center,
44
- ) {
45
- Row(verticalAlignment = Alignment.CenterVertically) {
46
- Text(
47
- text = data.start,
48
- color = tint,
49
- style = Typography.actionXsBold,
50
- maxLines = 1,
51
- overflow = TextOverflow.Ellipsis,
52
- modifier = Modifier.weight(1f, fill = false),
53
- )
54
- Spacer(Modifier.width(Spacing.S))
55
- if (data.icon.isNotBlank()) {
56
- Icon(source = data.icon, size = 16.dp, color = iconTint)
57
- } else {
58
- Spacer(Modifier.width(16.dp))
59
- }
60
- Spacer(Modifier.width(Spacing.S))
61
- if (!data.end.isNullOrEmpty()) {
62
- Text(
63
- text = data.end,
64
- color = tint,
65
- style = Typography.actionXsBold,
66
- maxLines = 1,
67
- overflow = TextOverflow.Ellipsis,
68
- modifier = Modifier.weight(1f, fill = false),
69
- )
70
- }
71
- Spacer(Modifier.width(Spacing.XS))
72
- Icon(source = "16_arrow_chevron_down_small", size = 16.dp, color = tint)
73
- }
74
- if (!data.description.isNullOrEmpty()) {
75
- Text(
76
- text = data.description,
77
- color = tint,
78
- style = Typography.descriptionXsRegular,
79
- maxLines = 1,
80
- overflow = TextOverflow.Ellipsis,
81
- )
82
- }
83
- }
84
- }
85
-
86
- @Composable
87
- private fun TitleJourneyShimmer() {
88
- Column(modifier = Modifier.fillMaxWidth()) {
89
- Box(modifier = Modifier.height(18.dp).width(120.dp).clip(RoundedCornerShape(8.dp))) { Skeleton() }
90
- Spacer(Modifier.height(Spacing.XXS))
91
- Box(modifier = Modifier.height(12.dp).width(120.dp).clip(RoundedCornerShape(8.dp))) { Skeleton() }
92
- }
93
- }
94
-
95
- internal fun parseHeaderTint(value: String?): Color? {
96
- val raw = value?.trim()?.removePrefix("#") ?: return null
97
- val hex = when (raw.length) {
98
- 3 -> "FF" + raw.map { "$it$it" }.joinToString("")
99
- 6 -> "FF$raw"
100
- // CSS #RRGGBBAA, as RN passes it; Compose wants AARRGGBB
101
- 8 -> raw.substring(6) + raw.substring(0, 6)
102
- else -> return null
103
- }
104
- val v = hex.toLongOrNull(16) ?: return null
105
- return Color(v)
106
- }