@momo-kits/native-kits 0.168.1-beta.37-debug → 0.168.1-beta.38-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.
Files changed (47) hide show
  1. package/CLAUDE.md +2 -3
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +81 -72
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +13 -8
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +163 -54
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +12 -17
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +34 -27
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +319 -167
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +93 -326
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -2
  18. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +3 -2
  19. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +3 -9
  20. package/ios/Input/Input.swift +1 -3
  21. package/ios/Input/InputTextArea.swift +1 -3
  22. package/ios/Layout/ScreenLayout.swift +24 -28
  23. package/ios/Navigation/BottomSheet.swift +157 -29
  24. package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
  25. package/ios/Navigation/BottomTab/BottomTabBar.swift +280 -132
  26. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  27. package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
  28. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  29. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  30. package/ios/Navigation/ModalScreen.swift +7 -18
  31. package/ios/Navigation/StackScreen.swift +3 -1
  32. package/ios/Popup/PopupDisplay.swift +2 -4
  33. package/ios/Popup/PopupInput.swift +2 -4
  34. package/ios/Popup/PopupLayout.swift +9 -10
  35. package/ios/Popup/PopupNotify.swift +23 -26
  36. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  37. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  38. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  39. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -103
  40. package/package.json +1 -1
  41. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  45. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  46. package/ios/Layout/ModalLayout.swift +0 -152
  47. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
@@ -1,7 +1,10 @@
1
1
  package vn.momo.kits.navigation.bottomtab
2
2
 
3
+ import androidx.compose.runtime.getValue
4
+ import androidx.compose.runtime.setValue
3
5
  import androidx.compose.animation.core.Animatable
4
6
  import androidx.compose.animation.core.AnimationVector1D
7
+ import androidx.compose.animation.core.CubicBezierEasing
5
8
  import androidx.compose.animation.core.Easing
6
9
  import androidx.compose.animation.core.tween
7
10
  import androidx.compose.foundation.background
@@ -10,14 +13,12 @@ import androidx.compose.runtime.Composable
10
13
  import androidx.compose.runtime.CompositionLocalProvider
11
14
  import androidx.compose.runtime.DisposableEffect
12
15
  import androidx.compose.runtime.LaunchedEffect
13
- import androidx.compose.runtime.getValue
14
16
  import androidx.compose.runtime.key
15
17
  import androidx.compose.runtime.mutableIntStateOf
16
18
  import androidx.compose.runtime.mutableStateOf
17
19
  import androidx.compose.runtime.remember
18
20
  import androidx.compose.runtime.saveable.rememberSaveable
19
21
  import androidx.compose.runtime.saveable.rememberSaveableStateHolder
20
- import androidx.compose.runtime.setValue
21
22
  import androidx.compose.runtime.staticCompositionLocalOf
22
23
  import androidx.compose.ui.Alignment
23
24
  import androidx.compose.ui.Modifier
@@ -25,9 +26,8 @@ import androidx.compose.ui.graphics.graphicsLayer
25
26
  import androidx.compose.ui.layout.layout
26
27
  import androidx.compose.ui.unit.dp
27
28
  import androidx.compose.ui.zIndex
28
- import vn.momo.kits.const.AppNavigationBar
29
+ import kotlin.math.abs
29
30
  import vn.momo.kits.const.AppTheme
30
- import vn.momo.kits.const.Spacing
31
31
  import vn.momo.kits.navigation.KeyboardOptions
32
32
  import vn.momo.kits.navigation.LocalMaxApi
33
33
  import vn.momo.kits.navigation.LocalNavigation
@@ -40,8 +40,12 @@ import vn.momo.kits.platform.reportFloatingArrowBack
40
40
  import vn.momo.kits.layout.getScreenLayout
41
41
  import kotlinx.coroutines.launch
42
42
 
43
- private val inOutQuad = Easing { t -> if (t < 0.5f) 2 * t * t else 1 - 2 * (1 - t) * (1 - t) }
44
- internal val tabTimingSpec = tween<Float>(durationMillis = 200, easing = inOutQuad)
43
+ internal val inOutQuad = Easing { t -> if (t < 0.5f) 2 * t * t else 1 - 2 * (1 - t) * (1 - t) }
44
+ // the tab screens slide in index order over 280ms, CSS `ease`
45
+ private val tabSwitchSpec = tween<Float>(durationMillis = 280, easing = CubicBezierEasing(0.25f, 0.1f, 0.25f, 1f))
46
+
47
+ // -1 for tabs before the selected one, 1 for tabs after it: they wait a full width off screen on their side
48
+ private fun tabPosition(index: Int, selected: Int) = (index - selected).coerceIn(-1, 1).toFloat()
45
49
 
46
50
  internal val LocalBottomTabFocused = staticCompositionLocalOf { true }
47
51
 
@@ -72,8 +76,6 @@ fun BottomTab(
72
76
  initialRouteName: String? = null,
73
77
  onTabPress: ((index: Int, switchTab: () -> Unit) -> Unit)? = null,
74
78
  backToInitialTab: Boolean = true,
75
- // RN tabLongPress; on iPhone Duo the held tab is still selected on release
76
- onTabLongPress: ((index: Int) -> Unit)? = null,
77
79
  ) {
78
80
  val navigation = LocalNavigation.current
79
81
  val navigator = LocalNavigator.current
@@ -107,14 +109,21 @@ fun BottomTab(
107
109
  var lastFocusedIndex by rememberSaveable { mutableStateOf<Int?>(null) }
108
110
  val tabProgress = remember { mutableMapOf<Int, Animatable<Float, AnimationVector1D>>() }
109
111
  fun progressOf(index: Int) = tabProgress.getOrPut(index) {
110
- Animatable(if (index == lastFocusedIndex) 1f else 0f)
112
+ Animatable(tabPosition(index, lastFocusedIndex ?: index))
111
113
  }
112
114
  LaunchedEffect(selectedIndex) {
115
+ val previousIndex = lastFocusedIndex
113
116
  lastFocusedIndex = selectedIndex
114
117
  tabProgress.forEach { (index, progress) ->
115
- if (index != selectedIndex) launch { progress.animateTo(0f, tabTimingSpec) }
118
+ val target = tabPosition(index, selectedIndex)
119
+ launch {
120
+ if (index == selectedIndex || index == previousIndex) {
121
+ progress.animateTo(target, tabSwitchSpec)
122
+ } else {
123
+ progress.snapTo(target)
124
+ }
125
+ }
116
126
  }
117
- progressOf(selectedIndex).animateTo(1f, tabTimingSpec)
118
127
  }
119
128
 
120
129
  DisposableEffect(isFirstTab) {
@@ -149,21 +158,20 @@ fun BottomTab(
149
158
  CompositionLocalProvider(
150
159
  LocalDuoRailReserve provides railReserve,
151
160
  LocalDuoBarCompression provides compression,
161
+ LocalTabBarHasCenterAction provides hasCenterAction(floatingButton, items.size),
152
162
  ) {
153
163
  loadedTabs.forEach { index ->
154
164
  val item = items.getOrNull(index) ?: return@forEach
155
165
  val focused = index == selectedIndex
156
166
  val progress = progressOf(index)
167
+ // the leaving tab stays drawn until it has slid off screen
168
+ val visible = focused || abs(progress.value) < 1f
157
169
  key(index) {
158
170
  Box(
159
171
  Modifier
160
172
  .fillMaxSize()
161
173
  .zIndex(if (focused) 0f else -1f)
162
- .then(if (focused) Modifier.graphicsLayer {
163
- alpha = 0.3f + 0.7f * progress.value
164
- scaleX = 0.97f + 0.03f * progress.value
165
- scaleY = scaleX
166
- } else Hidden)
174
+ .then(if (visible) Modifier.graphicsLayer { translationX = progress.value * size.width } else Hidden)
167
175
  ) {
168
176
  CompositionLocalProvider(LocalBottomTabFocused provides focused) {
169
177
  tabStateHolder.SaveableStateProvider(index) {
@@ -197,19 +205,14 @@ fun BottomTab(
197
205
  selectedIndex = selectedIndex,
198
206
  onTabSelected = onTabSelected,
199
207
  compression = compression,
200
- onTabLongPress = onTabLongPress,
201
208
  )
202
209
  } else {
203
- Column {
204
- BottomTabBar(
205
- items = items,
206
- floatingButton = floatingButton,
207
- selectedIndex = selectedIndex,
208
- onTabSelected = onTabSelected,
209
- onTabLongPress = onTabLongPress,
210
- )
211
- Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
212
- }
210
+ BottomTabBar(
211
+ items = items,
212
+ floatingButton = floatingButton,
213
+ selectedIndex = selectedIndex,
214
+ onTabSelected = onTabSelected,
215
+ )
213
216
  }
214
217
  }
215
218
  }
@@ -229,4 +232,8 @@ data class BottomTabFloatingButton(
229
232
  val icon: String,
230
233
  val label: String,
231
234
  val onPress: () -> Unit,
235
+ // replaces the icon inside the 48 button, e.g. the button part of a Lottie; centered, unclipped
236
+ val iconContent: (@Composable () -> Unit)? = null,
237
+ // drawn over the label text, which stays, e.g. the label part of a Lottie; centered, unclipped
238
+ val labelContent: (@Composable () -> Unit)? = null,
232
239
  )