@momo-kits/native-kits 0.169.8-beta.5-debug → 0.169.8-beta.6

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