@momo-kits/native-kits 0.160.1-beta.8 → 0.160.1-beta.9-debug

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 (131) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +180 -0
  3. package/compose/build.gradle.kts.backup +180 -0
  4. package/compose/compose.podspec +47 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +117 -0
  6. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  7. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +109 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +720 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +403 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +340 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +198 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +123 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +224 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +188 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +452 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +232 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +259 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +92 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +352 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +338 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +348 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +256 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +494 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +131 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +215 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +531 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +130 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +590 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +192 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +188 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +57 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +14 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +253 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +133 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +99 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +141 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +333 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +569 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +161 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +243 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +279 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +32 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +131 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +167 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +58 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +105 -0
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +180 -0
  124. package/gradle/libs.versions.toml +58 -0
  125. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  126. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  127. package/gradle.properties +26 -0
  128. package/gradlew +252 -0
  129. package/gradlew.bat +94 -0
  130. package/package.json +1 -1
  131. package/settings.gradle.kts +52 -0
@@ -0,0 +1,569 @@
1
+ package vn.momo.kits.navigation
2
+
3
+ import androidx.compose.animation.animateColorAsState
4
+ import androidx.compose.animation.core.animateDpAsState
5
+ import androidx.compose.foundation.ScrollState
6
+ import androidx.compose.foundation.background
7
+ import androidx.compose.foundation.border
8
+ import androidx.compose.foundation.gestures.ScrollableState
9
+ import androidx.compose.foundation.layout.Box
10
+ import androidx.compose.foundation.layout.Column
11
+ import androidx.compose.foundation.layout.ColumnScope
12
+ import androidx.compose.foundation.layout.Spacer
13
+ import androidx.compose.foundation.layout.WindowInsets
14
+ import androidx.compose.foundation.layout.aspectRatio
15
+ import androidx.compose.foundation.layout.fillMaxSize
16
+ import androidx.compose.foundation.layout.fillMaxWidth
17
+ import androidx.compose.foundation.layout.height
18
+ import androidx.compose.foundation.layout.ime
19
+ import androidx.compose.foundation.layout.imePadding
20
+ import androidx.compose.foundation.layout.offset
21
+ import androidx.compose.foundation.layout.padding
22
+ import androidx.compose.foundation.lazy.LazyListState
23
+ import androidx.compose.foundation.lazy.rememberLazyListState
24
+ import androidx.compose.foundation.rememberScrollState
25
+ import androidx.compose.foundation.verticalScroll
26
+ import androidx.compose.material.ExperimentalMaterialApi
27
+ import androidx.compose.runtime.Composable
28
+ import androidx.compose.runtime.CompositionLocalProvider
29
+ import androidx.compose.runtime.LaunchedEffect
30
+ import androidx.compose.runtime.getValue
31
+ import androidx.compose.runtime.mutableIntStateOf
32
+ import androidx.compose.runtime.mutableStateOf
33
+ import androidx.compose.runtime.remember
34
+ import androidx.compose.runtime.snapshotFlow
35
+ import androidx.compose.runtime.staticCompositionLocalOf
36
+ import androidx.compose.ui.Alignment
37
+ import androidx.compose.ui.Modifier
38
+ import androidx.compose.ui.graphics.Brush
39
+ import androidx.compose.ui.graphics.Color
40
+ import androidx.compose.ui.graphics.lerp
41
+ import androidx.compose.ui.layout.onGloballyPositioned
42
+ import androidx.compose.ui.platform.LocalDensity
43
+ import androidx.compose.ui.unit.Dp
44
+ import androidx.compose.ui.unit.dp
45
+ import androidx.compose.ui.unit.min
46
+ import androidx.compose.ui.zIndex
47
+ import vn.momo.kits.components.InputSearch
48
+ import vn.momo.kits.const.AppNavigationBar
49
+ import vn.momo.kits.const.AppStatusBar
50
+ import vn.momo.kits.const.AppTheme
51
+ import vn.momo.kits.application.IsShowBaseLineDebug
52
+ import vn.momo.kits.const.Colors
53
+ import vn.momo.kits.const.Spacing
54
+ import vn.momo.kits.modifier.conditional
55
+ import vn.momo.kits.modifier.hideKeyboardOnTap
56
+ import vn.momo.kits.navigation.component.FABPosition
57
+ import vn.momo.kits.navigation.component.FloatingButton
58
+ import vn.momo.kits.navigation.component.HEADER_HEIGHT
59
+ import vn.momo.kits.navigation.component.Header
60
+ import vn.momo.kits.navigation.component.HeaderBackground
61
+ import vn.momo.kits.navigation.component.HeaderRight
62
+ import vn.momo.kits.navigation.component.HeaderType
63
+ import vn.momo.kits.navigation.component.InputSearchType
64
+ import vn.momo.kits.platform.BackHandler
65
+ import vn.momo.kits.platform.supportsImePadding
66
+ import vn.momo.kits.navigation.tracking.ScreenTracker
67
+ import vn.momo.kits.navigation.tracking.ScreenTrackingState
68
+ import kotlinx.coroutines.delay
69
+ import vn.momo.kits.application.ApplicationContext
70
+ import kotlin.time.Clock
71
+ import kotlin.time.ExperimentalTime
72
+
73
+ internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
74
+ internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
75
+
76
+ @OptIn(ExperimentalMaterialApi::class, ExperimentalTime::class)
77
+ @Composable
78
+ internal fun StackScreen(
79
+ content: @Composable () -> Unit,
80
+ navigationOptions: NavigationOptions? = null,
81
+ id: Int = -1,
82
+ name: String = "",
83
+ bottomTabIndex: Int = -1,
84
+ onBackHandler: (() -> Unit)? = null,
85
+ ) {
86
+ val navigator = LocalNavigator.current
87
+ val maxApi = LocalMaxApi.current
88
+ val context = ApplicationContext.current
89
+ val statusBar = AppStatusBar.current
90
+ val density = LocalDensity.current
91
+ val navigation = remember { Navigation(id = id, bottomTabIndex = bottomTabIndex, initOptions = navigationOptions) }
92
+
93
+ val options by navigation.currentOptions
94
+
95
+ // Auto tracking state
96
+ val trackingState = remember {
97
+ ScreenTrackingState().apply {
98
+ startTime = Clock.System.now().toEpochMilliseconds()
99
+ }
100
+ }
101
+
102
+ // Determine action: push or back
103
+ val action = remember {
104
+ if (ScreenTracker.getLastScreenName() != null) "push" else "back"
105
+ }
106
+
107
+ // Auto tracking effects
108
+ LaunchedEffect(name) {
109
+ // Track screen navigated immediately
110
+ ScreenTracker.trackScreenNavigated(
111
+ maxApi = maxApi,
112
+ context = context,
113
+ screenName = name,
114
+ action = action,
115
+ state = trackingState
116
+ )
117
+
118
+ // Track screen displayed after 2 seconds (debounce)
119
+ delay(2000)
120
+ val loadTime = Clock.System.now().toEpochMilliseconds() - trackingState.startTime
121
+ ScreenTracker.trackScreenDisplayed(
122
+ maxApi = maxApi,
123
+ context = context,
124
+ screenName = name,
125
+ duration = loadTime,
126
+ state = trackingState
127
+ )
128
+
129
+ // Track screen interacted after displayed
130
+ val interactionTime = Clock.System.now().toEpochMilliseconds() - trackingState.startTime
131
+ ScreenTracker.trackScreenInteracted(
132
+ maxApi = maxApi,
133
+ context = context,
134
+ screenName = name,
135
+ duration = interactionTime - loadTime,
136
+ totalDuration = interactionTime,
137
+ state = trackingState
138
+ )
139
+ }
140
+
141
+ val limit = with(density) {
142
+ (statusBar).toPx() + HEADER_HEIGHT
143
+ }.toInt()
144
+
145
+ val (scrollState, scrollInProcess) = if (options.scrollData.scrollState is LazyListState)
146
+ (options.scrollData.scrollState as? LazyListState ?: rememberLazyListState()).proxyScrollState(limit, 15)
147
+ else
148
+ (options.scrollData.scrollState as? ScrollState ?: rememberScrollState()).proxyLimitedScrollState(limit, 15)
149
+
150
+ val footerHeightPx = remember { mutableIntStateOf(0) }
151
+ val headerRightWidthPx = remember { mutableIntStateOf(0) }
152
+
153
+ BackHandler(true) { navigator.onBackSafe() }
154
+
155
+ CompositionLocalProvider(
156
+ StackScreenScrollableState provides options.scrollData.scrollState,
157
+ LocalNavigation provides navigation,
158
+ LocalScrollState provides scrollState,
159
+ LocalOptions provides options,
160
+ LocalFooterHeightPx provides footerHeightPx,
161
+ LocalHeaderRightWidthPx provides headerRightWidthPx
162
+ ) {
163
+ Box(Modifier
164
+ .fillMaxSize()
165
+ .background(options.backgroundColor ?: AppTheme.current.colors.background.default)
166
+ .conditional(options.keyboardOptions.keyboardShouldPersistTaps) {
167
+ hideKeyboardOnTap()
168
+ }
169
+ .conditional(options.keyboardOptions.useAvoidKeyboard && supportsImePadding()) {
170
+ imePadding()
171
+ }
172
+ ) {
173
+ Box(Modifier.zIndex(1f)) {
174
+ HeaderBackground()
175
+ }
176
+
177
+ Box(Modifier.zIndex(1.5f)) {
178
+ AnimatedHeaderImage()
179
+ }
180
+
181
+ Box(Modifier.zIndex(5f)) {
182
+ Header(onBackHandler)
183
+ }
184
+
185
+ Column (Modifier.zIndex(6f)) {
186
+ SearchAnimated(isScrollInProgress = scrollInProcess)
187
+ }
188
+
189
+ Column(Modifier.zIndex(2f).fillMaxSize()) {
190
+ MainContent(content = content)
191
+ }
192
+
193
+ Box(Modifier.zIndex(4f).align(Alignment.BottomCenter)) {
194
+ FooterContent()
195
+ }
196
+
197
+ Box(Modifier.zIndex(7f)){
198
+ FloatingContent()
199
+ }
200
+
201
+ OverplayView(bottomTabIndex = bottomTabIndex, id = id)
202
+ }
203
+ }
204
+ }
205
+
206
+ @Composable
207
+ fun FloatingContent(){
208
+ val options = LocalOptions.current
209
+ val density = LocalDensity.current
210
+ val footerHeightPx = LocalFooterHeightPx.current
211
+ val scrollState = LocalScrollState.current
212
+
213
+ val fabProps = options.floatingButtonProps ?: return
214
+ val bottomPadding = fabProps.bottom ?:
215
+ (Spacing.M + if (options.footerComponent != null) with(density){ footerHeightPx.intValue.toDp() } else 0.dp)
216
+
217
+ FloatingButton(
218
+ scrollPosition = fabProps.scrollState?.value ?: scrollState.value,
219
+ onClick = fabProps.onClick,
220
+ containerColor = AppTheme.current.colors.primary,
221
+ bottom = bottomPadding,
222
+ icon = fabProps.icon,
223
+ iconColor = fabProps.iconColor,
224
+ text = fabProps.label,
225
+ size = fabProps.size,
226
+ position = fabProps.position ?: FABPosition.END,
227
+ )
228
+ }
229
+
230
+ @Composable
231
+ fun ColumnScope.MainContent(content: @Composable ()-> Unit){
232
+ val options = LocalOptions.current
233
+ val inputSearchType = getInputSearchType(options)
234
+ val density = LocalDensity.current
235
+ val scrollState = LocalScrollState.current
236
+
237
+ Spacer(Modifier.height(
238
+ if (options.headerType is HeaderType.DefaultOrExtended || (options.headerType is HeaderType.Transparent && !options.headerType.isFullScreenContent) || options.headerType is HeaderType.Animated)
239
+ AppStatusBar.current + HEADER_HEIGHT.dp else 0.dp)
240
+ )
241
+ if (inputSearchType == InputSearchType.Animated){
242
+ val scrollDp = with(density) { scrollState.value.toDp() }
243
+
244
+ val animatedTopPadding by animateDpAsState(
245
+ targetValue = (HEADER_HEIGHT.dp - scrollDp).coerceIn(0.dp, HEADER_HEIGHT.dp),
246
+ label = "AnimatedTopPadding"
247
+ )
248
+ Spacer(Modifier.height(animatedTopPadding))
249
+ }
250
+ Column (Modifier
251
+ .fillMaxWidth()
252
+ .weight(1f)
253
+ .conditional(options.scrollData.scrollable && options.scrollData.scrollState !is LazyListState) {
254
+ verticalScroll(scrollState)
255
+ }
256
+ ) {
257
+ ScreenContent(content = content)
258
+ }
259
+
260
+ if (options.footerComponent != null){
261
+ val footerHeight = LocalFooterHeightPx.current
262
+ val footerHeightDp = with(density) { footerHeight.value.toDp() }
263
+ Spacer(Modifier.height(footerHeightDp))
264
+ }
265
+ }
266
+
267
+ @Composable
268
+ fun ScreenContent(content: @Composable () -> Unit){
269
+ val options = LocalOptions.current
270
+
271
+ if (options.headerType is HeaderType.Animated){
272
+ val animatedHeader = options.headerType
273
+ Column {
274
+ Spacer(Modifier.height(animatedHeader.layoutOffSet))
275
+ content()
276
+ }
277
+ } else {
278
+ content()
279
+ }
280
+ }
281
+
282
+ @Composable
283
+ fun AnimatedHeaderImage() {
284
+ val options = LocalOptions.current
285
+ val scrollState = LocalScrollState.current
286
+ val animatedHeader = options.headerType as? HeaderType.Animated ?: return
287
+ val density = LocalDensity.current
288
+ val scrollDp = with(density) { scrollState.value.toDp() }
289
+
290
+ Box(
291
+ Modifier
292
+ .fillMaxWidth()
293
+ .offset(y = -scrollDp)
294
+ .aspectRatio(animatedHeader.aspectRatio.value)
295
+ ) {
296
+ animatedHeader.composable.invoke(scrollState.value)
297
+ }
298
+ }
299
+
300
+ @Composable
301
+ fun FooterContent(){
302
+ val options = LocalOptions.current
303
+ if (options.footerComponent != null){
304
+ val ime = WindowInsets.ime
305
+ val density = LocalDensity.current
306
+ val imeBottom = ime.getBottom(density)
307
+ val thresholdPx = with(density) { 50.dp.toPx() }
308
+ val isKeyboardVisible = imeBottom > thresholdPx
309
+ val bottomPadding = if (isKeyboardVisible) 0.dp else AppNavigationBar.current
310
+ Footer(footerComponent = options.footerComponent, bottomPadding = bottomPadding)
311
+ }
312
+ }
313
+
314
+ @Composable
315
+ fun OverplayView(bottomTabIndex: Int, id: Int){
316
+ val overplayType = OverplayComponentRegistry.getOverplayType()
317
+
318
+ if (overplayType != null) {
319
+ Box(Modifier.zIndex(if (overplayType == OverplayComponentType.SNACK_BAR) 3f else 8f).fillMaxSize()){
320
+ if (bottomTabIndex != -1) return@Box
321
+ if (OverplayComponentRegistry.currentRootId() != id) return@Box
322
+ OverplayComponentRegistry.OverlayComponent()
323
+ }
324
+ }
325
+ }
326
+
327
+ @Composable
328
+ fun Footer(footerComponent: @Composable (() -> Unit)?, bottomPadding: Dp) {
329
+ if (footerComponent == null) return
330
+
331
+ val footerHeightPx = LocalFooterHeightPx.current
332
+
333
+ val shadowBrush = remember {
334
+ Brush.verticalGradient(
335
+ colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
336
+ )
337
+ }
338
+
339
+ Box(Modifier.onGloballyPositioned {
340
+ if (footerHeightPx.intValue != it.size.height) footerHeightPx.intValue = it.size.height
341
+ }) {
342
+ Box(Modifier
343
+ .fillMaxWidth()
344
+ .background(AppTheme.current.colors.background.surface)
345
+ .conditional(IsShowBaseLineDebug) {
346
+ border(1.dp, Colors.blue_03)
347
+ }
348
+ .padding(top = Spacing.S, start = Spacing.M, end = Spacing.M, bottom = bottomPadding + Spacing.S)
349
+ ){
350
+ footerComponent.invoke()
351
+ }
352
+
353
+ Box(modifier = Modifier
354
+ .fillMaxWidth()
355
+ .height(6.dp)
356
+ .offset(x = 0.dp, y = (-6).dp)
357
+ .background(shadowBrush)
358
+ )
359
+ }
360
+ }
361
+
362
+ data class InputSearchLayoutParams(
363
+ val topPadding: Dp,
364
+ val startPadding: Dp,
365
+ val endPadding: Dp
366
+ )
367
+ @Composable
368
+ fun SearchAnimated(
369
+ isScrollInProgress: Boolean
370
+ ) {
371
+ val scrollState = LocalScrollState.current
372
+ val options = LocalOptions.current
373
+ val navigator = LocalNavigator.current
374
+ val density = LocalDensity.current
375
+
376
+ val scrollDp = with(density) { scrollState.value.toDp() }
377
+
378
+ val inputSearchType = getInputSearchType(options)
379
+ val headerRightWidthPx = LocalHeaderRightWidthPx.current
380
+ val headerRightWidthDp = with(density) { headerRightWidthPx.intValue.toDp() }
381
+
382
+ if (inputSearchType == InputSearchType.None) return
383
+ val inputSearchProps = (options.headerType as? HeaderType.DefaultOrExtended)?.inputSearchProps ?: return
384
+
385
+ val minTopPadding = AppStatusBar.current
386
+ val maxTopPadding = AppStatusBar.current + HEADER_HEIGHT.dp
387
+ val minStartPadding = Spacing.M
388
+ val maxStartPadding = if (options.hiddenBack) Spacing.M else 52.dp
389
+ val minEndPadding = Spacing.M
390
+ val maxEndPadding = headerRightWidthDp + if (options.headerRight is HeaderRight.None) Spacing.M else Spacing.M * 2
391
+
392
+ val targetColor = lerp(
393
+ AppTheme.current.colors.background.surface,
394
+ AppTheme.current.colors.background.default,
395
+ (scrollDp / minTopPadding).coerceIn(0f, 1f)
396
+ )
397
+ val animatedColor by animateColorAsState(targetValue = targetColor, label = "BackgroundColor")
398
+
399
+ val layoutParams = when (inputSearchType) {
400
+ InputSearchType.Header -> {
401
+ InputSearchLayoutParams(
402
+ topPadding = minTopPadding,
403
+ startPadding = maxStartPadding,
404
+ endPadding = maxEndPadding
405
+ )
406
+ }
407
+
408
+ InputSearchType.Animated -> {
409
+ val animatedTopPadding by animateDpAsState(
410
+ targetValue = (maxTopPadding - scrollDp).coerceIn(minTopPadding, maxTopPadding),
411
+ label = "AnimatedTopPadding"
412
+ )
413
+
414
+ val animatedStartPadding by animateDpAsState(
415
+ targetValue = (minStartPadding + scrollDp).coerceIn(minStartPadding, maxStartPadding),
416
+ label = "AnimatedStartPadding"
417
+ )
418
+
419
+ val animatedEndPadding by animateDpAsState(
420
+ targetValue = (minEndPadding + scrollDp).coerceIn(minEndPadding, maxEndPadding),
421
+ label = "AnimatedEndPadding"
422
+ )
423
+
424
+ val maxPadding = remember(maxTopPadding, maxStartPadding, maxEndPadding) {
425
+ maxOf(maxEndPadding, maxStartPadding, maxTopPadding)
426
+ }
427
+ val snapScrollValue = with(density) { maxPadding.toPx().toInt() }
428
+
429
+ LaunchedEffect(isScrollInProgress && scrollState.value != 0 && scrollState.value != snapScrollValue) {
430
+ if (scrollDp < maxPadding) {
431
+ if (!isScrollInProgress) {
432
+ val midpoint = (maxTopPadding - minTopPadding) / 2
433
+
434
+ if (scrollDp < midpoint) {
435
+ scrollState.animateScrollTo(0)
436
+ } else {
437
+ scrollState.animateScrollTo(snapScrollValue)
438
+ }
439
+ }
440
+ }
441
+ }
442
+
443
+ InputSearchLayoutParams(
444
+ topPadding = animatedTopPadding,
445
+ startPadding = animatedStartPadding,
446
+ endPadding = animatedEndPadding
447
+ )
448
+ }
449
+
450
+ InputSearchType.None -> return
451
+ }
452
+
453
+ Spacer(Modifier.height(layoutParams.topPadding))
454
+ Box(
455
+ modifier = Modifier
456
+ .height(HEADER_HEIGHT.dp)
457
+ .fillMaxWidth()
458
+ .padding(
459
+ start = layoutParams.startPadding,
460
+ end = layoutParams.endPadding
461
+ ),
462
+ contentAlignment = Alignment.Center
463
+ ) {
464
+ InputSearch(
465
+ inputSearchProps = inputSearchProps.copy(
466
+ backgroundColor = animatedColor,
467
+ onPressButtonText = {
468
+ navigator.pop()
469
+ }
470
+ )
471
+ )
472
+ }
473
+ }
474
+
475
+ @Composable
476
+ internal fun isKeyboardVisible(): Boolean {
477
+ val ime = WindowInsets.ime
478
+ val density = LocalDensity.current
479
+ return ime.getBottom(density) > 0
480
+ }
481
+ private fun quantize(value: Int, stepPx: Int): Int {
482
+ if (stepPx <= 1) return value
483
+ return (value / stepPx) * stepPx
484
+ }
485
+
486
+ @Composable
487
+ fun LazyListState.proxyScrollState(
488
+ thresholdPx: Int = 200,
489
+ stepPx: Int = 4
490
+ ): Pair<ScrollState, Boolean> {
491
+ val scrollState = rememberScrollState()
492
+ val locked = remember { mutableStateOf(false) }
493
+
494
+ LaunchedEffect(this, scrollState, thresholdPx, stepPx) {
495
+ snapshotFlow { firstVisibleItemIndex to firstVisibleItemScrollOffset }
496
+ .collect { (index, offset) ->
497
+ val rawTarget = if (index == 0) offset else SCROLLED_PAST_FIRST_ITEM_THRESHOLD
498
+ val shouldLock = rawTarget > thresholdPx
499
+ if (locked.value != shouldLock) locked.value = shouldLock
500
+
501
+ val desired = if (shouldLock) thresholdPx else quantize(rawTarget, stepPx)
502
+
503
+ if (scrollState.value != desired) {
504
+ scrollState.scrollTo(desired.coerceAtLeast(0))
505
+ }
506
+ }
507
+ }
508
+
509
+ val inProgress = remember { mutableStateOf(false) }
510
+ LaunchedEffect(this, thresholdPx) {
511
+ snapshotFlow { isScrollInProgress }
512
+ .collect { progressing ->
513
+ inProgress.value = if (locked.value) false else progressing
514
+ }
515
+ }
516
+
517
+ return scrollState to inProgress.value
518
+ }
519
+
520
+ @Composable
521
+ fun ScrollState.proxyLimitedScrollState(
522
+ thresholdPx: Int = 200,
523
+ stepPx: Int = 4
524
+ ): Pair<ScrollState, Boolean> {
525
+ val proxy = rememberScrollState()
526
+ val locked = remember { mutableStateOf(false) }
527
+
528
+ LaunchedEffect(this, proxy, thresholdPx, stepPx) {
529
+ snapshotFlow { value }
530
+ .collect { rawTarget ->
531
+ val shouldLock = rawTarget > thresholdPx
532
+ if (locked.value != shouldLock) locked.value = shouldLock
533
+
534
+ val desired = if (shouldLock) thresholdPx else quantize(rawTarget, stepPx)
535
+
536
+ if (proxy.value != desired) {
537
+ proxy.scrollTo(desired.coerceAtLeast(0))
538
+ }
539
+ }
540
+ }
541
+
542
+ val inProgress = remember { mutableStateOf(false) }
543
+ LaunchedEffect(this, thresholdPx) {
544
+ snapshotFlow { isScrollInProgress }
545
+ .collect { progressing ->
546
+ inProgress.value = if (locked.value) false else progressing
547
+ }
548
+ }
549
+
550
+ return proxy to inProgress.value
551
+ }
552
+
553
+ private const val SCROLLED_PAST_FIRST_ITEM_THRESHOLD = 10_000
554
+
555
+ internal val LocalScrollState = staticCompositionLocalOf<ScrollState> { error("No Scroll State provided") }
556
+ internal val LocalOptions = staticCompositionLocalOf<NavigationOptions> { error("No NavigationOptions provided") }
557
+
558
+ val StackScreenScrollableState = staticCompositionLocalOf<ScrollableState?> { null }
559
+
560
+ internal fun getInputSearchType(options: NavigationOptions): InputSearchType{
561
+ return when (val headerType = options.headerType) {
562
+ is HeaderType.DefaultOrExtended -> when {
563
+ headerType.inputSearchProps == null -> InputSearchType.None
564
+ headerType.useAnimated -> InputSearchType.Animated
565
+ else -> InputSearchType.Header
566
+ }
567
+ else -> InputSearchType.None
568
+ }
569
+ }