@momo-kits/native-kits 0.164.1-beta.17-debug → 0.164.1-beta.18-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 +4 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +19 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +9 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +12 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +7 -0
- package/gradle.properties +1 -1
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/package.json +2 -2
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -10,3 +10,7 @@ import androidx.compose.runtime.remember
|
|
|
10
10
|
// Revisit if androidx.activity >= 1.12 is adopted; this then becomes a copy of the iOS actual.
|
|
11
11
|
@Composable
|
|
12
12
|
actual fun rememberBackGestureProgress(): State<Float?> = remember { mutableStateOf(null) }
|
|
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
|
+
actual fun reportFloatingArrowBack(shouldUse: Boolean) = Unit
|
|
@@ -8,12 +8,14 @@ import androidx.compose.animation.scaleOut
|
|
|
8
8
|
import androidx.compose.foundation.background
|
|
9
9
|
import androidx.compose.foundation.layout.*
|
|
10
10
|
import androidx.compose.runtime.Composable
|
|
11
|
+
import androidx.compose.runtime.DisposableEffect
|
|
11
12
|
import androidx.compose.runtime.LaunchedEffect
|
|
12
13
|
import androidx.compose.ui.Alignment
|
|
13
14
|
import androidx.compose.ui.Modifier
|
|
14
15
|
import androidx.compose.ui.unit.dp
|
|
15
16
|
import androidx.navigation.compose.NavHost
|
|
16
17
|
import androidx.navigation.compose.composable
|
|
18
|
+
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
17
19
|
import androidx.navigation.compose.rememberNavController
|
|
18
20
|
import vn.momo.kits.const.AppNavigationBar
|
|
19
21
|
import vn.momo.kits.const.AppTheme
|
|
@@ -24,6 +26,7 @@ import vn.momo.kits.navigation.LocalNavigator
|
|
|
24
26
|
import vn.momo.kits.navigation.NavigationOptions
|
|
25
27
|
import vn.momo.kits.navigation.StackScreen
|
|
26
28
|
import vn.momo.kits.navigation.component.HeaderType
|
|
29
|
+
import vn.momo.kits.platform.reportFloatingArrowBack
|
|
27
30
|
|
|
28
31
|
private var bottomTabOptionItems : MutableList<NavigationOptions?> = mutableListOf()
|
|
29
32
|
internal fun setBottomTabOption(index: Int, options: NavigationOptions){
|
|
@@ -59,6 +62,22 @@ fun BottomTab(
|
|
|
59
62
|
)
|
|
60
63
|
}
|
|
61
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Matches the React Native side. On the first tab the host replays its drag into NavHost and
|
|
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
|
+
*/
|
|
72
|
+
val currentRoute = navController.currentBackStackEntryAsState().value?.destination?.route
|
|
73
|
+
val isFirstTab = currentRoute == null || currentRoute == "option0"
|
|
74
|
+
|
|
75
|
+
DisposableEffect(isFirstTab) {
|
|
76
|
+
reportFloatingArrowBack(!isFirstTab)
|
|
77
|
+
// the flag lives on the host and would otherwise outlive the tabs that asked for it
|
|
78
|
+
onDispose { reportFloatingArrowBack(false) }
|
|
79
|
+
}
|
|
80
|
+
|
|
62
81
|
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomCenter) {
|
|
63
82
|
Box(modifier = Modifier
|
|
64
83
|
.fillMaxSize()
|
|
@@ -13,3 +13,12 @@ import androidx.compose.runtime.State
|
|
|
13
13
|
*/
|
|
14
14
|
@Composable
|
|
15
15
|
expect fun rememberBackGestureProgress(): State<Float?>
|
|
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
|
+
*/
|
|
24
|
+
expect fun reportFloatingArrowBack(shouldUse: Boolean)
|
|
@@ -38,6 +38,18 @@ object HostBackGestureBridge {
|
|
|
38
38
|
val hasEnabledHandlers: Boolean
|
|
39
39
|
get() = attachedInputs.lastOrNull()?.hasEnabledHandlers == true
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Whether the host should run its floating-arrow interaction instead of replaying the drag
|
|
43
|
+
* here. Set while a bottom tab other than the first one is showing: every tab lives inside a
|
|
44
|
+
* single stack card, so seeking that card would take all of them with it rather than
|
|
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.
|
|
49
|
+
*/
|
|
50
|
+
var shouldUseFloatingArrowBack: Boolean = false
|
|
51
|
+
internal set
|
|
52
|
+
|
|
41
53
|
/** Begins a drag. Pairs with exactly one [completed] or [cancelled]. */
|
|
42
54
|
fun started() {
|
|
43
55
|
val input = attachedInputs.lastOrNull() ?: return
|
|
@@ -8,6 +8,7 @@ import androidx.compose.runtime.remember
|
|
|
8
8
|
import androidx.compose.ui.InternalComposeUiApi
|
|
9
9
|
import androidx.compose.ui.backhandler.LocalCompatNavigationEventDispatcherOwner
|
|
10
10
|
import androidx.navigationevent.NavigationEventTransitionState
|
|
11
|
+
import vn.momo.kits.navigation.HostBackGestureBridge
|
|
11
12
|
|
|
12
13
|
// NavigationEventDispatcher.transitionState is a passive observer: UIKitNavigationEventInput
|
|
13
14
|
// publishes every edge-pan event to it without any handler consuming the gesture. Its `progress`
|
|
@@ -33,3 +34,9 @@ actual fun rememberBackGestureProgress(): State<Float?> {
|
|
|
33
34
|
|
|
34
35
|
return progress
|
|
35
36
|
}
|
|
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
|
+
actual fun reportFloatingArrowBack(shouldUse: Boolean) {
|
|
41
|
+
HostBackGestureBridge.shouldUseFloatingArrowBack = shouldUse
|
|
42
|
+
}
|
package/gradle.properties
CHANGED
package/ios/native-kits.podspec
CHANGED