@momo-kits/native-kits 0.169.10-beta.1 → 0.169.10-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 (188) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +198 -0
  3. package/compose/compose.podspec +47 -0
  4. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +315 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +113 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +206 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +421 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +730 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +242 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +456 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +401 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +204 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -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 +55 -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 +117 -0
  123. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +143 -0
  131. package/gradle/libs.versions.toml +67 -0
  132. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  133. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  134. package/gradle.properties +24 -0
  135. package/gradlew +252 -0
  136. package/gradlew.bat +94 -0
  137. package/ios/Application/DesignSystemKits.swift +2 -3
  138. package/ios/Application/LanguageSource.swift +2 -3
  139. package/ios/Application/Localize.swift +4 -7
  140. package/ios/Application/LocalizeModifier.swift +2 -3
  141. package/ios/Badge/Badge.swift +5 -7
  142. package/ios/Button/Button.swift +2 -3
  143. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +3 -5
  144. package/ios/Carousel/Carousel.swift +2 -3
  145. package/ios/Collapse/Collapse.swift +17 -11
  146. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  147. package/ios/Icon/Icon.swift +2 -3
  148. package/ios/IconButton/IconButton.swift +2 -3
  149. package/ios/Input/InputSearch.swift +6 -23
  150. package/ios/Layout/ModalLayout.swift +2 -3
  151. package/ios/Layout/ScreenLayout.swift +10 -12
  152. package/ios/Layout/Section.swift +2 -3
  153. package/ios/Navigation/BottomSheet.swift +6 -9
  154. package/ios/Navigation/BottomTab/BottomTab.swift +6 -9
  155. package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -6
  156. package/ios/Navigation/BottomTab/CurvedContainer.swift +2 -3
  157. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  158. package/ios/Navigation/BottomTab/DuoTabBar.swift +6 -6
  159. package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -6
  160. package/ios/Navigation/Component/Header.swift +46 -31
  161. package/ios/Navigation/Component/HeaderJourney.swift +1 -2
  162. package/ios/Navigation/Component/HeaderLocation.swift +1 -2
  163. package/ios/Navigation/Component/HeaderRight.swift +15 -18
  164. package/ios/Navigation/Component/HeaderUser.swift +1 -2
  165. package/ios/Navigation/Component/SideBar.swift +15 -7
  166. package/ios/Navigation/HostBackGestureBridge.swift +2 -3
  167. package/ios/Navigation/ModalScreen.swift +13 -11
  168. package/ios/Navigation/Navigation.swift +3 -9
  169. package/ios/Navigation/NavigationContainer.swift +4 -6
  170. package/ios/Navigation/Navigator.swift +12 -18
  171. package/ios/Navigation/StackScreen.swift +25 -40
  172. package/ios/Navigation/StackTransition.swift +7 -6
  173. package/ios/Skeleton/Skeleton.swift +3 -6
  174. package/ios/Steps/Steps.swift +20 -15
  175. package/ios/TabView/TabView.swift +2 -3
  176. package/ios/Title/Title.swift +1 -3
  177. package/ios/Typography/FontScale.swift +6 -9
  178. package/ios/Typography/Text.swift +2 -3
  179. package/ios/Typography/Typography.swift +3 -4
  180. package/ios/native-kits.podspec +1 -1
  181. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  182. package/ios-demo/README.md +120 -0
  183. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
  184. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
  185. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
  186. package/package.json +1 -1
  187. package/settings.gradle.kts +64 -0
  188. package/ios/Layout/HeaderLayout.swift +0 -67
@@ -0,0 +1,730 @@
1
+ package vn.momo.kits.navigation
2
+
3
+ import androidx.compose.animation.animateColorAsState
4
+ import androidx.compose.animation.core.Animatable
5
+ import androidx.compose.animation.core.AnimationVector1D
6
+ import androidx.compose.animation.core.tween
7
+ import androidx.compose.foundation.ScrollState
8
+ import androidx.compose.foundation.background
9
+ import androidx.compose.foundation.border
10
+ import androidx.compose.foundation.gestures.ScrollableState
11
+ import androidx.compose.foundation.gestures.animateScrollBy
12
+ import androidx.compose.foundation.layout.Box
13
+ import androidx.compose.foundation.layout.Column
14
+ import androidx.compose.foundation.layout.ColumnScope
15
+ import androidx.compose.foundation.layout.Spacer
16
+ import androidx.compose.foundation.layout.WindowInsets
17
+ import androidx.compose.foundation.layout.asPaddingValues
18
+ import androidx.compose.foundation.layout.aspectRatio
19
+ import androidx.compose.foundation.layout.fillMaxSize
20
+ import androidx.compose.foundation.layout.fillMaxWidth
21
+ import androidx.compose.foundation.layout.height
22
+ import androidx.compose.foundation.layout.ime
23
+ import androidx.compose.foundation.layout.imePadding
24
+ import androidx.compose.foundation.layout.offset
25
+ import androidx.compose.foundation.layout.padding
26
+ import androidx.compose.foundation.lazy.LazyListState
27
+ import androidx.compose.foundation.rememberScrollState
28
+ import androidx.compose.foundation.verticalScroll
29
+ import androidx.compose.material.ExperimentalMaterialApi
30
+ import androidx.compose.runtime.Composable
31
+ import androidx.compose.runtime.CompositionLocalProvider
32
+ import androidx.compose.foundation.layout.PaddingValues
33
+ import androidx.compose.runtime.LaunchedEffect
34
+ import androidx.compose.runtime.State
35
+ import androidx.compose.runtime.getValue
36
+ import androidx.compose.runtime.mutableIntStateOf
37
+ import androidx.compose.runtime.mutableStateOf
38
+ import androidx.compose.runtime.remember
39
+ import androidx.compose.runtime.rememberUpdatedState
40
+ import androidx.compose.runtime.snapshotFlow
41
+ import androidx.compose.runtime.staticCompositionLocalOf
42
+ import androidx.compose.ui.Alignment
43
+ import androidx.compose.ui.Modifier
44
+ import androidx.compose.ui.graphics.Brush
45
+ import androidx.compose.ui.graphics.Color
46
+ import androidx.compose.ui.graphics.graphicsLayer
47
+ import androidx.compose.ui.graphics.lerp
48
+ import androidx.compose.ui.layout.onGloballyPositioned
49
+ import androidx.compose.ui.platform.LocalDensity
50
+ import androidx.compose.ui.unit.Dp
51
+ import androidx.compose.ui.unit.dp
52
+ import androidx.compose.ui.unit.lerp
53
+ import androidx.compose.ui.zIndex
54
+ import kotlinx.coroutines.flow.Flow
55
+ import kotlinx.coroutines.flow.filter
56
+ import kotlinx.coroutines.launch
57
+ import vn.momo.kits.components.InputSearch
58
+ import vn.momo.kits.const.AppNavigationBar
59
+ import vn.momo.kits.const.AppTheme
60
+ import vn.momo.kits.application.IsShowBaseLineDebug
61
+ import vn.momo.kits.const.Colors
62
+ import vn.momo.kits.const.Spacing
63
+ import vn.momo.kits.modifier.conditional
64
+ import vn.momo.kits.modifier.hideKeyboardOnTap
65
+ import vn.momo.kits.navigation.component.FABPosition
66
+ import vn.momo.kits.navigation.component.FloatingButton
67
+ import vn.momo.kits.navigation.component.HEADER_HEIGHT
68
+ import vn.momo.kits.navigation.component.Header
69
+ import vn.momo.kits.navigation.component.HeaderBackground
70
+ import vn.momo.kits.navigation.component.HeaderRight
71
+ import vn.momo.kits.navigation.component.HeaderSideBar
72
+ import vn.momo.kits.navigation.bottomtab.LocalDuoRailReserve
73
+ import vn.momo.kits.navigation.bottomtab.LocalTabBarHasCenterAction
74
+ import vn.momo.kits.navigation.bottomtab.duoFloatingTabBarInset
75
+ import vn.momo.kits.navigation.component.HeaderType
76
+ import vn.momo.kits.navigation.component.InputSearchType
77
+ import vn.momo.kits.navigation.bottomtab.LocalBottomTabFocused
78
+ import vn.momo.kits.platform.BackHandler
79
+ import vn.momo.kits.platform.supportsImePadding
80
+ import vn.momo.kits.navigation.tracking.ScreenTracker
81
+ import vn.momo.kits.navigation.tracking.ScreenTrackingState
82
+ import kotlinx.coroutines.delay
83
+ import vn.momo.kits.application.LocalContext
84
+ import vn.momo.kits.utils.horizontalSafeAreaPadding
85
+ import vn.momo.kits.layout.LocalScreenLayout
86
+ import vn.momo.kits.layout.ScreenLayout
87
+ import vn.momo.kits.layout.consumeHorizontalInsets
88
+ import vn.momo.kits.layout.DuoMetrics
89
+ import vn.momo.kits.layout.getScreenLayout
90
+ import kotlin.time.Clock
91
+ import kotlin.time.Duration.Companion.milliseconds
92
+ import kotlin.time.ExperimentalTime
93
+
94
+ @Composable
95
+ fun floatingTabBarContentPadding(): PaddingValues {
96
+ val navigation = LocalNavigation.current
97
+ LaunchedEffect(navigation) { navigation.bottomTabEdgeToEdge = true }
98
+ val reserve = navigation.bottomTabIndex != -1 && navigation.bottomTabEdgeToEdge
99
+ return PaddingValues(bottom = if (reserve) bottomTabChildInset() else 0.dp)
100
+ }
101
+
102
+ internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
103
+ internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
104
+
105
+ // Space a tab's content leaves for the tab bar and home indicator: the horizontal bar floats over the
106
+ // content (phone and unfolded Duo); the Duo rail lives in the side strip, so only the home indicator.
107
+ @Composable
108
+ private fun bottomTabChildInset(): Dp {
109
+ val keyboard = keyboardSizeState().value
110
+ val navigationBar = AppNavigationBar.current
111
+ val layout = getScreenLayout()
112
+ return when {
113
+ layout.isIPhoneDuo && layout.sideBar != null -> (navigationBar - keyboard).coerceAtLeast(0.dp)
114
+ else -> (duoFloatingTabBarInset(layout, LocalTabBarHasCenterAction.current) - keyboard).coerceAtLeast(0.dp)
115
+ }
116
+ }
117
+
118
+ @OptIn(ExperimentalMaterialApi::class, ExperimentalTime::class)
119
+ @Composable
120
+ internal fun StackScreen(
121
+ content: @Composable () -> Unit,
122
+ navigationOptions: NavigationOptions? = null,
123
+ id: Int = -1,
124
+ name: String = "",
125
+ bottomTabIndex: Int = -1,
126
+ onBackHandler: (() -> Unit)? = null,
127
+ ) {
128
+ val navigator = LocalNavigator.current
129
+ val maxApi = LocalMaxApi.current
130
+ val context = LocalContext.current
131
+ val screenLayout = getScreenLayout()
132
+ val density = LocalDensity.current
133
+ val screenRegistry = LocalDynamicScreenRegistry.current
134
+ val navigation = remember { Navigation(id = id, bottomTabIndex = bottomTabIndex, initOptions = navigationOptions, registry = screenRegistry) }
135
+
136
+ val options by navigation.currentOptions
137
+ val isBottomTabChild = bottomTabIndex != -1
138
+ val isBottomTabRoot = navigation.isBottomTabRoot
139
+
140
+ // A mounted-but-hidden bottom tab tracks again each time it is focused (RN useFocusEffect).
141
+ val tabFocused = LocalBottomTabFocused.current
142
+
143
+ val trackingState = remember(tabFocused) {
144
+ ScreenTrackingState().apply {
145
+ time = Clock.System.now().toEpochMilliseconds()
146
+ }
147
+ }
148
+
149
+ val action = remember(tabFocused) {
150
+ if (ScreenTracker.getLastScreenName() != null) "push" else "back"
151
+ }
152
+
153
+ LaunchedEffect(name, tabFocused) {
154
+ if (!tabFocused) return@LaunchedEffect
155
+ ScreenTracker.trackScreenNavigated(
156
+ maxApi = maxApi,
157
+ context = context,
158
+ screenName = name,
159
+ action = action,
160
+ state = trackingState
161
+ )
162
+
163
+ delay(2000.milliseconds)
164
+ val loadTime = Clock.System.now().toEpochMilliseconds() - trackingState.time
165
+ ScreenTracker.trackScreenDisplayed(
166
+ maxApi = maxApi,
167
+ context = context,
168
+ screenName = name,
169
+ duration = loadTime,
170
+ state = trackingState
171
+ )
172
+
173
+ val interactionTime = Clock.System.now().toEpochMilliseconds() - trackingState.time
174
+ ScreenTracker.trackScreenInteracted(
175
+ maxApi = maxApi,
176
+ context = context,
177
+ screenName = name,
178
+ duration = interactionTime - loadTime,
179
+ totalDuration = interactionTime,
180
+ state = trackingState
181
+ )
182
+ }
183
+
184
+ val limit = with(density) {
185
+ screenLayout.headerHeight.toPx()
186
+ }.toInt()
187
+
188
+ val lazyListState = options.scrollData.scrollState as? LazyListState
189
+ val (scrollState, _) = if (lazyListState != null)
190
+ lazyListState.proxyScrollState(limit, 1)
191
+ else
192
+ (options.scrollData.scrollState as? ScrollState ?: rememberScrollState()).proxyLimitedScrollState(limit, 1)
193
+ val snapState: ScrollableState = lazyListState ?: scrollState
194
+ val headerHide = rememberQuickReturnHide(
195
+ enabled = options.usesDuoQuickReturnHeader(screenLayout),
196
+ scrollState = scrollState,
197
+ heightPx = with(density) { screenLayout.headerHeight.toPx() },
198
+ )
199
+
200
+ val footerHeightPx = remember { mutableIntStateOf(0) }
201
+ val headerRightWidthPx = remember { mutableIntStateOf(0) }
202
+
203
+ if (tabFocused && navigation.options.scrollData.scrollToTopCallback != null) {
204
+ RegisterScrollToTop(navigation.options.scrollData.scrollToTopCallback)
205
+ }
206
+
207
+ val canPop = navigator.canPop()
208
+
209
+ val hasCustomBackHandling = !SwipeBackConfig.enabled || OverplayComponentRegistry.isOverplayShowing() || !canPop
210
+
211
+ BackHandler(hasCustomBackHandling) { navigator.onBackSafe() }
212
+
213
+ CompositionLocalProvider(
214
+ StackScreenScrollableState provides options.scrollData.scrollState,
215
+ LocalNavigation provides navigation,
216
+ LocalScrollState provides scrollState,
217
+ LocalOptions provides options,
218
+ LocalFooterHeightPx provides footerHeightPx,
219
+ LocalHeaderRightWidthPx provides headerRightWidthPx
220
+ ) {
221
+ Box(Modifier.fillMaxSize()) {
222
+ options.backgroundComponent?.let { background ->
223
+ Box(Modifier.fillMaxSize()) { background() }
224
+ }
225
+ Box(
226
+ Modifier
227
+ .fillMaxSize()
228
+ .background(
229
+ if (options.backgroundComponent != null) Color.Transparent
230
+ else options.backgroundColor ?: AppTheme.current.colors.background.default
231
+ )
232
+ .conditional(options.keyboardOptions.keyboardShouldPersistTaps) {
233
+ hideKeyboardOnTap()
234
+ }
235
+ .conditional(options.keyboardOptions.useAvoidKeyboard && supportsImePadding()) {
236
+ imePadding()
237
+ }
238
+ ) {
239
+ Box(Modifier.zIndex(1f)) {
240
+ HeaderBackground()
241
+ }
242
+
243
+ Box(Modifier.zIndex(4f).graphicsLayer { translationY = -headerHide.value }) {
244
+ Header(onBackHandler)
245
+ }
246
+
247
+ HeaderSideBar(
248
+ bottomInset = maxOf(
249
+ bottomBarsHeight(isBottomTabChild) + Spacing.XL,
250
+ if (isBottomTabChild) LocalDuoRailReserve.current else 0.dp,
251
+ ),
252
+ modifier = Modifier.zIndex(4f),
253
+ )
254
+
255
+ Column(Modifier.zIndex(5f).horizontalSafeAreaPadding()) {
256
+ SearchAnimated(snapState = snapState)
257
+ }
258
+
259
+ Column(Modifier.zIndex(2f).fillMaxSize()) {
260
+ MainContent(content = content, isBottomTabRoot = isBottomTabRoot, isBottomTabChild = isBottomTabChild)
261
+ FooterContent()
262
+ }
263
+
264
+ Box(Modifier.zIndex(6f).horizontalSafeAreaPadding()) {
265
+ FloatingContent(isBottomTabChild = isBottomTabChild)
266
+ }
267
+
268
+ OverplayView(isBottomTabChild = isBottomTabChild, id = id)
269
+ }
270
+ }
271
+ }
272
+ }
273
+
274
+ // Height the footer, tab bar or home indicator takes from the bottom of the screen.
275
+ @Composable
276
+ private fun bottomBarsHeight(isBottomTabChild: Boolean): Dp {
277
+ val options = LocalOptions.current
278
+ val navigationBar = AppNavigationBar.current
279
+ return when {
280
+ options.hasFooter() -> with(LocalDensity.current) { LocalFooterHeightPx.current.intValue.toDp() }
281
+ isBottomTabChild -> bottomTabChildInset()
282
+ else -> navigationBar
283
+ }
284
+ }
285
+
286
+ @Suppress("FrequentlyChangingValue")
287
+ @Composable
288
+ internal fun FloatingContent(isBottomTabChild: Boolean) {
289
+ val options = LocalOptions.current
290
+ val scrollState = LocalScrollState.current
291
+
292
+ val fabProps = options.floatingButtonProps ?: return
293
+ val bottomPadding = fabProps.bottom ?: (Spacing.M + bottomBarsHeight(isBottomTabChild))
294
+
295
+ FloatingButton(
296
+ scrollPosition = fabProps.scrollState?.value ?: scrollState.value,
297
+ onClick = fabProps.onClick,
298
+ containerColor = AppTheme.current.colors.primary,
299
+ bottom = bottomPadding,
300
+ icon = fabProps.icon,
301
+ iconColor = fabProps.iconColor,
302
+ text = fabProps.label,
303
+ size = fabProps.size,
304
+ position = fabProps.position ?: FABPosition.END,
305
+ )
306
+ }
307
+
308
+ @Composable
309
+ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTabRoot: Boolean, isBottomTabChild: Boolean) {
310
+ val options = LocalOptions.current
311
+ val inputSearchType = getInputSearchType(options)
312
+ val density = LocalDensity.current
313
+ val scrollState = LocalScrollState.current
314
+ val navigationBar = AppNavigationBar.current
315
+ val screenLayout = getScreenLayout()
316
+ val useDuoGlass = options.usesDuoGlassHeader(screenLayout)
317
+
318
+ Spacer(
319
+ Modifier.height(
320
+ if (!useDuoGlass && (options.headerType is HeaderType.DefaultOrExtended || (options.headerType is HeaderType.Transparent && !options.headerType.isFullScreenContent)))
321
+ screenLayout.headerHeight else 0.dp
322
+ )
323
+ )
324
+ if (inputSearchType == InputSearchType.Animated) {
325
+ val scrollDp = with(density) { scrollState.value.toDp() }
326
+
327
+ Spacer(Modifier.height((HEADER_HEIGHT.dp - scrollDp).coerceIn(0.dp, HEADER_HEIGHT.dp)))
328
+ }
329
+ val insetContent = !isBottomTabRoot
330
+ Column(
331
+ Modifier
332
+ .fillMaxWidth()
333
+ .weight(1f)
334
+ .conditional(insetContent && options.headerType !is HeaderType.Animated) {
335
+ horizontalSafeAreaPadding()
336
+ }
337
+ .conditional(options.scrollData.scrollable && options.scrollData.scrollState is ScrollState) {
338
+ verticalScroll(scrollState)
339
+ }
340
+ .conditional(useDuoGlass) {
341
+ padding(top = screenLayout.headerHeight)
342
+ }
343
+ .padding(
344
+ bottom = when {
345
+ options.hasFooter() || isBottomTabRoot -> 0.dp
346
+ // 0 when the tab pads itself via floatingTabBarContentPadding(), else the kit reserves the bar space
347
+ isBottomTabChild -> if (LocalNavigation.current.bottomTabEdgeToEdge) 0.dp else bottomTabChildInset()
348
+ !options.scrollData.scrollable && options.scrollData.scrollState == null -> 0.dp
349
+ else -> navigationBar
350
+ }
351
+ )
352
+ ) {
353
+ ScreenContent(content = content, insetContent = insetContent)
354
+ }
355
+
356
+ }
357
+
358
+ @Composable
359
+ internal fun ScreenContent(content: @Composable () -> Unit, insetContent: Boolean) {
360
+ val scrollState = LocalScrollState.current
361
+ val options = LocalOptions.current
362
+ val screenLayout = getScreenLayout()
363
+ val insetBody: @Composable () -> Unit = {
364
+ CompositionLocalProvider(
365
+ LocalScreenLayout provides if (insetContent) screenLayout.consumeHorizontalInsets() else screenLayout,
366
+ content = content,
367
+ )
368
+ }
369
+
370
+ if (options.headerType is HeaderType.Animated) {
371
+ val animatedHeader = options.headerType
372
+ Box {
373
+ val bannerModifier = animatedHeader.height
374
+ ?.let { Modifier.fillMaxWidth().height(it) }
375
+ ?: Modifier.fillMaxWidth().aspectRatio(animatedHeader.aspectRatio.value)
376
+ Box(bannerModifier) {
377
+ animatedHeader.composable.invoke(scrollState.value)
378
+ }
379
+ Box(
380
+ Modifier
381
+ .padding(top = screenLayout.headerHeight + animatedHeader.layoutOffSet)
382
+ .conditional(insetContent) { horizontalSafeAreaPadding() }
383
+ ) {
384
+ insetBody()
385
+ }
386
+ }
387
+ } else {
388
+ insetBody()
389
+ }
390
+ }
391
+
392
+ @Composable
393
+ internal fun FooterContent() {
394
+ val options = LocalOptions.current
395
+ if (options.hasFooter()) {
396
+ val keyboardSize = keyboardSizeState()
397
+ // the floating tab bar overlays tab content, so a tab's footer sits above it
398
+ val duoTabInset = if (LocalNavigation.current.bottomTabIndex != -1) duoFloatingTabBarInset(getScreenLayout(), LocalTabBarHasCenterAction.current) else 0.dp
399
+ val bottomPadding = (maxOf(AppNavigationBar.current, duoTabInset) - keyboardSize.value).coerceAtLeast(0.dp)
400
+ Footer(
401
+ footerComponent = options.footerComponent,
402
+ bottomPadding = bottomPadding,
403
+ transparent = options.footerTransparent,
404
+ useMargin = options.footerUseMargin
405
+ )
406
+ }
407
+ }
408
+
409
+ @Composable
410
+ internal fun keyboardSizeState(): State<Dp> {
411
+ val bottom = WindowInsets.ime.asPaddingValues()
412
+ return rememberUpdatedState(bottom.calculateBottomPadding())
413
+ }
414
+
415
+ @Composable
416
+ internal fun OverplayView(isBottomTabChild: Boolean, id: Int) {
417
+ val overplayType = OverplayComponentRegistry.getOverplayType()
418
+
419
+ if (overplayType != null) {
420
+ Box(Modifier.zIndex(if (overplayType == OverplayComponentType.SNACK_BAR) 3f else 7f).fillMaxSize()) {
421
+ if (isBottomTabChild) return@Box
422
+ if (OverplayComponentRegistry.currentRootId() != id) return@Box
423
+ OverplayComponentRegistry.OverlayComponent()
424
+ }
425
+ }
426
+ }
427
+
428
+ @Composable
429
+ fun Footer(
430
+ footerComponent: @Composable (() -> Unit)?,
431
+ bottomPadding: Dp,
432
+ transparent: Boolean = false,
433
+ useMargin: Boolean = true,
434
+ ) {
435
+ if (footerComponent == null) return
436
+
437
+ val footerHeightPx = LocalFooterHeightPx.current
438
+
439
+ val shadowBrush = remember {
440
+ Brush.verticalGradient(
441
+ colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
442
+ )
443
+ }
444
+
445
+ val backgroundColor = if (transparent) Color.Transparent else AppTheme.current.colors.background.surface
446
+
447
+ // inset as a whole, not padded inside, so the surface and its shadow stay off the iPhone Duo side bar
448
+ Box(Modifier.onGloballyPositioned {
449
+ if (footerHeightPx.intValue != it.size.height) footerHeightPx.intValue = it.size.height
450
+ }.horizontalSafeAreaPadding()) {
451
+ Box(
452
+ Modifier
453
+ .fillMaxWidth()
454
+ .background(backgroundColor)
455
+ .conditional(IsShowBaseLineDebug) {
456
+ border(1.dp, Colors.blue_03)
457
+ }
458
+ .padding(
459
+ top = if (useMargin) Spacing.S else 0.dp,
460
+ start = if (useMargin) Spacing.M else 0.dp,
461
+ end = if (useMargin) Spacing.M else 0.dp,
462
+ bottom = bottomPadding + if (useMargin) Spacing.S else 0.dp,
463
+ )
464
+ ) {
465
+ footerComponent.invoke()
466
+ }
467
+
468
+ if (!transparent) {
469
+ Box(
470
+ modifier = Modifier
471
+ .fillMaxWidth()
472
+ .height(6.dp)
473
+ .offset(x = 0.dp, y = (-6).dp)
474
+ .background(shadowBrush)
475
+ )
476
+ }
477
+ }
478
+ }
479
+
480
+ data class InputSearchLayoutParams(
481
+ val topPadding: Dp,
482
+ val startPadding: Dp,
483
+ val endPadding: Dp
484
+ )
485
+
486
+ @Suppress("FrequentlyChangingValue")
487
+ @Composable
488
+ internal fun SearchAnimated(
489
+ snapState: ScrollableState
490
+ ) {
491
+ val scrollState = LocalScrollState.current
492
+ val options = LocalOptions.current
493
+ val navigator = LocalNavigator.current
494
+ val density = LocalDensity.current
495
+
496
+ val scrollDp = with(density) { scrollState.value.toDp() }
497
+
498
+ val inputSearchType = getInputSearchType(options)
499
+ val headerRightWidthPx = LocalHeaderRightWidthPx.current
500
+ val headerRightWidthDp = with(density) { headerRightWidthPx.intValue.toDp() }
501
+
502
+ if (inputSearchType == InputSearchType.None) return
503
+ val inputSearchProps = (options.headerType as? HeaderType.DefaultOrExtended)?.inputSearchProps ?: return
504
+
505
+ val screenLayout = getScreenLayout()
506
+ val useSideBar = screenLayout.sideBar != null
507
+ // collapsed, the search is centered in the bar row
508
+ val minTopPadding = screenLayout.headerStatusBarHeight + (screenLayout.headerBarHeight - HEADER_HEIGHT.dp) / 2
509
+ val maxTopPadding = screenLayout.headerHeight
510
+ // collapsed on the iPhone Duo status bar row, the search stays between its clusters (48pt back there)
511
+ val clearance = screenLayout.statusBarClearance
512
+ val backWidth = if (clearance != null && !useSideBar) DuoMetrics.controlSize else 28.dp
513
+ val minStartPadding = Spacing.M
514
+ val maxStartPadding = (clearance?.left ?: 0.dp) +
515
+ if (options.hiddenBack || useSideBar) Spacing.M else backWidth + Spacing.M + Spacing.S
516
+ val minEndPadding = Spacing.M
517
+ val maxEndPadding = (clearance?.right ?: 0.dp) + when {
518
+ options.headerRight is HeaderRight.None -> Spacing.M
519
+ useSideBar && options.headerRight is HeaderRight.Toolkit -> Spacing.M
520
+ else -> headerRightWidthDp + Spacing.M * 2
521
+ }
522
+
523
+ val targetColor = lerp(
524
+ AppTheme.current.colors.background.surface,
525
+ AppTheme.current.colors.background.default,
526
+ (scrollDp / minTopPadding.coerceAtLeast(1.dp)).coerceIn(0f, 1f)
527
+ )
528
+ val animatedColor by animateColorAsState(targetValue = targetColor, label = "BackgroundColor")
529
+
530
+ val layoutParams = when (inputSearchType) {
531
+ InputSearchType.Header -> {
532
+ InputSearchLayoutParams(
533
+ topPadding = minTopPadding,
534
+ startPadding = maxStartPadding,
535
+ endPadding = maxEndPadding
536
+ )
537
+ }
538
+
539
+ InputSearchType.Animated -> {
540
+ val collapsePx = with(density) { HEADER_HEIGHT.dp.roundToPx() }
541
+ val progress = (scrollState.value / collapsePx.toFloat()).coerceIn(0f, 1f)
542
+
543
+ LaunchedEffect(snapState, collapsePx) {
544
+ snapshotFlow { snapState.isScrollInProgress }
545
+ .filter { !it }
546
+ .collect {
547
+ val offset = snapState.headerOffsetPx() ?: return@collect
548
+ if (offset <= 0 || offset >= collapsePx) return@collect
549
+ val target = if (offset < collapsePx / 2) 0 else collapsePx
550
+ launch { snapState.animateScrollBy((target - offset).toFloat()) }
551
+ }
552
+ }
553
+
554
+ InputSearchLayoutParams(
555
+ topPadding = lerp(maxTopPadding, minTopPadding, progress),
556
+ startPadding = lerp(minStartPadding, maxStartPadding, progress),
557
+ endPadding = lerp(minEndPadding, maxEndPadding, progress)
558
+ )
559
+ }
560
+
561
+ InputSearchType.None -> return
562
+ }
563
+
564
+ Spacer(Modifier.height(layoutParams.topPadding))
565
+ Box(
566
+ modifier = Modifier
567
+ .height(HEADER_HEIGHT.dp)
568
+ .fillMaxWidth()
569
+ .padding(
570
+ start = layoutParams.startPadding,
571
+ end = layoutParams.endPadding
572
+ ),
573
+ contentAlignment = Alignment.Center
574
+ ) {
575
+ InputSearch(
576
+ inputSearchProps = inputSearchProps.copy(
577
+ backgroundColor = animatedColor,
578
+ onPressButtonText = {
579
+ navigator.pop()
580
+ }
581
+ )
582
+ )
583
+ }
584
+ }
585
+
586
+ private fun ScrollableState.headerOffsetPx(): Int? = when (this) {
587
+ is LazyListState -> if (firstVisibleItemIndex == 0) firstVisibleItemScrollOffset else null
588
+ is ScrollState -> value
589
+ else -> null
590
+ }
591
+
592
+ private fun quantize(value: Int, stepPx: Int): Int {
593
+ if (stepPx <= 1) return value
594
+ return (value / stepPx) * stepPx
595
+ }
596
+
597
+ @Composable
598
+ internal fun LazyListState.proxyScrollState(
599
+ thresholdPx: Int = 200,
600
+ stepPx: Int = 4
601
+ ): Pair<ScrollState, Boolean> = proxyScroll(
602
+ source = this,
603
+ thresholdPx = thresholdPx,
604
+ stepPx = stepPx,
605
+ isScrollInProgress = { isScrollInProgress },
606
+ rawTargetFlow = {
607
+ snapshotFlow {
608
+ if (firstVisibleItemIndex == 0) firstVisibleItemScrollOffset
609
+ else SCROLLED_PAST_FIRST_ITEM_THRESHOLD
610
+ }
611
+ },
612
+ )
613
+
614
+ @Composable
615
+ internal fun ScrollState.proxyLimitedScrollState(
616
+ thresholdPx: Int = 200,
617
+ stepPx: Int = 4
618
+ ): Pair<ScrollState, Boolean> = proxyScroll(
619
+ source = this,
620
+ thresholdPx = thresholdPx,
621
+ stepPx = stepPx,
622
+ isScrollInProgress = { isScrollInProgress },
623
+ rawTargetFlow = { snapshotFlow { value } },
624
+ )
625
+
626
+ @Composable
627
+ private fun proxyScroll(
628
+ source: Any,
629
+ thresholdPx: Int,
630
+ stepPx: Int,
631
+ isScrollInProgress: () -> Boolean,
632
+ rawTargetFlow: () -> Flow<Int>,
633
+ ): Pair<ScrollState, Boolean> {
634
+ val proxy = rememberScrollState()
635
+ val locked = remember { mutableStateOf(false) }
636
+
637
+ LaunchedEffect(source, proxy, thresholdPx, stepPx) {
638
+ rawTargetFlow().collect { rawTarget ->
639
+ val shouldLock = rawTarget > thresholdPx
640
+ if (locked.value != shouldLock) locked.value = shouldLock
641
+
642
+ val desired = if (shouldLock) thresholdPx else quantize(rawTarget, stepPx)
643
+
644
+ if (proxy.value != desired) {
645
+ proxy.scrollTo(desired.coerceAtLeast(0))
646
+ }
647
+ }
648
+ }
649
+
650
+ val inProgress = remember { mutableStateOf(false) }
651
+ LaunchedEffect(source, thresholdPx) {
652
+ snapshotFlow { isScrollInProgress() }
653
+ .collect { progressing ->
654
+ inProgress.value = if (locked.value) false else progressing
655
+ }
656
+ }
657
+
658
+ return proxy to inProgress.value
659
+ }
660
+
661
+ private const val SCROLLED_PAST_FIRST_ITEM_THRESHOLD = 10_000
662
+
663
+ internal val LocalScrollState = staticCompositionLocalOf<ScrollState> { error("No Scroll State provided") }
664
+ internal val LocalOptions = staticCompositionLocalOf<NavigationOptions> { error("No NavigationOptions provided") }
665
+
666
+ val StackScreenScrollableState = staticCompositionLocalOf<ScrollableState?> { null }
667
+
668
+ // iPhone Duo side bar: the header leaves with the content and slides back in on a reverse scroll
669
+ // (RN DuoQuickReturnHeader). The side bar is drawn apart from the header, so it stays put.
670
+ @Composable
671
+ private fun rememberQuickReturnHide(
672
+ enabled: Boolean,
673
+ scrollState: ScrollState,
674
+ heightPx: Float,
675
+ ): Animatable<Float, AnimationVector1D> {
676
+ val hide = remember { Animatable(0f) }
677
+ LaunchedEffect(enabled, scrollState, heightPx) {
678
+ if (!enabled) {
679
+ hide.snapTo(0f)
680
+ return@LaunchedEffect
681
+ }
682
+ var last = scrollState.value
683
+ snapshotFlow { scrollState.value }.collect { y ->
684
+ val delta = y - last
685
+ last = y
686
+ hide.snapTo(if (y <= 0) 0f else (hide.value + delta).coerceIn(0f, heightPx))
687
+ }
688
+ }
689
+ // a half-shown header settles fully in or out once the scroll stops
690
+ LaunchedEffect(enabled, scrollState, heightPx) {
691
+ if (!enabled) return@LaunchedEffect
692
+ snapshotFlow { scrollState.isScrollInProgress }
693
+ .filter { !it }
694
+ .collect {
695
+ val value = hide.value
696
+ // within the first header height the header still sits on the content
697
+ if (scrollState.value < heightPx || value <= 0f || value >= heightPx) return@collect
698
+ launch { hide.animateTo(if (value > heightPx / 2) heightPx else 0f, tween(200)) }
699
+ }
700
+ }
701
+ return hide
702
+ }
703
+
704
+ internal fun NavigationOptions.usesDuoQuickReturnHeader(layout: ScreenLayout): Boolean {
705
+ if (usesDuoGlassHeader(layout)) return true
706
+ return layout.sideBar != null && headerType is HeaderType.Animated && scrollsWithScrollState()
707
+ }
708
+
709
+ // iPhone Duo side bar: content scrolls under a glass header instead of starting below it (RN Screen).
710
+ internal fun NavigationOptions.usesDuoGlassHeader(layout: ScreenLayout): Boolean {
711
+ if (layout.sideBar == null || headerType !is HeaderType.DefaultOrExtended) return false
712
+ return getInputSearchType(this) == InputSearchType.None && scrollsWithScrollState()
713
+ }
714
+
715
+ private fun NavigationOptions.scrollsWithScrollState(): Boolean {
716
+ return scrollData.scrollable && scrollData.scrollState is ScrollState
717
+ }
718
+
719
+ internal fun getInputSearchType(options: NavigationOptions): InputSearchType {
720
+ return when (val headerType = options.headerType) {
721
+ is HeaderType.DefaultOrExtended -> when {
722
+ headerType.inputSearchProps == null -> InputSearchType.None
723
+ headerType.useAnimated -> InputSearchType.Animated
724
+ else -> InputSearchType.Header
725
+ }
726
+
727
+ else -> InputSearchType.None
728
+ }
729
+ }
730
+