@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-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.
- package/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/compose/build.gradle.kts +2 -4
- package/compose/build.gradle.kts.backup +1 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
- package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
- package/gradle/libs.versions.toml +1 -3
- package/gradle.properties +1 -3
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
- package/scripts/ci/build-swiftui.sh +22 -0
- package/scripts/ci/resolve-version.mjs +144 -0
- package/settings.gradle.kts +0 -1
|
@@ -6,6 +6,7 @@ import androidx.compose.animation.core.tween
|
|
|
6
6
|
import androidx.compose.foundation.background
|
|
7
7
|
import androidx.compose.foundation.border
|
|
8
8
|
import androidx.compose.foundation.gestures.detectDragGestures
|
|
9
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
9
10
|
import androidx.compose.foundation.layout.Box
|
|
10
11
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
11
12
|
import androidx.compose.foundation.layout.Column
|
|
@@ -25,19 +26,23 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
25
26
|
import androidx.compose.runtime.Composable
|
|
26
27
|
import androidx.compose.runtime.DisposableEffect
|
|
27
28
|
import androidx.compose.runtime.LaunchedEffect
|
|
29
|
+
import androidx.compose.runtime.getValue
|
|
30
|
+
import androidx.compose.runtime.mutableStateOf
|
|
28
31
|
import androidx.compose.runtime.remember
|
|
32
|
+
import androidx.compose.runtime.setValue
|
|
29
33
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
30
34
|
import androidx.compose.ui.Alignment
|
|
31
35
|
import androidx.compose.ui.Modifier
|
|
36
|
+
import androidx.compose.ui.draw.clip
|
|
32
37
|
import androidx.compose.ui.graphics.Brush
|
|
33
38
|
import androidx.compose.ui.graphics.Color
|
|
34
39
|
import androidx.compose.ui.input.pointer.pointerInput
|
|
35
40
|
import androidx.compose.ui.platform.LocalDensity
|
|
41
|
+
import androidx.compose.ui.unit.Density
|
|
36
42
|
import androidx.compose.ui.unit.IntOffset
|
|
37
43
|
import androidx.compose.ui.unit.dp
|
|
38
44
|
import kotlinx.coroutines.launch
|
|
39
45
|
import vn.momo.kits.components.Divider
|
|
40
|
-
import vn.momo.kits.components.Icon
|
|
41
46
|
import vn.momo.kits.components.Text
|
|
42
47
|
import vn.momo.kits.const.AppTheme
|
|
43
48
|
import vn.momo.kits.const.Colors
|
|
@@ -52,10 +57,25 @@ import vn.momo.kits.modifier.conditional
|
|
|
52
57
|
import vn.momo.kits.modifier.noFeedbackClickable
|
|
53
58
|
import vn.momo.kits.platform.BackHandler
|
|
54
59
|
import vn.momo.kits.platform.getScreenHeight
|
|
60
|
+
import vn.momo.kits.layout.MODAL_ICON_BUTTON_SIZE
|
|
61
|
+
import vn.momo.kits.layout.ModalIconButton
|
|
55
62
|
import vn.momo.kits.layout.getScreenLayout
|
|
63
|
+
import vn.momo.kits.layout.rememberModalLayout
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
private val
|
|
65
|
+
private val INDICATOR_HEIGHT = 16.dp
|
|
66
|
+
private val HEADER_ROW_HEIGHT = 56.dp
|
|
67
|
+
|
|
68
|
+
// A sheet held at its min height keeps the footer at the bottom; the room goes above it.
|
|
69
|
+
private object FooterAtBottom : Arrangement.Vertical {
|
|
70
|
+
override fun Density.arrange(totalSize: Int, sizes: IntArray, outPositions: IntArray) {
|
|
71
|
+
var y = 0
|
|
72
|
+
sizes.forEachIndexed { index, size ->
|
|
73
|
+
outPositions[index] = y
|
|
74
|
+
y += size
|
|
75
|
+
}
|
|
76
|
+
if (sizes.isNotEmpty()) outPositions[sizes.lastIndex] = maxOf(y - sizes.last(), totalSize - sizes.last())
|
|
77
|
+
}
|
|
78
|
+
}
|
|
59
79
|
|
|
60
80
|
@Composable
|
|
61
81
|
internal fun BottomSheet(
|
|
@@ -69,41 +89,51 @@ internal fun BottomSheet(
|
|
|
69
89
|
onDismiss: (() -> Unit)?
|
|
70
90
|
) {
|
|
71
91
|
val layout = getScreenLayout()
|
|
72
|
-
val
|
|
73
|
-
val
|
|
92
|
+
val modal = rememberModalLayout()
|
|
93
|
+
val isFoldable = modal.isFoldable
|
|
94
|
+
val sheet = modal.sheet
|
|
95
|
+
val sheetShape = RoundedCornerShape(topStart = sheet.radius, topEnd = sheet.radius)
|
|
96
|
+
val title = header as? BottomHeader.Title
|
|
74
97
|
// the screen is the outer display on iPhone Duo, even when unfolded
|
|
75
|
-
val screenHeightDp = if (
|
|
98
|
+
val screenHeightDp = if (isFoldable) layout.height else getScreenHeight()
|
|
76
99
|
val screenHeightPx = with(LocalDensity.current) { screenHeightDp.toPx() }
|
|
77
100
|
val sheetOffset = remember { Animatable(screenHeightPx) }
|
|
78
101
|
|
|
102
|
+
// half the scrim fades in first, the other half follows the sheet
|
|
79
103
|
val backgroundAlpha = remember { Animatable(0f) }
|
|
80
|
-
val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.
|
|
81
|
-
val alpha = backgroundAlpha.value + dynamicAlpha
|
|
104
|
+
val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.5f
|
|
105
|
+
val alpha = (backgroundAlpha.value + dynamicAlpha) * modal.scrimOpacity
|
|
82
106
|
|
|
83
107
|
val sheetCloseOffset = with(LocalDensity.current) { 100.dp.toPx() }
|
|
84
108
|
|
|
85
109
|
val coroutineScope = rememberCoroutineScope()
|
|
86
110
|
|
|
87
|
-
val
|
|
111
|
+
val binding = LocalKitsBinding.current
|
|
88
112
|
val context = LocalContext.current
|
|
89
113
|
|
|
90
114
|
DisposableEffect(Unit) {
|
|
91
115
|
ScreenTracker.trackPopupDisplayed(
|
|
92
|
-
|
|
116
|
+
binding = binding,
|
|
93
117
|
context = context,
|
|
94
118
|
parentScreenName = ScreenTracker.getLastScreenName()
|
|
95
119
|
)
|
|
96
120
|
onDispose { }
|
|
97
121
|
}
|
|
98
122
|
|
|
123
|
+
// a closing sheet keeps going: a second close, the open slide or a drag would cancel its animation
|
|
124
|
+
var isClosing by remember { mutableStateOf(false) }
|
|
125
|
+
// runs once the sheet has closed itself, after its onDismiss
|
|
126
|
+
var afterDismiss by remember { mutableStateOf<(() -> Unit)?>(null) }
|
|
127
|
+
|
|
99
128
|
suspend fun openEvent(){
|
|
100
129
|
backgroundAlpha.animateTo(
|
|
101
|
-
targetValue = 0.
|
|
130
|
+
targetValue = 0.5f,
|
|
102
131
|
animationSpec = tween(
|
|
103
132
|
durationMillis = 100,
|
|
104
133
|
easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
|
|
105
134
|
)
|
|
106
135
|
)
|
|
136
|
+
if (isClosing) return
|
|
107
137
|
sheetOffset.animateTo(
|
|
108
138
|
targetValue = 0f,
|
|
109
139
|
animationSpec = tween(
|
|
@@ -113,7 +143,9 @@ internal fun BottomSheet(
|
|
|
113
143
|
)
|
|
114
144
|
}
|
|
115
145
|
|
|
116
|
-
fun closeEvent(){
|
|
146
|
+
fun closeEvent(then: (() -> Unit)? = null){
|
|
147
|
+
if (isClosing) return
|
|
148
|
+
isClosing = true
|
|
117
149
|
coroutineScope.launch {
|
|
118
150
|
sheetOffset.animateTo(
|
|
119
151
|
targetValue = screenHeightPx,
|
|
@@ -129,10 +161,15 @@ internal fun BottomSheet(
|
|
|
129
161
|
easing = CubicBezierEasing(0.3f, 0.0f, 0.8f, 0.15f)
|
|
130
162
|
)
|
|
131
163
|
)
|
|
164
|
+
// not reached when a newer overlay replaced this one, so its back is dropped
|
|
165
|
+
afterDismiss = then
|
|
132
166
|
OverplayComponentRegistry.hardClearAfterDismiss()
|
|
133
167
|
}
|
|
134
168
|
}
|
|
135
169
|
|
|
170
|
+
// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs
|
|
171
|
+
val onBack = title?.onBack?.let { back -> { closeEvent(then = back) } }
|
|
172
|
+
|
|
136
173
|
LaunchedEffect(Unit) {
|
|
137
174
|
openEvent()
|
|
138
175
|
}
|
|
@@ -141,6 +178,7 @@ internal fun BottomSheet(
|
|
|
141
178
|
OverplayComponentRegistry.bindClose { closeEvent() }
|
|
142
179
|
onDispose {
|
|
143
180
|
onDismiss?.invoke()
|
|
181
|
+
afterDismiss?.invoke()
|
|
144
182
|
}
|
|
145
183
|
}
|
|
146
184
|
|
|
@@ -151,41 +189,30 @@ internal fun BottomSheet(
|
|
|
151
189
|
BoxWithConstraints(
|
|
152
190
|
modifier = Modifier
|
|
153
191
|
.fillMaxSize()
|
|
154
|
-
|
|
192
|
+
// full screen on foldables too, over the iPhone Duo control column
|
|
193
|
+
.background(Colors.black_20.copy(alpha = alpha))
|
|
155
194
|
.noFeedbackClickable {
|
|
156
195
|
if(barrierDismissible) closeEvent()
|
|
157
196
|
}
|
|
197
|
+
// centered in the placement: off the iPhone Duo control column, the right half when half folded
|
|
198
|
+
.conditional(isFoldable) {
|
|
199
|
+
absolutePadding(left = modal.placement.left, right = layout.width - modal.placement.right)
|
|
200
|
+
}
|
|
158
201
|
) {
|
|
159
202
|
val parentHeight = with(LocalDensity.current) { constraints.maxHeight.toDp() }
|
|
160
|
-
val maxHeight =
|
|
161
|
-
parentHeight - maxOf(layout.duoTopInset, Spacing.XL)
|
|
162
|
-
} else {
|
|
163
|
-
parentHeight - 90.dp
|
|
164
|
-
}
|
|
165
|
-
// landscape side buttons span the full height; in portrait the side status bar only covers the top
|
|
166
|
-
val sideInset = isDuo && !isDuoCentered && layout.width > layout.height
|
|
203
|
+
val maxHeight = sheet.maxHeight ?: (parentHeight - 90.dp)
|
|
167
204
|
|
|
168
205
|
Box(
|
|
169
206
|
modifier = Modifier
|
|
170
207
|
.align(Alignment.BottomCenter)
|
|
171
208
|
.offset { IntOffset(x = 0, y = sheetOffset.value.toInt()) }
|
|
172
|
-
.then(
|
|
173
|
-
if (isDuoCentered) {
|
|
174
|
-
// keeps the portrait width in landscape, like system sheets
|
|
175
|
-
Modifier.width(
|
|
176
|
-
minOf(
|
|
177
|
-
minOf(layout.width, layout.height) - Spacing.L * 2,
|
|
178
|
-
layout.width - maxOf(layout.insetLeft, layout.insetRight, Spacing.L) * 2,
|
|
179
|
-
)
|
|
180
|
-
)
|
|
181
|
-
} else {
|
|
182
|
-
Modifier.fillMaxWidth()
|
|
183
|
-
}
|
|
184
|
-
)
|
|
209
|
+
.then(if (sheet.width != null) Modifier.width(sheet.width) else Modifier.fillMaxWidth())
|
|
185
210
|
.heightIn(max = maxHeight)
|
|
211
|
+
// clip too, so content (images, scrims) follows the corners like iOS clipShape
|
|
212
|
+
.clip(sheetShape)
|
|
186
213
|
.background(
|
|
187
214
|
color = if (isSurface) AppTheme.current.colors.background.surface else AppTheme.current.colors.background.default,
|
|
188
|
-
shape =
|
|
215
|
+
shape = sheetShape
|
|
189
216
|
)
|
|
190
217
|
.conditional(IsShowBaseLineDebug) {
|
|
191
218
|
border(1.dp, Colors.blue_03)
|
|
@@ -197,27 +224,26 @@ internal fun BottomSheet(
|
|
|
197
224
|
(AppNavigationBar.current - keyboardSizeState().value).coerceAtLeast(0.dp)
|
|
198
225
|
} else 0.dp
|
|
199
226
|
Column(
|
|
200
|
-
Modifier
|
|
201
|
-
|
|
202
|
-
.conditional(sideInset) {
|
|
203
|
-
absolutePadding(left = layout.insetLeft, right = layout.insetRight)
|
|
204
|
-
}
|
|
227
|
+
modifier = Modifier.heightIn(min = sheet.minHeight).padding(bottom = bottomInset),
|
|
228
|
+
verticalArrangement = if (footerComponent != null) FooterAtBottom else Arrangement.Top,
|
|
205
229
|
) {
|
|
206
230
|
Box(
|
|
207
231
|
modifier = Modifier
|
|
208
|
-
.height(
|
|
232
|
+
.height(INDICATOR_HEIGHT + HEADER_ROW_HEIGHT)
|
|
209
233
|
.fillMaxWidth()
|
|
210
234
|
.conditional(draggable) {
|
|
211
235
|
pointerInput(Unit) {
|
|
212
236
|
detectDragGestures(
|
|
213
237
|
onDrag = { change, dragAmount ->
|
|
214
238
|
change.consume()
|
|
239
|
+
if (isClosing) return@detectDragGestures
|
|
215
240
|
coroutineScope.launch {
|
|
216
241
|
val newOffset = (sheetOffset.value + dragAmount.y).coerceAtLeast(0f)
|
|
217
242
|
sheetOffset.snapTo(newOffset)
|
|
218
243
|
}
|
|
219
244
|
},
|
|
220
245
|
onDragEnd = {
|
|
246
|
+
if (isClosing) return@detectDragGestures
|
|
221
247
|
coroutineScope.launch {
|
|
222
248
|
if (sheetOffset.value > sheetCloseOffset) {
|
|
223
249
|
closeEvent()
|
|
@@ -247,29 +273,17 @@ internal fun BottomSheet(
|
|
|
247
273
|
)
|
|
248
274
|
)
|
|
249
275
|
Spacer(Modifier.height(4.dp))
|
|
250
|
-
Box(
|
|
276
|
+
Box(
|
|
277
|
+
Modifier.fillMaxWidth().height(HEADER_ROW_HEIGHT),
|
|
278
|
+
contentAlignment = Alignment.Center
|
|
279
|
+
) {
|
|
251
280
|
when (header) {
|
|
252
|
-
is BottomHeader.Title ->
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
color = Colors.black_17,
|
|
259
|
-
style = Typography.headerDefaultBold
|
|
260
|
-
)
|
|
261
|
-
}
|
|
262
|
-
Box(Modifier
|
|
263
|
-
.size(24.dp)
|
|
264
|
-
.noFeedbackClickable {
|
|
265
|
-
closeEvent()
|
|
266
|
-
},
|
|
267
|
-
contentAlignment = Alignment.Center
|
|
268
|
-
){
|
|
269
|
-
Icon(source = "navigation_close")
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
281
|
+
is BottomHeader.Title -> BottomSheetTitle(
|
|
282
|
+
text = header.data,
|
|
283
|
+
backIcon = header.backIcon,
|
|
284
|
+
onBack = onBack,
|
|
285
|
+
onClose = { closeEvent() },
|
|
286
|
+
)
|
|
273
287
|
is BottomHeader.Custom -> {
|
|
274
288
|
header.content()
|
|
275
289
|
}
|
|
@@ -283,7 +297,7 @@ internal fun BottomSheet(
|
|
|
283
297
|
content()
|
|
284
298
|
}
|
|
285
299
|
BottomSheetFooter(footerComponent)
|
|
286
|
-
} else if (
|
|
300
|
+
} else if (isFoldable) {
|
|
287
301
|
// content shrinks so a tall sheet keeps its header
|
|
288
302
|
Box(Modifier.weight(1f, fill = false)) {
|
|
289
303
|
content()
|
|
@@ -296,6 +310,39 @@ internal fun BottomSheet(
|
|
|
296
310
|
}
|
|
297
311
|
}
|
|
298
312
|
|
|
313
|
+
@Composable
|
|
314
|
+
private fun BottomSheetTitle(
|
|
315
|
+
text: String,
|
|
316
|
+
backIcon: String,
|
|
317
|
+
onBack: (() -> Unit)?,
|
|
318
|
+
onClose: () -> Unit,
|
|
319
|
+
) {
|
|
320
|
+
Row(
|
|
321
|
+
modifier = Modifier.fillMaxSize(),
|
|
322
|
+
horizontalArrangement = Arrangement.spacedBy(Spacing.S),
|
|
323
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
324
|
+
) {
|
|
325
|
+
if (onBack != null) {
|
|
326
|
+
ModalIconButton(icon = backIcon, automationId = "btn_bottom_sheet_back", onClick = onBack)
|
|
327
|
+
} else {
|
|
328
|
+
Box(Modifier.size(MODAL_ICON_BUTTON_SIZE))
|
|
329
|
+
}
|
|
330
|
+
Box(
|
|
331
|
+
Modifier
|
|
332
|
+
.fillMaxHeight()
|
|
333
|
+
.weight(1f),
|
|
334
|
+
contentAlignment = Alignment.Center
|
|
335
|
+
) {
|
|
336
|
+
Text(
|
|
337
|
+
text = text,
|
|
338
|
+
color = Colors.black_17,
|
|
339
|
+
style = Typography.headerDefaultBold
|
|
340
|
+
)
|
|
341
|
+
}
|
|
342
|
+
ModalIconButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
299
346
|
@Composable
|
|
300
347
|
private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
|
|
301
348
|
val shadowBrush = remember {
|
|
@@ -330,7 +377,19 @@ private fun BottomSheetFooter(footerComponent: @Composable () -> Unit) {
|
|
|
330
377
|
sealed class BottomHeader {
|
|
331
378
|
data class Title(
|
|
332
379
|
val data: String = "Bottom Sheet Title",
|
|
333
|
-
) : BottomHeader()
|
|
380
|
+
) : BottomHeader() {
|
|
381
|
+
// Outside the primary constructor so code built against older kits keeps Title() and copy().
|
|
382
|
+
// onBack shows a back button: the sheet closes (onDismiss fires), then it runs.
|
|
383
|
+
var onBack: (() -> Unit)? = null
|
|
384
|
+
private set
|
|
385
|
+
var backIcon: String = "arrow-back"
|
|
386
|
+
private set
|
|
387
|
+
|
|
388
|
+
constructor(data: String, onBack: (() -> Unit)?, backIcon: String = "arrow-back") : this(data) {
|
|
389
|
+
this.onBack = onBack
|
|
390
|
+
this.backIcon = backIcon
|
|
391
|
+
}
|
|
392
|
+
}
|
|
334
393
|
|
|
335
394
|
data class Custom(
|
|
336
395
|
val content: @Composable () -> Unit
|
|
@@ -8,16 +8,17 @@ import androidx.compose.foundation.border
|
|
|
8
8
|
import androidx.compose.foundation.clickable
|
|
9
9
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
10
10
|
import androidx.compose.foundation.layout.Box
|
|
11
|
+
import androidx.compose.foundation.layout.absolutePadding
|
|
11
12
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
12
|
-
import androidx.compose.foundation.layout.
|
|
13
|
+
import androidx.compose.foundation.layout.sizeIn
|
|
13
14
|
import androidx.compose.foundation.layout.wrapContentSize
|
|
14
15
|
import androidx.compose.runtime.*
|
|
15
16
|
import androidx.compose.ui.Alignment
|
|
16
17
|
import androidx.compose.ui.Modifier
|
|
17
18
|
import androidx.compose.ui.draw.alpha
|
|
18
19
|
import androidx.compose.ui.draw.scale
|
|
19
|
-
import androidx.compose.ui.graphics.Color
|
|
20
20
|
import androidx.compose.ui.unit.dp
|
|
21
|
+
import androidx.compose.ui.unit.height
|
|
21
22
|
import kotlinx.coroutines.launch
|
|
22
23
|
import vn.momo.kits.application.LocalContext
|
|
23
24
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
@@ -27,6 +28,7 @@ import vn.momo.kits.modifier.noFeedbackClickable
|
|
|
27
28
|
import vn.momo.kits.navigation.tracking.ScreenTracker
|
|
28
29
|
import vn.momo.kits.platform.BackHandler
|
|
29
30
|
import vn.momo.kits.layout.getScreenLayout
|
|
31
|
+
import vn.momo.kits.layout.rememberModalLayout
|
|
30
32
|
|
|
31
33
|
@Composable
|
|
32
34
|
internal fun ModalScreen(
|
|
@@ -41,12 +43,12 @@ internal fun ModalScreen(
|
|
|
41
43
|
|
|
42
44
|
val coroutineScope = rememberCoroutineScope()
|
|
43
45
|
|
|
44
|
-
val
|
|
46
|
+
val binding = LocalKitsBinding.current
|
|
45
47
|
val context = LocalContext.current
|
|
46
48
|
|
|
47
49
|
DisposableEffect(Unit) {
|
|
48
50
|
ScreenTracker.trackPopupDisplayed(
|
|
49
|
-
|
|
51
|
+
binding = binding,
|
|
50
52
|
context = context,
|
|
51
53
|
parentScreenName = ScreenTracker.getLastScreenName()
|
|
52
54
|
)
|
|
@@ -103,17 +105,25 @@ internal fun ModalScreen(
|
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
val layout = getScreenLayout()
|
|
108
|
+
val modal = rememberModalLayout()
|
|
109
|
+
val placement = modal.placement
|
|
106
110
|
|
|
107
111
|
Box(
|
|
108
112
|
modifier = Modifier
|
|
109
113
|
.fillMaxSize()
|
|
110
|
-
|
|
114
|
+
// full screen on foldables too, over the iPhone Duo control column
|
|
115
|
+
.background(Colors.black_20.copy(alpha = modal.scrimOpacity * alpha.value))
|
|
111
116
|
.noFeedbackClickable {
|
|
112
117
|
if(barrierDismissible) closeEvent()
|
|
113
118
|
}
|
|
114
|
-
// center
|
|
115
|
-
.conditional(
|
|
116
|
-
|
|
119
|
+
// center in the placement: the safe area, or the right half of a half-folded iPhone Duo
|
|
120
|
+
.conditional(modal.isFoldable) {
|
|
121
|
+
absolutePadding(
|
|
122
|
+
left = placement.left,
|
|
123
|
+
top = placement.top,
|
|
124
|
+
right = layout.width - placement.right,
|
|
125
|
+
bottom = layout.height - placement.bottom,
|
|
126
|
+
)
|
|
117
127
|
},
|
|
118
128
|
contentAlignment = Alignment.Center
|
|
119
129
|
) {
|
|
@@ -121,6 +131,12 @@ internal fun ModalScreen(
|
|
|
121
131
|
modifier = Modifier
|
|
122
132
|
.scale(scale.value)
|
|
123
133
|
.alpha(alpha.value)
|
|
134
|
+
.conditional(modal.isFoldable) {
|
|
135
|
+
sizeIn(
|
|
136
|
+
maxWidth = modal.popup.maxWidth,
|
|
137
|
+
maxHeight = modal.popup.maxHeight ?: placement.height,
|
|
138
|
+
)
|
|
139
|
+
}
|
|
124
140
|
.wrapContentSize()
|
|
125
141
|
.conditional(IsShowBaseLineDebug) {
|
|
126
142
|
border(1.dp, Colors.blue_03)
|
|
@@ -3,6 +3,7 @@ package vn.momo.kits.navigation
|
|
|
3
3
|
import androidx.compose.foundation.gestures.ScrollableState
|
|
4
4
|
import androidx.compose.runtime.*
|
|
5
5
|
import androidx.compose.ui.graphics.Color
|
|
6
|
+
import vn.momo.kits.layout.ContentLayout
|
|
6
7
|
import vn.momo.kits.navigation.bottomtab.setBottomTabOption
|
|
7
8
|
import vn.momo.kits.navigation.component.*
|
|
8
9
|
|
|
@@ -20,6 +21,10 @@ class Navigation(
|
|
|
20
21
|
internal val isBottomTabRoot: Boolean get() = _isBottomTabRoot.value
|
|
21
22
|
internal fun markAsBottomTabRoot() { _isBottomTabRoot.value = true }
|
|
22
23
|
|
|
24
|
+
// A self-scrolling tab asks (via floatingTabBarContentPadding) to run edge to edge behind the
|
|
25
|
+
// floating bar; the kit then stops reserving the bar space as outer padding. Not in NavigationOptions.
|
|
26
|
+
internal var bottomTabEdgeToEdge by mutableStateOf(false)
|
|
27
|
+
|
|
23
28
|
fun setOptions(
|
|
24
29
|
onBackHandler: (() -> Unit)? = null,
|
|
25
30
|
hiddenBack: Boolean? = null,
|
|
@@ -30,15 +35,14 @@ class Navigation(
|
|
|
30
35
|
headerType: HeaderType? = null,
|
|
31
36
|
scrollData: ScrollData? = null,
|
|
32
37
|
backgroundColor: Color? = null,
|
|
33
|
-
// AI-GENERATED START: custom screen background
|
|
34
38
|
backgroundComponent: (@Composable () -> Unit)? = null,
|
|
35
|
-
// AI-GENERATED END: custom screen background
|
|
36
39
|
tintColor: Color? = null,
|
|
37
40
|
footerComponent: (@Composable () -> Unit)? = null,
|
|
38
41
|
footerTransparent: Boolean? = null,
|
|
39
42
|
footerUseMargin: Boolean? = null,
|
|
40
43
|
floatingButtonProps: FloatingButtonProps? = null,
|
|
41
|
-
keyboardOptions: KeyboardOptions? = null
|
|
44
|
+
keyboardOptions: KeyboardOptions? = null,
|
|
45
|
+
contentLayout: ContentLayout? = null,
|
|
42
46
|
) {
|
|
43
47
|
updateOptions(
|
|
44
48
|
options.copy(
|
|
@@ -51,15 +55,14 @@ class Navigation(
|
|
|
51
55
|
headerType = headerType ?: options.headerType,
|
|
52
56
|
scrollData = scrollData ?: options.scrollData,
|
|
53
57
|
backgroundColor = backgroundColor ?: options.backgroundColor,
|
|
54
|
-
// AI-GENERATED START: custom screen background
|
|
55
58
|
backgroundComponent = backgroundComponent ?: options.backgroundComponent,
|
|
56
|
-
// AI-GENERATED END: custom screen background
|
|
57
59
|
tintColor = tintColor ?: options.tintColor,
|
|
58
60
|
footerComponent = footerComponent ?: options.footerComponent,
|
|
59
61
|
footerTransparent = footerTransparent ?: options.footerTransparent,
|
|
60
62
|
footerUseMargin = footerUseMargin ?: options.footerUseMargin,
|
|
61
63
|
floatingButtonProps = floatingButtonProps ?: options.floatingButtonProps,
|
|
62
64
|
keyboardOptions = keyboardOptions ?: options.keyboardOptions,
|
|
65
|
+
contentLayout = contentLayout ?: options.contentLayout,
|
|
63
66
|
)
|
|
64
67
|
)
|
|
65
68
|
}
|
|
@@ -91,16 +94,15 @@ data class NavigationOptions(
|
|
|
91
94
|
val headerType: HeaderType = HeaderType.Default(),
|
|
92
95
|
val scrollData: ScrollData = ScrollData(),
|
|
93
96
|
val backgroundColor: Color? = null,
|
|
94
|
-
// AI-GENERATED START: custom screen background (SwiftUI `NavigationOptions.background`)
|
|
95
|
-
/** Drawn instead of `backgroundColor` over the whole screen: under the header, outside the keyboard padding. */
|
|
96
97
|
val backgroundComponent: @Composable (() -> Unit)? = null,
|
|
97
|
-
// AI-GENERATED END: custom screen background (SwiftUI `NavigationOptions.background`)
|
|
98
98
|
val tintColor: Color? = null,
|
|
99
99
|
val footerComponent: @Composable (() -> Unit)? = null,
|
|
100
100
|
val footerTransparent: Boolean = false,
|
|
101
101
|
val footerUseMargin: Boolean = true,
|
|
102
102
|
val floatingButtonProps: FloatingButtonProps? = null,
|
|
103
|
-
val keyboardOptions: KeyboardOptions = KeyboardOptions()
|
|
103
|
+
val keyboardOptions: KeyboardOptions = KeyboardOptions(),
|
|
104
|
+
// Wide windows: Stretch puts the header row in the centered 600pt content frame.
|
|
105
|
+
val contentLayout: ContentLayout = ContentLayout.Grid,
|
|
104
106
|
) {
|
|
105
107
|
internal fun hasFooter() : Boolean = footerComponent != null
|
|
106
108
|
}
|
|
@@ -37,17 +37,15 @@ import vn.momo.kits.platform.ProvideNavigationEventDispatcherOwner
|
|
|
37
37
|
import vn.momo.kits.platform.ProvideOsFontScale
|
|
38
38
|
import vn.momo.kits.utils.getAppStatusBarHeight
|
|
39
39
|
import vn.momo.kits.utils.getNavigationBarHeight
|
|
40
|
-
|
|
41
|
-
import vn.momo.
|
|
42
|
-
import vn.momo.maxapi.runtime.ApiResult
|
|
43
|
-
// AI-GENERATED END: consume typed NativeMaxApi results
|
|
40
|
+
import vn.momo.kits.application.KitsBinding
|
|
41
|
+
import vn.momo.kits.application.KitsHost
|
|
44
42
|
import kotlin.time.Duration.Companion.milliseconds
|
|
45
43
|
|
|
46
44
|
@Composable
|
|
47
45
|
fun NavigationContainer(
|
|
48
46
|
initialScreenName: String,
|
|
49
47
|
initialScreen: @Composable () -> Unit,
|
|
50
|
-
|
|
48
|
+
binding: KitsBinding? = null,
|
|
51
49
|
options: NavigationOptions? = null,
|
|
52
50
|
initialTheme: Theme = defaultTheme,
|
|
53
51
|
miniAppContext: MiniAppContext? = null,
|
|
@@ -56,11 +54,13 @@ fun NavigationContainer(
|
|
|
56
54
|
localize: Localize? = null,
|
|
57
55
|
designSystemConfig: DesignSystemConfig? = null,
|
|
58
56
|
) {
|
|
57
|
+
// An explicit binding wins, then an enclosing container's, then the one the host installed.
|
|
58
|
+
val kitsBinding = binding ?: LocalKitsBinding.current ?: KitsHost.binding
|
|
59
59
|
val navController = rememberNavController()
|
|
60
60
|
val registry = remember { DynamicScreenRegistry() }
|
|
61
61
|
// AI-GENERATED START: retain the current host client after recomposition
|
|
62
|
-
val navigator = remember(navController,
|
|
63
|
-
Navigator(navController = navController,
|
|
62
|
+
val navigator = remember(navController, kitsBinding, registry) {
|
|
63
|
+
Navigator(navController = navController, binding = kitsBinding, registry = registry)
|
|
64
64
|
}
|
|
65
65
|
// AI-GENERATED END: retain the current host client after recomposition
|
|
66
66
|
val statusBarHeight = statusBarHeight ?: getAppStatusBarHeight()
|
|
@@ -72,8 +72,9 @@ fun NavigationContainer(
|
|
|
72
72
|
|
|
73
73
|
val stackTransition = remember { StackTransitionCoordinator() }
|
|
74
74
|
val theme = remember { mutableStateOf(initialTheme) }
|
|
75
|
-
val resolvedDesignSystemConfig =
|
|
76
|
-
|
|
75
|
+
val resolvedDesignSystemConfig = designSystemConfig
|
|
76
|
+
?: LocalDesignSystemConfig.current
|
|
77
|
+
?: DesignSystemKits.getConfigs().designSystemConfig
|
|
77
78
|
val headerBar = resolvedDesignSystemConfig?.headerBar
|
|
78
79
|
// RN parity: the theme's own header image wins; config headerBar is only the fallback.
|
|
79
80
|
val resolvedTheme = remember(theme.value, headerBar) {
|
|
@@ -87,15 +88,12 @@ fun NavigationContainer(
|
|
|
87
88
|
|
|
88
89
|
val resolvedLocalize = localize ?: fallbackLocalize
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
DisposableEffect(maxApi, resolvedLocalize) {
|
|
92
|
-
val api = maxApi
|
|
91
|
+
DisposableEffect(kitsBinding, resolvedLocalize) {
|
|
93
92
|
val target = resolvedLocalize
|
|
94
93
|
var active = true
|
|
95
94
|
val handle = runCatching {
|
|
96
|
-
|
|
97
|
-
if (active &&
|
|
98
|
-
result.value.trim().lowercase().startsWith(Localize.EN)) {
|
|
95
|
+
kitsBinding.getLanguage { language ->
|
|
96
|
+
if (active && language.trim().lowercase().startsWith(Localize.EN)) {
|
|
99
97
|
target.changeLanguage(Localize.EN)
|
|
100
98
|
}
|
|
101
99
|
}
|
|
@@ -105,7 +103,6 @@ fun NavigationContainer(
|
|
|
105
103
|
handle?.cancel()
|
|
106
104
|
}
|
|
107
105
|
}
|
|
108
|
-
// AI-GENERATED END: cancel language delivery when its composition owner changes
|
|
109
106
|
|
|
110
107
|
val screenId = rememberSaveable { registry.nextId() }
|
|
111
108
|
registry.bind(screenId, initialScreenName, initialScreen, options)
|
|
@@ -116,7 +113,7 @@ fun NavigationContainer(
|
|
|
116
113
|
CompositionLocalProvider(
|
|
117
114
|
LocalNavigator provides navigator,
|
|
118
115
|
LocalDynamicScreenRegistry provides registry,
|
|
119
|
-
|
|
116
|
+
LocalKitsBinding provides kitsBinding,
|
|
120
117
|
AppTheme provides resolvedTheme,
|
|
121
118
|
AppStatusBar provides statusBarHeight,
|
|
122
119
|
AppNavigationBar provides navigationBarHeight,
|
|
@@ -130,7 +127,7 @@ fun NavigationContainer(
|
|
|
130
127
|
setNavigator?.invoke(navigator)
|
|
131
128
|
}
|
|
132
129
|
|
|
133
|
-
SwipeBackHaptic(
|
|
130
|
+
SwipeBackHaptic(kitsBinding)
|
|
134
131
|
|
|
135
132
|
LaunchedEffect(navController, registry) {
|
|
136
133
|
navController.currentBackStack.collectLatest { entries ->
|
|
@@ -211,5 +208,5 @@ fun NavigationContainer(
|
|
|
211
208
|
}
|
|
212
209
|
}
|
|
213
210
|
|
|
214
|
-
val
|
|
211
|
+
val LocalKitsBinding = staticCompositionLocalOf<KitsBinding?> { null }
|
|
215
212
|
|