@momo-kits/native-kits 0.167.1-duo.3 → 0.167.1-duo.4-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 (187) hide show
  1. package/CLAUDE.md +17 -8
  2. package/build.gradle.kts +11 -0
  3. package/compose/build.gradle.kts +190 -0
  4. package/compose/build.gradle.kts.backup +190 -0
  5. package/compose/compose.podspec +47 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +151 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +52 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +124 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +183 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +207 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +39 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +293 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +831 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +110 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +378 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +82 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +356 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +113 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +475 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +266 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +240 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +264 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +334 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +98 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +310 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +323 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +199 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +91 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +552 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +88 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +234 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +188 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +16 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +188 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +297 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +157 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +299 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +129 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +106 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +393 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +622 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +175 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +232 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +381 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +83 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +105 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +347 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +37 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +169 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +71 -0
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +40 -0
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +213 -0
  136. package/gradle/libs.versions.toml +69 -0
  137. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  138. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  139. package/gradle.properties +26 -0
  140. package/gradlew +252 -0
  141. package/gradlew.bat +94 -0
  142. package/ios/Application/ApplicationEnvironment.swift +6 -0
  143. package/ios/Application/Components.swift +1 -3
  144. package/ios/Application/HeaderRight.swift +19 -27
  145. package/ios/Application/Navigation/BottomTab/BottomTab.swift +9 -30
  146. package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +2 -5
  147. package/ios/Application/Navigation/HeaderUser.swift +1 -7
  148. package/ios/Application/Navigation/NavigationContainer.swift +45 -45
  149. package/ios/Application/Navigation/Navigator.swift +122 -29
  150. package/ios/Application/Navigation/NavigatorManager.swift +13 -6
  151. package/ios/Application/Navigation/Overplay/BottomSheet.swift +4 -41
  152. package/ios/Application/Navigation/Overplay/ModalScreen.swift +1 -5
  153. package/ios/Application/Navigation/component/Header.swift +4 -12
  154. package/ios/Application/Navigation/component/HeaderBackground.swift +2 -3
  155. package/ios/Application/Navigation/component/NavigationFooter.swift +1 -1
  156. package/ios/Application/Navigation/component/NavigationHeaderRight.swift +9 -61
  157. package/ios/Application/StackScreen.swift +18 -135
  158. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +59 -5
  159. package/ios/Colors+Radius+Spacing/Colors.swift +1 -1
  160. package/ios/Extensions/Color++.swift +20 -9
  161. package/ios/Extensions/OptionalEnvironmentObject.swift +12 -0
  162. package/ios/Icon/Icon.swift +14 -22
  163. package/ios/Icon/Icons.swift +1329 -0
  164. package/ios/Image/Image.swift +16 -5
  165. package/ios/Lottie/LottieView.swift +4 -2
  166. package/ios/Popup/PopupDisplay.swift +68 -84
  167. package/ios/Popup/PopupNotify.swift +32 -43
  168. package/ios/Popup/PopupPromotion.swift +6 -18
  169. package/ios/Resources/dot_loading.json +558 -0
  170. package/ios/Resources/lottie_circle_loader.json +1 -0
  171. package/ios/Template/TrustBanner/TrustBanner.swift +69 -31
  172. package/ios/native-kits.podspec +1 -1
  173. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  174. package/ios-demo/README.md +120 -0
  175. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -1
  176. package/package.json +1 -1
  177. package/scripts/gen-ios-icons.mjs +36 -0
  178. package/settings.gradle.kts +64 -0
  179. package/.claude/scheduled_tasks.lock +0 -1
  180. package/.claude/settings.local.json +0 -185
  181. package/ios/Application/Layout/ScreenLayout.swift +0 -196
  182. package/ios/Application/Navigation/BottomTab/DuoTabBar.swift +0 -275
  183. package/ios/Application/Navigation/component/DuoScrollGradient.swift +0 -55
  184. package/ios/Application/Navigation/component/SideBar.swift +0 -155
  185. package/ios/Popup/PopupLayout.swift +0 -45
  186. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DuoTabDemo.swift +0 -76
  187. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IPhoneDuoDemo.swift +0 -170
@@ -0,0 +1,622 @@
1
+ package vn.momo.kits.navigation
2
+
3
+ import androidx.compose.animation.animateColorAsState
4
+ import androidx.compose.foundation.ScrollState
5
+ import androidx.compose.foundation.background
6
+ import androidx.compose.foundation.border
7
+ import androidx.compose.foundation.gestures.ScrollableState
8
+ import androidx.compose.foundation.gestures.animateScrollBy
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.asPaddingValues
15
+ import androidx.compose.foundation.layout.aspectRatio
16
+ import androidx.compose.foundation.layout.fillMaxSize
17
+ import androidx.compose.foundation.layout.fillMaxWidth
18
+ import androidx.compose.foundation.layout.height
19
+ import androidx.compose.foundation.layout.ime
20
+ import androidx.compose.foundation.layout.imePadding
21
+ import androidx.compose.foundation.layout.offset
22
+ import androidx.compose.foundation.layout.padding
23
+ import androidx.compose.foundation.lazy.LazyListState
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.State
31
+ import androidx.compose.runtime.getValue
32
+ import androidx.compose.runtime.mutableIntStateOf
33
+ import androidx.compose.runtime.mutableStateOf
34
+ import androidx.compose.runtime.remember
35
+ import androidx.compose.runtime.rememberUpdatedState
36
+ import androidx.compose.runtime.snapshotFlow
37
+ import androidx.compose.runtime.staticCompositionLocalOf
38
+ import androidx.compose.ui.Alignment
39
+ import androidx.compose.ui.Modifier
40
+ import androidx.compose.ui.graphics.Brush
41
+ import androidx.compose.ui.graphics.Color
42
+ import androidx.compose.ui.graphics.lerp
43
+ import androidx.compose.ui.layout.onGloballyPositioned
44
+ import androidx.compose.ui.platform.LocalDensity
45
+ import androidx.compose.ui.unit.Dp
46
+ import androidx.compose.ui.unit.dp
47
+ import androidx.compose.ui.unit.lerp
48
+ import androidx.compose.ui.zIndex
49
+ import kotlinx.coroutines.flow.Flow
50
+ import kotlinx.coroutines.flow.filter
51
+ import kotlinx.coroutines.launch
52
+ import vn.momo.kits.components.InputSearch
53
+ import vn.momo.kits.const.AppNavigationBar
54
+ import vn.momo.kits.const.AppTheme
55
+ import vn.momo.kits.application.IsShowBaseLineDebug
56
+ import vn.momo.kits.const.Colors
57
+ import vn.momo.kits.const.Spacing
58
+ import vn.momo.kits.modifier.conditional
59
+ import vn.momo.kits.modifier.hideKeyboardOnTap
60
+ import vn.momo.kits.navigation.bottomtab.BOTTOM_TAB_BAR_HEIGHT
61
+ import vn.momo.kits.navigation.component.FABPosition
62
+ import vn.momo.kits.navigation.component.FloatingButton
63
+ import vn.momo.kits.navigation.component.HEADER_HEIGHT
64
+ import vn.momo.kits.navigation.component.Header
65
+ import vn.momo.kits.navigation.component.HeaderBackground
66
+ import vn.momo.kits.navigation.component.HeaderRight
67
+ import vn.momo.kits.navigation.component.HeaderSideBar
68
+ import vn.momo.kits.navigation.component.HeaderType
69
+ import vn.momo.kits.navigation.component.InputSearchType
70
+ import vn.momo.kits.platform.BackHandler
71
+ import vn.momo.kits.platform.supportsImePadding
72
+ import vn.momo.kits.navigation.tracking.ScreenTracker
73
+ import vn.momo.kits.navigation.tracking.ScreenTrackingState
74
+ import kotlinx.coroutines.delay
75
+ import vn.momo.kits.application.LocalContext
76
+ import vn.momo.kits.utils.horizontalSafeAreaPadding
77
+ import vn.momo.kits.layout.LocalScreenLayout
78
+ import vn.momo.kits.layout.consumeHorizontalInsets
79
+ import vn.momo.kits.layout.getScreenLayout
80
+ import kotlin.time.Clock
81
+ import kotlin.time.Duration.Companion.milliseconds
82
+ import kotlin.time.ExperimentalTime
83
+
84
+ internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
85
+ internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
86
+
87
+ @Composable
88
+ private fun bottomTabBarInset(): Dp {
89
+ if (LocalNavigation.current.bottomTabIndex == -1) return 0.dp
90
+ val keyboard = keyboardSizeState().value
91
+ return (BOTTOM_TAB_BAR_HEIGHT.dp + Spacing.S - keyboard).coerceAtLeast(0.dp)
92
+ }
93
+
94
+ @OptIn(ExperimentalMaterialApi::class, ExperimentalTime::class)
95
+ @Composable
96
+ internal fun StackScreen(
97
+ content: @Composable () -> Unit,
98
+ navigationOptions: NavigationOptions? = null,
99
+ id: Int = -1,
100
+ name: String = "",
101
+ bottomTabIndex: Int = -1,
102
+ onBackHandler: (() -> Unit)? = null,
103
+ ) {
104
+ val navigator = LocalNavigator.current
105
+ val maxApi = LocalMaxApi.current
106
+ val context = LocalContext.current
107
+ val screenLayout = getScreenLayout()
108
+ val density = LocalDensity.current
109
+ val screenRegistry = LocalDynamicScreenRegistry.current
110
+ val navigation = remember { Navigation(id = id, bottomTabIndex = bottomTabIndex, initOptions = navigationOptions, registry = screenRegistry) }
111
+
112
+ val options by navigation.currentOptions
113
+ val isBottomTabChild = bottomTabIndex != -1
114
+ val isBottomTabRoot = navigation.isBottomTabRoot
115
+
116
+ // Auto tracking state
117
+ val trackingState = remember {
118
+ ScreenTrackingState().apply {
119
+ time = Clock.System.now().toEpochMilliseconds()
120
+ }
121
+ }
122
+
123
+ // Determine action: push or back
124
+ val action = remember {
125
+ if (ScreenTracker.getLastScreenName() != null) "push" else "back"
126
+ }
127
+
128
+ // Auto tracking effects
129
+ LaunchedEffect(name) {
130
+ // Track screen navigated immediately
131
+ ScreenTracker.trackScreenNavigated(
132
+ maxApi = maxApi,
133
+ context = context,
134
+ screenName = name,
135
+ action = action,
136
+ state = trackingState
137
+ )
138
+
139
+ // Track screen displayed after 2 seconds (debounce)
140
+ delay(2000.milliseconds)
141
+ val loadTime = Clock.System.now().toEpochMilliseconds() - trackingState.time
142
+ ScreenTracker.trackScreenDisplayed(
143
+ maxApi = maxApi,
144
+ context = context,
145
+ screenName = name,
146
+ duration = loadTime,
147
+ state = trackingState
148
+ )
149
+
150
+ // Track screen interacted after displayed
151
+ val interactionTime = Clock.System.now().toEpochMilliseconds() - trackingState.time
152
+ ScreenTracker.trackScreenInteracted(
153
+ maxApi = maxApi,
154
+ context = context,
155
+ screenName = name,
156
+ duration = interactionTime - loadTime,
157
+ totalDuration = interactionTime,
158
+ state = trackingState
159
+ )
160
+ }
161
+
162
+ val limit = with(density) {
163
+ screenLayout.headerHeight.toPx()
164
+ }.toInt()
165
+
166
+ val lazyListState = options.scrollData.scrollState as? LazyListState
167
+ val (scrollState, _) = if (lazyListState != null)
168
+ lazyListState.proxyScrollState(limit, 1)
169
+ else
170
+ (options.scrollData.scrollState as? ScrollState ?: rememberScrollState()).proxyLimitedScrollState(limit, 1)
171
+ val snapState: ScrollableState = lazyListState ?: scrollState
172
+
173
+ val footerHeightPx = remember { mutableIntStateOf(0) }
174
+ val headerRightWidthPx = remember { mutableIntStateOf(0) }
175
+
176
+ if (navigation.options.scrollData.scrollToTopCallback != null) {
177
+ RegisterScrollToTop(navigation.options.scrollData.scrollToTopCallback)
178
+ }
179
+
180
+ val canPop = navigator.canPop()
181
+
182
+ val hasCustomBackHandling = !SwipeBackConfig.enabled ||
183
+ OverplayComponentRegistry.isOverplayShowing() ||
184
+ !canPop
185
+
186
+ BackHandler(hasCustomBackHandling) { navigator.onBackSafe() }
187
+
188
+ CompositionLocalProvider(
189
+ StackScreenScrollableState provides options.scrollData.scrollState,
190
+ LocalNavigation provides navigation,
191
+ LocalScrollState provides scrollState,
192
+ LocalOptions provides options,
193
+ LocalFooterHeightPx provides footerHeightPx,
194
+ LocalHeaderRightWidthPx provides headerRightWidthPx
195
+ ) {
196
+ Box(
197
+ Modifier
198
+ .fillMaxSize()
199
+ .background(options.backgroundColor ?: AppTheme.current.colors.background.default)
200
+ .conditional(options.keyboardOptions.keyboardShouldPersistTaps) {
201
+ hideKeyboardOnTap()
202
+ }
203
+ .conditional(options.keyboardOptions.useAvoidKeyboard && supportsImePadding()) {
204
+ imePadding()
205
+ }
206
+ ) {
207
+ Box(Modifier.zIndex(1f)) {
208
+ HeaderBackground()
209
+ }
210
+
211
+ Box(Modifier.zIndex(4f)) {
212
+ Header(onBackHandler)
213
+ }
214
+
215
+ HeaderSideBar(bottomInset = bottomBarsHeight(isBottomTabChild), modifier = Modifier.zIndex(4f))
216
+
217
+ Column(Modifier.zIndex(5f).horizontalSafeAreaPadding()) {
218
+ SearchAnimated(snapState = snapState)
219
+ }
220
+
221
+ Column(Modifier.zIndex(2f).fillMaxSize()) {
222
+ MainContent(content = content, isBottomTabRoot = isBottomTabRoot, isBottomTabChild = isBottomTabChild)
223
+ FooterContent()
224
+ }
225
+
226
+ Box(Modifier.zIndex(6f).horizontalSafeAreaPadding()) {
227
+ FloatingContent(isBottomTabChild = isBottomTabChild)
228
+ }
229
+
230
+ OverplayView(isBottomTabChild = isBottomTabChild, id = id)
231
+ }
232
+ }
233
+ }
234
+
235
+ // Height the footer, tab bar or home indicator takes from the bottom of the screen.
236
+ @Composable
237
+ private fun bottomBarsHeight(isBottomTabChild: Boolean): Dp {
238
+ val options = LocalOptions.current
239
+ val navigationBar = AppNavigationBar.current
240
+ return when {
241
+ options.hasFooter() -> with(LocalDensity.current) { LocalFooterHeightPx.current.intValue.toDp() }
242
+ isBottomTabChild -> bottomTabBarInset() + (navigationBar - keyboardSizeState().value).coerceAtLeast(0.dp)
243
+ else -> navigationBar
244
+ }
245
+ }
246
+
247
+ @Suppress("FrequentlyChangingValue")
248
+ @Composable
249
+ internal fun FloatingContent(isBottomTabChild: Boolean) {
250
+ val options = LocalOptions.current
251
+ val scrollState = LocalScrollState.current
252
+
253
+ val fabProps = options.floatingButtonProps ?: return
254
+ val bottomPadding = fabProps.bottom ?: (Spacing.M + bottomBarsHeight(isBottomTabChild))
255
+
256
+ FloatingButton(
257
+ scrollPosition = fabProps.scrollState?.value ?: scrollState.value,
258
+ onClick = fabProps.onClick,
259
+ containerColor = AppTheme.current.colors.primary,
260
+ bottom = bottomPadding,
261
+ icon = fabProps.icon,
262
+ iconColor = fabProps.iconColor,
263
+ text = fabProps.label,
264
+ size = fabProps.size,
265
+ position = fabProps.position ?: FABPosition.END,
266
+ )
267
+ }
268
+
269
+ @Composable
270
+ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTabRoot: Boolean, isBottomTabChild: Boolean) {
271
+ val options = LocalOptions.current
272
+ val inputSearchType = getInputSearchType(options)
273
+ val density = LocalDensity.current
274
+ val scrollState = LocalScrollState.current
275
+ val navigationBar = AppNavigationBar.current
276
+ val screenLayout = getScreenLayout()
277
+
278
+ Spacer(
279
+ Modifier.height(
280
+ if (options.headerType is HeaderType.DefaultOrExtended || (options.headerType is HeaderType.Transparent && !options.headerType.isFullScreenContent))
281
+ screenLayout.headerHeight else 0.dp
282
+ )
283
+ )
284
+ if (inputSearchType == InputSearchType.Animated) {
285
+ val scrollDp = with(density) { scrollState.value.toDp() }
286
+
287
+ Spacer(Modifier.height((HEADER_HEIGHT.dp - scrollDp).coerceIn(0.dp, HEADER_HEIGHT.dp)))
288
+ }
289
+ // a bottom tab root stays full width: the tab bar and each tab's own StackScreen handle the insets
290
+ Column(
291
+ Modifier
292
+ .fillMaxWidth()
293
+ .weight(1f)
294
+ .conditional(!isBottomTabRoot) {
295
+ horizontalSafeAreaPadding()
296
+ }
297
+ .conditional(options.scrollData.scrollable && options.scrollData.scrollState is ScrollState) {
298
+ verticalScroll(scrollState)
299
+ }
300
+ .padding(
301
+ bottom = when {
302
+ options.hasFooter() || isBottomTabRoot -> 0.dp
303
+ isBottomTabChild -> bottomTabBarInset() + (navigationBar - keyboardSizeState().value).coerceAtLeast(0.dp)
304
+ !options.scrollData.scrollable && options.scrollData.scrollState == null -> 0.dp
305
+ else -> navigationBar
306
+ }
307
+ )
308
+ ) {
309
+ CompositionLocalProvider(
310
+ LocalScreenLayout provides if (isBottomTabRoot) screenLayout else screenLayout.consumeHorizontalInsets()
311
+ ) {
312
+ ScreenContent(content = content)
313
+ }
314
+ }
315
+
316
+ }
317
+
318
+ @Composable
319
+ internal fun ScreenContent(content: @Composable () -> Unit) {
320
+ val scrollState = LocalScrollState.current
321
+ val options = LocalOptions.current
322
+
323
+ if (options.headerType is HeaderType.Animated) {
324
+ val animatedHeader = options.headerType
325
+ Box {
326
+ val bannerModifier = animatedHeader.height
327
+ ?.let { Modifier.fillMaxWidth().height(it) }
328
+ ?: Modifier.fillMaxWidth().aspectRatio(animatedHeader.aspectRatio.value)
329
+ Box(bannerModifier) {
330
+ animatedHeader.composable.invoke(scrollState.value)
331
+ }
332
+ Box(Modifier.padding(top = getScreenLayout().headerHeight + animatedHeader.layoutOffSet)) {
333
+ content()
334
+ }
335
+ }
336
+ } else {
337
+ content()
338
+ }
339
+ }
340
+
341
+ @Composable
342
+ internal fun FooterContent() {
343
+ val options = LocalOptions.current
344
+ if (options.hasFooter()) {
345
+ val keyboardSize = keyboardSizeState()
346
+ val bottomPadding = (AppNavigationBar.current - keyboardSize.value).coerceAtLeast(0.dp)
347
+ Footer(
348
+ footerComponent = options.footerComponent,
349
+ bottomPadding = bottomPadding,
350
+ transparent = options.footerTransparent,
351
+ useMargin = options.footerUseMargin
352
+ )
353
+ }
354
+ }
355
+
356
+ @Composable
357
+ internal fun keyboardSizeState(): State<Dp> {
358
+ val bottom = WindowInsets.ime.asPaddingValues()
359
+ return rememberUpdatedState(bottom.calculateBottomPadding())
360
+ }
361
+
362
+ @Composable
363
+ internal fun OverplayView(isBottomTabChild: Boolean, id: Int) {
364
+ val overplayType = OverplayComponentRegistry.getOverplayType()
365
+
366
+ if (overplayType != null) {
367
+ Box(Modifier.zIndex(if (overplayType == OverplayComponentType.SNACK_BAR) 3f else 7f).fillMaxSize()) {
368
+ if (isBottomTabChild) return@Box
369
+ if (OverplayComponentRegistry.currentRootId() != id) return@Box
370
+ OverplayComponentRegistry.OverlayComponent()
371
+ }
372
+ }
373
+ }
374
+
375
+ @Composable
376
+ fun Footer(
377
+ footerComponent: @Composable (() -> Unit)?,
378
+ bottomPadding: Dp,
379
+ transparent: Boolean = false,
380
+ useMargin: Boolean = true,
381
+ ) {
382
+ if (footerComponent == null) return
383
+
384
+ val footerHeightPx = LocalFooterHeightPx.current
385
+
386
+ val shadowBrush = remember {
387
+ Brush.verticalGradient(
388
+ colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
389
+ )
390
+ }
391
+
392
+ val backgroundColor = if (transparent) Color.Transparent else AppTheme.current.colors.background.surface
393
+
394
+ Box(Modifier.onGloballyPositioned {
395
+ if (footerHeightPx.intValue != it.size.height) footerHeightPx.intValue = it.size.height
396
+ }) {
397
+ Box(
398
+ Modifier
399
+ .fillMaxWidth()
400
+ .background(backgroundColor)
401
+ .conditional(IsShowBaseLineDebug) {
402
+ border(1.dp, Colors.blue_03)
403
+ }
404
+ .horizontalSafeAreaPadding()
405
+ .padding(
406
+ top = if (useMargin) Spacing.S else 0.dp,
407
+ start = if (useMargin) Spacing.M else 0.dp,
408
+ end = if (useMargin) Spacing.M else 0.dp,
409
+ bottom = bottomPadding + if (useMargin) Spacing.S else 0.dp,
410
+ )
411
+ ) {
412
+ footerComponent.invoke()
413
+ }
414
+
415
+ if (!transparent) {
416
+ Box(
417
+ modifier = Modifier
418
+ .fillMaxWidth()
419
+ .height(6.dp)
420
+ .offset(x = 0.dp, y = (-6).dp)
421
+ .background(shadowBrush)
422
+ )
423
+ }
424
+ }
425
+ }
426
+
427
+ data class InputSearchLayoutParams(
428
+ val topPadding: Dp,
429
+ val startPadding: Dp,
430
+ val endPadding: Dp
431
+ )
432
+
433
+ @Suppress("FrequentlyChangingValue")
434
+ @Composable
435
+ internal fun SearchAnimated(
436
+ snapState: ScrollableState
437
+ ) {
438
+ val scrollState = LocalScrollState.current
439
+ val options = LocalOptions.current
440
+ val navigator = LocalNavigator.current
441
+ val density = LocalDensity.current
442
+
443
+ val scrollDp = with(density) { scrollState.value.toDp() }
444
+
445
+ val inputSearchType = getInputSearchType(options)
446
+ val headerRightWidthPx = LocalHeaderRightWidthPx.current
447
+ val headerRightWidthDp = with(density) { headerRightWidthPx.intValue.toDp() }
448
+
449
+ if (inputSearchType == InputSearchType.None) return
450
+ val inputSearchProps = (options.headerType as? HeaderType.DefaultOrExtended)?.inputSearchProps ?: return
451
+
452
+ val screenLayout = getScreenLayout()
453
+ val useSideBar = screenLayout.sideBar != null
454
+ // collapsed, the search is centered in the bar row
455
+ val minTopPadding = screenLayout.headerStatusBarHeight + (screenLayout.headerBarHeight - HEADER_HEIGHT.dp) / 2
456
+ val maxTopPadding = screenLayout.headerHeight
457
+ val minStartPadding = Spacing.M
458
+ val maxStartPadding = if (options.hiddenBack || useSideBar) Spacing.M else 48.dp // button back: size + left +right = 28 + 12 + 8 = 48
459
+ val minEndPadding = Spacing.M
460
+ val maxEndPadding = when {
461
+ options.headerRight is HeaderRight.None -> Spacing.M
462
+ useSideBar && options.headerRight is HeaderRight.Toolkit -> Spacing.M
463
+ else -> headerRightWidthDp + Spacing.M * 2
464
+ }
465
+
466
+ val targetColor = lerp(
467
+ AppTheme.current.colors.background.surface,
468
+ AppTheme.current.colors.background.default,
469
+ (scrollDp / minTopPadding.coerceAtLeast(1.dp)).coerceIn(0f, 1f)
470
+ )
471
+ val animatedColor by animateColorAsState(targetValue = targetColor, label = "BackgroundColor")
472
+
473
+ val layoutParams = when (inputSearchType) {
474
+ InputSearchType.Header -> {
475
+ InputSearchLayoutParams(
476
+ topPadding = minTopPadding,
477
+ startPadding = maxStartPadding,
478
+ endPadding = maxEndPadding
479
+ )
480
+ }
481
+
482
+ InputSearchType.Animated -> {
483
+ val collapsePx = with(density) { HEADER_HEIGHT.dp.roundToPx() }
484
+ val progress = (scrollState.value / collapsePx.toFloat()).coerceIn(0f, 1f)
485
+
486
+ LaunchedEffect(snapState, collapsePx) {
487
+ snapshotFlow { snapState.isScrollInProgress }
488
+ .filter { !it }
489
+ .collect {
490
+ val offset = snapState.headerOffsetPx() ?: return@collect
491
+ if (offset <= 0 || offset >= collapsePx) return@collect
492
+ val target = if (offset < collapsePx / 2) 0 else collapsePx
493
+ launch { snapState.animateScrollBy((target - offset).toFloat()) }
494
+ }
495
+ }
496
+
497
+ InputSearchLayoutParams(
498
+ topPadding = lerp(maxTopPadding, minTopPadding, progress),
499
+ startPadding = lerp(minStartPadding, maxStartPadding, progress),
500
+ endPadding = lerp(minEndPadding, maxEndPadding, progress)
501
+ )
502
+ }
503
+
504
+ InputSearchType.None -> return
505
+ }
506
+
507
+ Spacer(Modifier.height(layoutParams.topPadding))
508
+ Box(
509
+ modifier = Modifier
510
+ .height(HEADER_HEIGHT.dp)
511
+ .fillMaxWidth()
512
+ .padding(
513
+ start = layoutParams.startPadding,
514
+ end = layoutParams.endPadding
515
+ ),
516
+ contentAlignment = Alignment.Center
517
+ ) {
518
+ InputSearch(
519
+ inputSearchProps = inputSearchProps.copy(
520
+ backgroundColor = animatedColor,
521
+ onPressButtonText = {
522
+ navigator.pop()
523
+ }
524
+ )
525
+ )
526
+ }
527
+ }
528
+
529
+ private fun ScrollableState.headerOffsetPx(): Int? = when (this) {
530
+ is LazyListState -> if (firstVisibleItemIndex == 0) firstVisibleItemScrollOffset else null
531
+ is ScrollState -> value
532
+ else -> null
533
+ }
534
+
535
+ private fun quantize(value: Int, stepPx: Int): Int {
536
+ if (stepPx <= 1) return value
537
+ return (value / stepPx) * stepPx
538
+ }
539
+
540
+ @Composable
541
+ internal fun LazyListState.proxyScrollState(
542
+ thresholdPx: Int = 200,
543
+ stepPx: Int = 4
544
+ ): Pair<ScrollState, Boolean> = proxyScroll(
545
+ source = this,
546
+ thresholdPx = thresholdPx,
547
+ stepPx = stepPx,
548
+ isScrollInProgress = { isScrollInProgress },
549
+ rawTargetFlow = {
550
+ snapshotFlow {
551
+ if (firstVisibleItemIndex == 0) firstVisibleItemScrollOffset
552
+ else SCROLLED_PAST_FIRST_ITEM_THRESHOLD
553
+ }
554
+ },
555
+ )
556
+
557
+ @Composable
558
+ internal fun ScrollState.proxyLimitedScrollState(
559
+ thresholdPx: Int = 200,
560
+ stepPx: Int = 4
561
+ ): Pair<ScrollState, Boolean> = proxyScroll(
562
+ source = this,
563
+ thresholdPx = thresholdPx,
564
+ stepPx = stepPx,
565
+ isScrollInProgress = { isScrollInProgress },
566
+ rawTargetFlow = { snapshotFlow { value } },
567
+ )
568
+
569
+ @Composable
570
+ private fun proxyScroll(
571
+ source: Any,
572
+ thresholdPx: Int,
573
+ stepPx: Int,
574
+ isScrollInProgress: () -> Boolean,
575
+ rawTargetFlow: () -> Flow<Int>,
576
+ ): Pair<ScrollState, Boolean> {
577
+ val proxy = rememberScrollState()
578
+ val locked = remember { mutableStateOf(false) }
579
+
580
+ LaunchedEffect(source, proxy, thresholdPx, stepPx) {
581
+ rawTargetFlow().collect { rawTarget ->
582
+ val shouldLock = rawTarget > thresholdPx
583
+ if (locked.value != shouldLock) locked.value = shouldLock
584
+
585
+ val desired = if (shouldLock) thresholdPx else quantize(rawTarget, stepPx)
586
+
587
+ if (proxy.value != desired) {
588
+ proxy.scrollTo(desired.coerceAtLeast(0))
589
+ }
590
+ }
591
+ }
592
+
593
+ val inProgress = remember { mutableStateOf(false) }
594
+ LaunchedEffect(source, thresholdPx) {
595
+ snapshotFlow { isScrollInProgress() }
596
+ .collect { progressing ->
597
+ inProgress.value = if (locked.value) false else progressing
598
+ }
599
+ }
600
+
601
+ return proxy to inProgress.value
602
+ }
603
+
604
+ private const val SCROLLED_PAST_FIRST_ITEM_THRESHOLD = 10_000
605
+
606
+ internal val LocalScrollState = staticCompositionLocalOf<ScrollState> { error("No Scroll State provided") }
607
+ internal val LocalOptions = staticCompositionLocalOf<NavigationOptions> { error("No NavigationOptions provided") }
608
+
609
+ val StackScreenScrollableState = staticCompositionLocalOf<ScrollableState?> { null }
610
+
611
+ internal fun getInputSearchType(options: NavigationOptions): InputSearchType {
612
+ return when (val headerType = options.headerType) {
613
+ is HeaderType.DefaultOrExtended -> when {
614
+ headerType.inputSearchProps == null -> InputSearchType.None
615
+ headerType.useAnimated -> InputSearchType.Animated
616
+ else -> InputSearchType.Header
617
+ }
618
+
619
+ else -> InputSearchType.None
620
+ }
621
+ }
622
+