@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
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
package vn.momo.kits.navigation
|
|
2
2
|
|
|
3
3
|
import androidx.compose.foundation.layout.Box
|
|
4
|
+
import androidx.compose.foundation.layout.absolutePadding
|
|
4
5
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
5
6
|
import androidx.compose.runtime.Composable
|
|
6
7
|
import androidx.compose.runtime.MutableState
|
|
8
|
+
import androidx.compose.runtime.key
|
|
7
9
|
import androidx.compose.runtime.mutableStateOf
|
|
8
10
|
import androidx.compose.runtime.staticCompositionLocalOf
|
|
9
11
|
import androidx.compose.ui.Alignment
|
|
@@ -19,17 +21,17 @@ import kotlinx.coroutines.launch
|
|
|
19
21
|
import kotlinx.serialization.Serializable
|
|
20
22
|
import vn.momo.kits.components.PopupAction
|
|
21
23
|
import vn.momo.kits.components.PopupNotify
|
|
24
|
+
import vn.momo.kits.layout.getScreenLayout
|
|
25
|
+
import vn.momo.kits.modifier.conditional
|
|
22
26
|
import vn.momo.kits.navigation.BottomHeader.*
|
|
23
27
|
import vn.momo.kits.navigation.component.SnackBar
|
|
24
|
-
import vn.momo.
|
|
25
|
-
|
|
26
|
-
import vn.momo.maxapi.contract.navigation.model.DismissTarget
|
|
27
|
-
// AI-GENERATED END: dismiss through the typed navigator target
|
|
28
|
+
import vn.momo.kits.application.KitsBinding
|
|
29
|
+
import vn.momo.kits.application.KitsDismissTarget
|
|
28
30
|
import kotlin.time.Duration.Companion.milliseconds
|
|
29
31
|
|
|
30
32
|
class Navigator(
|
|
31
33
|
private val navController: NavController,
|
|
32
|
-
private val
|
|
34
|
+
private val binding: KitsBinding?,
|
|
33
35
|
private val registry: DynamicScreenRegistry
|
|
34
36
|
) {
|
|
35
37
|
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
|
@@ -94,9 +96,8 @@ class Navigator(
|
|
|
94
96
|
}
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
//
|
|
98
|
-
// back handling
|
|
99
|
-
// Public: the iOS host asks this to decide whether the kit owns the swipe on this screen.
|
|
99
|
+
// Public for the iOS host (does the kit own this swipe?). False on the root, so StackScreen keeps custom
|
|
100
|
+
// back handling and the back still reaches binding.dismiss.
|
|
100
101
|
fun canPop(): Boolean = navController.previousBackStackEntry != null
|
|
101
102
|
|
|
102
103
|
fun pop(count: Int = 1, callBack: (() -> Unit)? = null) {
|
|
@@ -116,9 +117,10 @@ class Navigator(
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
private suspend fun dismissOverplay(isDelay: Boolean = true) {
|
|
120
|
+
val dismissing = OverplayComponentRegistry.current()
|
|
119
121
|
OverplayComponentRegistry.clear()
|
|
120
122
|
if (isDelay) delay(300L.milliseconds)
|
|
121
|
-
OverplayComponentRegistry.hardClearAfterDismiss()
|
|
123
|
+
OverplayComponentRegistry.hardClearAfterDismiss(dismissing)
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
private suspend fun dismissScreen() {
|
|
@@ -128,9 +130,7 @@ class Navigator(
|
|
|
128
130
|
delay(STACK_TRANSITION_DURATION.milliseconds)
|
|
129
131
|
dismissing?.let { registry.unregisterScreen(it.id) }
|
|
130
132
|
} else {
|
|
131
|
-
|
|
132
|
-
maxApi?.dismiss(DismissTarget.Current()) {}
|
|
133
|
-
// AI-GENERATED END: preserve root-screen dismissal
|
|
133
|
+
binding?.dismiss(KitsDismissTarget.Current)
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -187,9 +187,10 @@ class Navigator(
|
|
|
187
187
|
|
|
188
188
|
fun hideSnackBar() {
|
|
189
189
|
scope.launch {
|
|
190
|
+
val dismissing = OverplayComponentRegistry.current()
|
|
190
191
|
OverplayComponentRegistry.clear()
|
|
191
192
|
delay(250L.milliseconds)
|
|
192
|
-
OverplayComponentRegistry.hardClearAfterDismiss()
|
|
193
|
+
OverplayComponentRegistry.hardClearAfterDismiss(dismissing)
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
|
|
@@ -363,42 +364,59 @@ object OverplayComponentRegistry {
|
|
|
363
364
|
requestClose = null
|
|
364
365
|
}
|
|
365
366
|
|
|
367
|
+
internal fun current(): OverplayComponent? = currentOverlayComponent.value
|
|
368
|
+
|
|
369
|
+
// An overlay shown from the dismissed one's onDismiss, before the delayed clear, stays.
|
|
370
|
+
internal fun hardClearAfterDismiss(dismissing: OverplayComponent?) {
|
|
371
|
+
if (currentOverlayComponent.value === dismissing) hardClearAfterDismiss()
|
|
372
|
+
}
|
|
373
|
+
|
|
366
374
|
@Composable
|
|
367
375
|
internal fun OverlayComponent(){
|
|
368
376
|
val overplay = currentOverlayComponent.value ?: return
|
|
369
377
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
378
|
+
// every registration is its own composition (params are new instances), as SwiftUI's `.id(item.id)`:
|
|
379
|
+
// a sheet shown from another one's close must not inherit its finished animation and effects
|
|
380
|
+
key(overplay) {
|
|
381
|
+
when (val params = overplay.params) {
|
|
382
|
+
is OverplayComponentParams.BottomSheet -> {
|
|
383
|
+
BottomSheet(
|
|
384
|
+
content = overplay.content,
|
|
385
|
+
header = params.bottomSheetHeader ?: Title(),
|
|
386
|
+
isSurface = params.isSurface,
|
|
387
|
+
barrierDismissible = params.barrierDismissible,
|
|
388
|
+
draggable = params.draggable,
|
|
389
|
+
useBottomInset = params.useBottomInset,
|
|
390
|
+
footerComponent = params.footerComponent,
|
|
391
|
+
onDismiss = params.onDismiss
|
|
392
|
+
)
|
|
393
|
+
}
|
|
383
394
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
395
|
+
is OverplayComponentParams.Modal -> {
|
|
396
|
+
ModalScreen(
|
|
397
|
+
content = overplay.content,
|
|
398
|
+
barrierDismissible = params.barrierDismissible,
|
|
399
|
+
onDismiss = params.onDismiss
|
|
400
|
+
)
|
|
401
|
+
}
|
|
391
402
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
403
|
+
is OverplayComponentParams.SnackBar -> {
|
|
404
|
+
val layout = getScreenLayout()
|
|
405
|
+
Box(
|
|
406
|
+
modifier = Modifier
|
|
407
|
+
.fillMaxSize()
|
|
408
|
+
// iPhone Duo: clear of the side toolbar strip, like the screen content
|
|
409
|
+
.conditional(layout.isIPhoneDuo) {
|
|
410
|
+
absolutePadding(left = layout.insetLeft, right = layout.insetRight)
|
|
411
|
+
},
|
|
412
|
+
contentAlignment = Alignment.BottomCenter
|
|
413
|
+
) {
|
|
414
|
+
overplay.content()
|
|
415
|
+
}
|
|
398
416
|
}
|
|
399
|
-
}
|
|
400
417
|
|
|
401
|
-
|
|
418
|
+
null -> {}
|
|
419
|
+
}
|
|
402
420
|
}
|
|
403
421
|
}
|
|
404
422
|
}
|
|
@@ -23,12 +23,14 @@ import androidx.compose.foundation.layout.ime
|
|
|
23
23
|
import androidx.compose.foundation.layout.imePadding
|
|
24
24
|
import androidx.compose.foundation.layout.offset
|
|
25
25
|
import androidx.compose.foundation.layout.padding
|
|
26
|
+
import androidx.compose.foundation.layout.width
|
|
26
27
|
import androidx.compose.foundation.lazy.LazyListState
|
|
27
28
|
import androidx.compose.foundation.rememberScrollState
|
|
28
29
|
import androidx.compose.foundation.verticalScroll
|
|
29
30
|
import androidx.compose.material.ExperimentalMaterialApi
|
|
30
31
|
import androidx.compose.runtime.Composable
|
|
31
32
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
33
|
+
import androidx.compose.foundation.layout.PaddingValues
|
|
32
34
|
import androidx.compose.runtime.LaunchedEffect
|
|
33
35
|
import androidx.compose.runtime.State
|
|
34
36
|
import androidx.compose.runtime.getValue
|
|
@@ -54,6 +56,7 @@ import kotlinx.coroutines.flow.Flow
|
|
|
54
56
|
import kotlinx.coroutines.flow.filter
|
|
55
57
|
import kotlinx.coroutines.launch
|
|
56
58
|
import vn.momo.kits.components.InputSearch
|
|
59
|
+
import vn.momo.kits.components.InputSearchSize
|
|
57
60
|
import vn.momo.kits.const.AppNavigationBar
|
|
58
61
|
import vn.momo.kits.const.AppTheme
|
|
59
62
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
@@ -61,7 +64,6 @@ import vn.momo.kits.const.Colors
|
|
|
61
64
|
import vn.momo.kits.const.Spacing
|
|
62
65
|
import vn.momo.kits.modifier.conditional
|
|
63
66
|
import vn.momo.kits.modifier.hideKeyboardOnTap
|
|
64
|
-
import vn.momo.kits.navigation.bottomtab.BOTTOM_TAB_BAR_HEIGHT
|
|
65
67
|
import vn.momo.kits.navigation.component.FABPosition
|
|
66
68
|
import vn.momo.kits.navigation.component.FloatingButton
|
|
67
69
|
import vn.momo.kits.navigation.component.HEADER_HEIGHT
|
|
@@ -70,6 +72,7 @@ import vn.momo.kits.navigation.component.HeaderBackground
|
|
|
70
72
|
import vn.momo.kits.navigation.component.HeaderRight
|
|
71
73
|
import vn.momo.kits.navigation.component.HeaderSideBar
|
|
72
74
|
import vn.momo.kits.navigation.bottomtab.LocalDuoRailReserve
|
|
75
|
+
import vn.momo.kits.navigation.bottomtab.LocalTabBarHasCenterAction
|
|
73
76
|
import vn.momo.kits.navigation.bottomtab.duoFloatingTabBarInset
|
|
74
77
|
import vn.momo.kits.navigation.component.HeaderType
|
|
75
78
|
import vn.momo.kits.navigation.component.InputSearchType
|
|
@@ -84,27 +87,36 @@ import vn.momo.kits.utils.horizontalSafeAreaPadding
|
|
|
84
87
|
import vn.momo.kits.layout.LocalScreenLayout
|
|
85
88
|
import vn.momo.kits.layout.ScreenLayout
|
|
86
89
|
import vn.momo.kits.layout.consumeHorizontalInsets
|
|
87
|
-
import vn.momo.kits.layout.
|
|
90
|
+
import vn.momo.kits.layout.HEADER_BANNER_WIDTH
|
|
91
|
+
import vn.momo.kits.layout.HEADER_BUTTON_SIZE
|
|
92
|
+
import vn.momo.kits.layout.HEADER_TITLE_GAP
|
|
88
93
|
import vn.momo.kits.layout.getScreenLayout
|
|
94
|
+
import vn.momo.kits.layout.rememberHeaderLayout
|
|
89
95
|
import kotlin.time.Clock
|
|
90
96
|
import kotlin.time.Duration.Companion.milliseconds
|
|
91
97
|
import kotlin.time.ExperimentalTime
|
|
92
98
|
|
|
99
|
+
@Composable
|
|
100
|
+
fun floatingTabBarContentPadding(): PaddingValues {
|
|
101
|
+
val navigation = LocalNavigation.current
|
|
102
|
+
LaunchedEffect(navigation) { navigation.bottomTabEdgeToEdge = true }
|
|
103
|
+
val reserve = navigation.bottomTabIndex != -1 && navigation.bottomTabEdgeToEdge
|
|
104
|
+
return PaddingValues(bottom = if (reserve) bottomTabChildInset() else 0.dp)
|
|
105
|
+
}
|
|
106
|
+
|
|
93
107
|
internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
|
|
94
108
|
internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
|
|
95
109
|
|
|
96
|
-
// Space a tab's content leaves for the tab bar and home indicator
|
|
97
|
-
//
|
|
110
|
+
// Space a tab's content leaves for the tab bar and home indicator: the horizontal bar floats over the
|
|
111
|
+
// content (phone and unfolded Duo); the Duo rail lives in the side strip, so only the home indicator.
|
|
98
112
|
@Composable
|
|
99
113
|
private fun bottomTabChildInset(): Dp {
|
|
100
114
|
val keyboard = keyboardSizeState().value
|
|
101
115
|
val navigationBar = AppNavigationBar.current
|
|
102
116
|
val layout = getScreenLayout()
|
|
103
117
|
return when {
|
|
104
|
-
layout.isIPhoneDuo && layout.sideBar
|
|
105
|
-
|
|
106
|
-
else -> (BOTTOM_TAB_BAR_HEIGHT.dp + Spacing.S - keyboard).coerceAtLeast(0.dp) +
|
|
107
|
-
(navigationBar - keyboard).coerceAtLeast(0.dp)
|
|
118
|
+
layout.isIPhoneDuo && layout.sideBar != null -> (navigationBar - keyboard).coerceAtLeast(0.dp)
|
|
119
|
+
else -> (duoFloatingTabBarInset(layout, LocalTabBarHasCenterAction.current) - keyboard).coerceAtLeast(0.dp)
|
|
108
120
|
}
|
|
109
121
|
}
|
|
110
122
|
|
|
@@ -119,7 +131,7 @@ internal fun StackScreen(
|
|
|
119
131
|
onBackHandler: (() -> Unit)? = null,
|
|
120
132
|
) {
|
|
121
133
|
val navigator = LocalNavigator.current
|
|
122
|
-
val
|
|
134
|
+
val binding = LocalKitsBinding.current
|
|
123
135
|
val context = LocalContext.current
|
|
124
136
|
val screenLayout = getScreenLayout()
|
|
125
137
|
val density = LocalDensity.current
|
|
@@ -133,45 +145,39 @@ internal fun StackScreen(
|
|
|
133
145
|
// A mounted-but-hidden bottom tab tracks again each time it is focused (RN useFocusEffect).
|
|
134
146
|
val tabFocused = LocalBottomTabFocused.current
|
|
135
147
|
|
|
136
|
-
// Auto tracking state
|
|
137
148
|
val trackingState = remember(tabFocused) {
|
|
138
149
|
ScreenTrackingState().apply {
|
|
139
150
|
time = Clock.System.now().toEpochMilliseconds()
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
|
|
143
|
-
// Determine action: push or back
|
|
144
154
|
val action = remember(tabFocused) {
|
|
145
155
|
if (ScreenTracker.getLastScreenName() != null) "push" else "back"
|
|
146
156
|
}
|
|
147
157
|
|
|
148
|
-
// Auto tracking effects
|
|
149
158
|
LaunchedEffect(name, tabFocused) {
|
|
150
159
|
if (!tabFocused) return@LaunchedEffect
|
|
151
|
-
// Track screen navigated immediately
|
|
152
160
|
ScreenTracker.trackScreenNavigated(
|
|
153
|
-
|
|
161
|
+
binding = binding,
|
|
154
162
|
context = context,
|
|
155
163
|
screenName = name,
|
|
156
164
|
action = action,
|
|
157
165
|
state = trackingState
|
|
158
166
|
)
|
|
159
167
|
|
|
160
|
-
// Track screen displayed after 2 seconds (debounce)
|
|
161
168
|
delay(2000.milliseconds)
|
|
162
169
|
val loadTime = Clock.System.now().toEpochMilliseconds() - trackingState.time
|
|
163
170
|
ScreenTracker.trackScreenDisplayed(
|
|
164
|
-
|
|
171
|
+
binding = binding,
|
|
165
172
|
context = context,
|
|
166
173
|
screenName = name,
|
|
167
174
|
duration = loadTime,
|
|
168
175
|
state = trackingState
|
|
169
176
|
)
|
|
170
177
|
|
|
171
|
-
// Track screen interacted after displayed
|
|
172
178
|
val interactionTime = Clock.System.now().toEpochMilliseconds() - trackingState.time
|
|
173
179
|
ScreenTracker.trackScreenInteracted(
|
|
174
|
-
|
|
180
|
+
binding = binding,
|
|
175
181
|
context = context,
|
|
176
182
|
screenName = name,
|
|
177
183
|
duration = interactionTime - loadTime,
|
|
@@ -205,9 +211,7 @@ internal fun StackScreen(
|
|
|
205
211
|
|
|
206
212
|
val canPop = navigator.canPop()
|
|
207
213
|
|
|
208
|
-
val hasCustomBackHandling = !SwipeBackConfig.enabled ||
|
|
209
|
-
OverplayComponentRegistry.isOverplayShowing() ||
|
|
210
|
-
!canPop
|
|
214
|
+
val hasCustomBackHandling = !SwipeBackConfig.enabled || OverplayComponentRegistry.isOverplayShowing() || !canPop
|
|
211
215
|
|
|
212
216
|
BackHandler(hasCustomBackHandling) { navigator.onBackSafe() }
|
|
213
217
|
|
|
@@ -219,21 +223,17 @@ internal fun StackScreen(
|
|
|
219
223
|
LocalFooterHeightPx provides footerHeightPx,
|
|
220
224
|
LocalHeaderRightWidthPx provides headerRightWidthPx
|
|
221
225
|
) {
|
|
222
|
-
// AI-GENERATED START: custom screen background, full window and outside the keyboard padding
|
|
223
226
|
Box(Modifier.fillMaxSize()) {
|
|
224
227
|
options.backgroundComponent?.let { background ->
|
|
225
228
|
Box(Modifier.fillMaxSize()) { background() }
|
|
226
229
|
}
|
|
227
|
-
// AI-GENERATED END: custom screen background, full window and outside the keyboard padding
|
|
228
230
|
Box(
|
|
229
231
|
Modifier
|
|
230
232
|
.fillMaxSize()
|
|
231
|
-
// AI-GENERATED START: custom background replaces the colour
|
|
232
233
|
.background(
|
|
233
234
|
if (options.backgroundComponent != null) Color.Transparent
|
|
234
235
|
else options.backgroundColor ?: AppTheme.current.colors.background.default
|
|
235
236
|
)
|
|
236
|
-
// AI-GENERATED END: custom background replaces the colour
|
|
237
237
|
.conditional(options.keyboardOptions.keyboardShouldPersistTaps) {
|
|
238
238
|
hideKeyboardOnTap()
|
|
239
239
|
}
|
|
@@ -272,9 +272,7 @@ internal fun StackScreen(
|
|
|
272
272
|
|
|
273
273
|
OverplayView(isBottomTabChild = isBottomTabChild, id = id)
|
|
274
274
|
}
|
|
275
|
-
// AI-GENERATED START: custom screen background, full window and outside the keyboard padding
|
|
276
275
|
}
|
|
277
|
-
// AI-GENERATED END: custom screen background, full window and outside the keyboard padding
|
|
278
276
|
}
|
|
279
277
|
}
|
|
280
278
|
|
|
@@ -333,7 +331,6 @@ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTa
|
|
|
333
331
|
|
|
334
332
|
Spacer(Modifier.height((HEADER_HEIGHT.dp - scrollDp).coerceIn(0.dp, HEADER_HEIGHT.dp)))
|
|
335
333
|
}
|
|
336
|
-
// a bottom tab root stays full width: the tab bar and each tab's own StackScreen handle the insets
|
|
337
334
|
val insetContent = !isBottomTabRoot
|
|
338
335
|
Column(
|
|
339
336
|
Modifier
|
|
@@ -351,7 +348,8 @@ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTa
|
|
|
351
348
|
.padding(
|
|
352
349
|
bottom = when {
|
|
353
350
|
options.hasFooter() || isBottomTabRoot -> 0.dp
|
|
354
|
-
|
|
351
|
+
// 0 when the tab pads itself via floatingTabBarContentPadding(), else the kit reserves the bar space
|
|
352
|
+
isBottomTabChild -> if (LocalNavigation.current.bottomTabEdgeToEdge) 0.dp else bottomTabChildInset()
|
|
355
353
|
!options.scrollData.scrollable && options.scrollData.scrollState == null -> 0.dp
|
|
356
354
|
else -> navigationBar
|
|
357
355
|
}
|
|
@@ -376,12 +374,25 @@ internal fun ScreenContent(content: @Composable () -> Unit, insetContent: Boolea
|
|
|
376
374
|
|
|
377
375
|
if (options.headerType is HeaderType.Animated) {
|
|
378
376
|
val animatedHeader = options.headerType
|
|
377
|
+
val isBannerCentered = rememberHeaderLayout(options.contentLayout).isBannerCentered
|
|
379
378
|
Box {
|
|
379
|
+
// wide windows and the iPhone Duo inner display keep the phone banner size, centered over
|
|
380
|
+
// a fill fading down from bannerBackgroundColor
|
|
381
|
+
val bannerWidth = if (isBannerCentered) Modifier.width(HEADER_BANNER_WIDTH) else Modifier.fillMaxWidth()
|
|
380
382
|
val bannerModifier = animatedHeader.height
|
|
381
|
-
?.let {
|
|
382
|
-
?:
|
|
383
|
-
Box(
|
|
384
|
-
animatedHeader.
|
|
383
|
+
?.let { bannerWidth.height(it) }
|
|
384
|
+
?: bannerWidth.aspectRatio(animatedHeader.aspectRatio.value)
|
|
385
|
+
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.TopCenter) {
|
|
386
|
+
val fill = animatedHeader.bannerBackgroundColor
|
|
387
|
+
if (isBannerCentered && fill != null) {
|
|
388
|
+
Box(
|
|
389
|
+
Modifier.matchParentSize()
|
|
390
|
+
.background(Brush.verticalGradient(listOf(fill, fill.copy(alpha = 0f))))
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
Box(bannerModifier) {
|
|
394
|
+
animatedHeader.composable.invoke(scrollState.value)
|
|
395
|
+
}
|
|
385
396
|
}
|
|
386
397
|
Box(
|
|
387
398
|
Modifier
|
|
@@ -401,8 +412,8 @@ internal fun FooterContent() {
|
|
|
401
412
|
val options = LocalOptions.current
|
|
402
413
|
if (options.hasFooter()) {
|
|
403
414
|
val keyboardSize = keyboardSizeState()
|
|
404
|
-
// the
|
|
405
|
-
val duoTabInset = if (LocalNavigation.current.bottomTabIndex != -1) duoFloatingTabBarInset(getScreenLayout()) else 0.dp
|
|
415
|
+
// the floating tab bar overlays tab content, so a tab's footer sits above it
|
|
416
|
+
val duoTabInset = if (LocalNavigation.current.bottomTabIndex != -1) duoFloatingTabBarInset(getScreenLayout(), LocalTabBarHasCenterAction.current) else 0.dp
|
|
406
417
|
val bottomPadding = (maxOf(AppNavigationBar.current, duoTabInset) - keyboardSize.value).coerceAtLeast(0.dp)
|
|
407
418
|
Footer(
|
|
408
419
|
footerComponent = options.footerComponent,
|
|
@@ -514,17 +525,18 @@ internal fun SearchAnimated(
|
|
|
514
525
|
// collapsed, the search is centered in the bar row
|
|
515
526
|
val minTopPadding = screenLayout.headerStatusBarHeight + (screenLayout.headerBarHeight - HEADER_HEIGHT.dp) / 2
|
|
516
527
|
val maxTopPadding = screenLayout.headerHeight
|
|
517
|
-
// collapsed on the iPhone Duo status bar row, the search stays between its clusters
|
|
528
|
+
// collapsed on the iPhone Duo status bar row, the search stays between its clusters
|
|
518
529
|
val clearance = screenLayout.statusBarClearance
|
|
519
|
-
|
|
520
|
-
val
|
|
530
|
+
// stretch screens on wide windows keep the search in the header's centered frame
|
|
531
|
+
val sidePadding = rememberHeaderLayout(options.contentLayout).frameInset
|
|
532
|
+
val minStartPadding = sidePadding
|
|
521
533
|
val maxStartPadding = (clearance?.left ?: 0.dp) +
|
|
522
|
-
if (options.hiddenBack || useSideBar)
|
|
523
|
-
val minEndPadding =
|
|
534
|
+
if (options.hiddenBack || useSideBar) sidePadding else HEADER_BUTTON_SIZE + sidePadding + HEADER_TITLE_GAP
|
|
535
|
+
val minEndPadding = sidePadding
|
|
524
536
|
val maxEndPadding = (clearance?.right ?: 0.dp) + when {
|
|
525
|
-
options.headerRight is HeaderRight.None ->
|
|
526
|
-
useSideBar && options.headerRight is HeaderRight.Toolkit ->
|
|
527
|
-
else -> headerRightWidthDp + Spacing.M
|
|
537
|
+
options.headerRight is HeaderRight.None -> sidePadding
|
|
538
|
+
useSideBar && options.headerRight is HeaderRight.Toolkit -> sidePadding
|
|
539
|
+
else -> headerRightWidthDp + sidePadding + Spacing.M
|
|
528
540
|
}
|
|
529
541
|
|
|
530
542
|
val targetColor = lerp(
|
|
@@ -585,7 +597,8 @@ internal fun SearchAnimated(
|
|
|
585
597
|
onPressButtonText = {
|
|
586
598
|
navigator.pop()
|
|
587
599
|
}
|
|
588
|
-
)
|
|
600
|
+
),
|
|
601
|
+
size = InputSearchSize.Header,
|
|
589
602
|
)
|
|
590
603
|
}
|
|
591
604
|
}
|
|
@@ -708,15 +721,20 @@ private fun rememberQuickReturnHide(
|
|
|
708
721
|
return hide
|
|
709
722
|
}
|
|
710
723
|
|
|
711
|
-
internal fun NavigationOptions.usesDuoQuickReturnHeader(layout: ScreenLayout): Boolean
|
|
712
|
-
usesDuoGlassHeader(layout)
|
|
713
|
-
|
|
724
|
+
internal fun NavigationOptions.usesDuoQuickReturnHeader(layout: ScreenLayout): Boolean {
|
|
725
|
+
if (usesDuoGlassHeader(layout)) return true
|
|
726
|
+
return layout.sideBar != null && headerType is HeaderType.Animated && scrollsWithScrollState()
|
|
727
|
+
}
|
|
714
728
|
|
|
715
729
|
// iPhone Duo side bar: content scrolls under a glass header instead of starting below it (RN Screen).
|
|
716
|
-
internal fun NavigationOptions.usesDuoGlassHeader(layout: ScreenLayout): Boolean
|
|
717
|
-
layout.sideBar
|
|
718
|
-
|
|
719
|
-
|
|
730
|
+
internal fun NavigationOptions.usesDuoGlassHeader(layout: ScreenLayout): Boolean {
|
|
731
|
+
if (layout.sideBar == null || headerType !is HeaderType.DefaultOrExtended) return false
|
|
732
|
+
return getInputSearchType(this) == InputSearchType.None && scrollsWithScrollState()
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
private fun NavigationOptions.scrollsWithScrollState(): Boolean {
|
|
736
|
+
return scrollData.scrollable && scrollData.scrollState is ScrollState
|
|
737
|
+
}
|
|
720
738
|
|
|
721
739
|
internal fun getInputSearchType(options: NavigationOptions): InputSearchType {
|
|
722
740
|
return when (val headerType = options.headerType) {
|
|
@@ -52,19 +52,23 @@ object SwipeBackConfig {
|
|
|
52
52
|
// decouple the card from the finger.
|
|
53
53
|
private val stackSpec = tween<IntOffset>(STACK_TRANSITION_DURATION, easing = LinearEasing)
|
|
54
54
|
|
|
55
|
-
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackEnter(): EnterTransition
|
|
56
|
-
slideInHorizontally(stackSpec) { it }
|
|
55
|
+
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackEnter(): EnterTransition {
|
|
56
|
+
return slideInHorizontally(stackSpec) { it }
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackExit(): ExitTransition
|
|
59
|
-
if (targetState.destination.hasRoute<DynamicDialogRoute>()) ExitTransition.None
|
|
60
|
-
|
|
59
|
+
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackExit(): ExitTransition {
|
|
60
|
+
if (targetState.destination.hasRoute<DynamicDialogRoute>()) return ExitTransition.None
|
|
61
|
+
return slideOutHorizontally(stackSpec) { -(it * PARALLAX_RATIO).roundToInt() }
|
|
62
|
+
}
|
|
61
63
|
|
|
62
|
-
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopEnter(): EnterTransition
|
|
63
|
-
if (initialState.destination.hasRoute<DynamicDialogRoute>()) EnterTransition.None
|
|
64
|
-
|
|
64
|
+
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopEnter(): EnterTransition {
|
|
65
|
+
if (initialState.destination.hasRoute<DynamicDialogRoute>()) return EnterTransition.None
|
|
66
|
+
return slideInHorizontally(stackSpec) { -(it * PARALLAX_RATIO).roundToInt() }
|
|
67
|
+
}
|
|
65
68
|
|
|
66
|
-
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopExit(): ExitTransition
|
|
67
|
-
slideOutHorizontally(stackSpec) { it }
|
|
69
|
+
internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopExit(): ExitTransition {
|
|
70
|
+
return slideOutHorizontally(stackSpec) { it }
|
|
71
|
+
}
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
74
|
* Which composed screen is the top card. Ids are monotonic and NavHost keeps both entries composed
|
|
@@ -5,32 +5,27 @@ import androidx.compose.runtime.LaunchedEffect
|
|
|
5
5
|
import androidx.compose.runtime.snapshotFlow
|
|
6
6
|
import vn.momo.kits.platform.getScreenDimensions
|
|
7
7
|
import vn.momo.kits.platform.rememberBackGestureProgress
|
|
8
|
-
import vn.momo.
|
|
9
|
-
// AI-GENERATED START: use the typed light vibration pattern
|
|
10
|
-
import vn.momo.maxapi.contract.device.vibration.model.VibrateStyle
|
|
11
|
-
// AI-GENERATED END: use the typed light vibration pattern
|
|
8
|
+
import vn.momo.kits.application.KitsBinding
|
|
12
9
|
|
|
13
10
|
// Unscaled, so the tick lands at the same physical distance on every device.
|
|
14
11
|
private const val SWIPE_BACK_HAPTIC_THRESHOLD_DP = 50f
|
|
15
12
|
|
|
16
13
|
/** One light tick per crossing, re-armed below the threshold. iOS only. */
|
|
17
14
|
@Composable
|
|
18
|
-
internal fun SwipeBackHaptic(
|
|
19
|
-
if (
|
|
15
|
+
internal fun SwipeBackHaptic(binding: KitsBinding?) {
|
|
16
|
+
if (binding == null) return
|
|
20
17
|
|
|
21
18
|
val progress = rememberBackGestureProgress()
|
|
22
19
|
val screenWidth = getScreenDimensions().width.toFloat()
|
|
23
20
|
|
|
24
|
-
LaunchedEffect(
|
|
21
|
+
LaunchedEffect(binding, screenWidth) {
|
|
25
22
|
if (screenWidth <= 0f) return@LaunchedEffect
|
|
26
23
|
val threshold = SWIPE_BACK_HAPTIC_THRESHOLD_DP / screenWidth
|
|
27
24
|
var isSendHaptic = false
|
|
28
25
|
snapshotFlow { progress.value }.collect { fraction ->
|
|
29
26
|
val travelled = fraction ?: 0f
|
|
30
27
|
if (travelled >= threshold && !isSendHaptic) {
|
|
31
|
-
|
|
32
|
-
runCatching { maxApi.vibrate(VibrateStyle.LIGHT) }
|
|
33
|
-
// AI-GENERATED END: keep one light tick per threshold crossing
|
|
28
|
+
runCatching { binding.vibrateLight() }
|
|
34
29
|
isSendHaptic = true
|
|
35
30
|
} else if (travelled < threshold && isSendHaptic) {
|
|
36
31
|
isSendHaptic = false
|