@momo-kits/native-kits 0.169.2-debug → 0.169.3-beta.1

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