@momo-kits/native-kits 0.164.1-beta.18-debug → 0.164.1-beta.19-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/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +1 -7
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +3 -7
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -2
- package/gradle.properties +1 -1
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -11,6 +11,4 @@ import androidx.compose.runtime.remember
|
|
|
11
11
|
@Composable
|
|
12
12
|
actual fun rememberBackGestureProgress(): State<Float?> = remember { mutableStateOf(null) }
|
|
13
13
|
|
|
14
|
-
// No host-owned edge recogniser on Android: the system back gesture drives NavHost directly, so
|
|
15
|
-
// there is nothing to hand over.
|
|
16
14
|
actual fun reportFloatingArrowBack(shouldUse: Boolean) = Unit
|
|
@@ -31,6 +31,11 @@ class Navigator(
|
|
|
31
31
|
) {
|
|
32
32
|
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
|
33
33
|
|
|
34
|
+
// Set by BottomTab while a tab other than the first is showing. currentScreen() reads the root
|
|
35
|
+
// back stack, so it never sees the nested tab NavHost — without this every back path except the
|
|
36
|
+
// header button pops the whole BottomTab screen instead of returning to the first tab.
|
|
37
|
+
internal var tabBackHandler: (() -> Unit)? = null
|
|
38
|
+
|
|
34
39
|
private fun currentScreen(): DynamicScreen? {
|
|
35
40
|
val entry = navController.currentBackStackEntry ?: return null
|
|
36
41
|
val id = runCatching { entry.toRoute<DynamicScreenRoute>().id }.getOrNull()
|
|
@@ -52,6 +57,10 @@ class Navigator(
|
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
fun onBackSafe(callBack: (() -> Unit)? = null) {
|
|
60
|
+
tabBackHandler?.let {
|
|
61
|
+
it()
|
|
62
|
+
return
|
|
63
|
+
}
|
|
55
64
|
val currentScreen = currentScreen()
|
|
56
65
|
val options = currentScreen?.options
|
|
57
66
|
if (options?.onBackHandler != null) {
|
|
@@ -62,20 +62,22 @@ fun BottomTab(
|
|
|
62
62
|
)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* the stack transition seeks as usual. On any other tab it must not: every tab lives inside
|
|
68
|
-
* this one stack card, so seeking it would take them all instead of returning to the first
|
|
69
|
-
* tab, which is what `onBackHandler` below does. Hand that case to the host's floating-arrow
|
|
70
|
-
* interaction rather than leaving the swipe to do the wrong thing.
|
|
71
|
-
*/
|
|
65
|
+
// Tab 0 keeps the seeked transition; other tabs go to the host's floating arrow, since
|
|
66
|
+
// seeking this one card would take every tab with it. Matches RN.
|
|
72
67
|
val currentRoute = navController.currentBackStackEntryAsState().value?.destination?.route
|
|
73
68
|
val isFirstTab = currentRoute == null || currentRoute == "option0"
|
|
74
69
|
|
|
75
70
|
DisposableEffect(isFirstTab) {
|
|
76
71
|
reportFloatingArrowBack(!isFirstTab)
|
|
77
|
-
//
|
|
78
|
-
|
|
72
|
+
// onBackSafe reads the root back stack, so it cannot see this nested NavHost on its own
|
|
73
|
+
navigator.tabBackHandler = if (isFirstTab) null else ({
|
|
74
|
+
navController.popBackStack(navController.graph.startDestinationRoute!!, false)
|
|
75
|
+
})
|
|
76
|
+
// both live outside this composition and would otherwise outlive these tabs
|
|
77
|
+
onDispose {
|
|
78
|
+
reportFloatingArrowBack(false)
|
|
79
|
+
navigator.tabBackHandler = null
|
|
80
|
+
}
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) {
|
|
@@ -14,11 +14,5 @@ import androidx.compose.runtime.State
|
|
|
14
14
|
@Composable
|
|
15
15
|
expect fun rememberBackGestureProgress(): State<Float?>
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Reports whether the host should run its floating-arrow back instead of the seeked stack
|
|
19
|
-
* transition. Set while a bottom tab other than the first one is showing.
|
|
20
|
-
*
|
|
21
|
-
* Android is a no-op: its NavHost pops through `androidx.activity`'s dispatcher and there is no
|
|
22
|
-
* host interaction to hand the gesture to.
|
|
23
|
-
*/
|
|
17
|
+
/** Android is a no-op: no host-owned recogniser to hand the gesture to. */
|
|
24
18
|
expect fun reportFloatingArrowBack(shouldUse: Boolean)
|
|
@@ -39,13 +39,9 @@ object HostBackGestureBridge {
|
|
|
39
39
|
get() = attachedInputs.lastOrNull()?.hasEnabledHandlers == true
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* returning to the first tab. Read it when the recogniser begins — the kit keeps it current.
|
|
46
|
-
*
|
|
47
|
-
* Mirrors `MiniAppModule.setShouldUseFloatingArrowBack` on the React Native side, so both
|
|
48
|
-
* stacks hand the same case to the same host interaction.
|
|
42
|
+
* Set while a bottom tab other than the first is showing: every tab lives in one stack card,
|
|
43
|
+
* so seeking it would take them all instead of returning to the first tab. Host pulls this
|
|
44
|
+
* when its recogniser begins. Mirrors `MiniAppModule.setShouldUseFloatingArrowBack` on RN.
|
|
49
45
|
*/
|
|
50
46
|
var shouldUseFloatingArrowBack: Boolean = false
|
|
51
47
|
internal set
|
|
@@ -35,8 +35,6 @@ actual fun rememberBackGestureProgress(): State<Float?> {
|
|
|
35
35
|
return progress
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// The host pulls this when its recogniser begins, so a plain assignment is enough -- no dispatch,
|
|
39
|
-
// no observer. Kept next to the progress observer since both are the same host contract.
|
|
40
38
|
actual fun reportFloatingArrowBack(shouldUse: Boolean) {
|
|
41
39
|
HostBackGestureBridge.shouldUseFloatingArrowBack = shouldUse
|
|
42
40
|
}
|
package/gradle.properties
CHANGED
package/ios/native-kits.podspec
CHANGED