@momo-kits/native-kits 0.168.1-beta.32-debug → 0.168.1-beta.33-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 (31) hide show
  1. package/CLAUDE.md +1 -0
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +2 -3
  4. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +9 -9
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +26 -34
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +167 -319
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +71 -79
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +380 -0
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +326 -93
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +2 -3
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +1 -3
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  14. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +2 -3
  15. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  16. package/ios/Input/Input.swift +3 -1
  17. package/ios/Input/InputTextArea.swift +3 -1
  18. package/ios/Navigation/BottomTab/BottomTab.swift +67 -48
  19. package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -281
  20. package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
  21. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
  22. package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -72
  23. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  24. package/ios/Navigation/StackScreen.swift +1 -3
  25. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -272
  26. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +90 -0
  27. package/package.json +1 -1
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -106
  29. package/ios/Navigation/BottomTab/TabBarMetrics.swift +0 -88
  30. package/ios-demo/Resources/tabbar_scan_qr_button.json +0 -1
  31. package/ios-demo/Resources/tabbar_scan_qr_label.json +0 -1
package/CLAUDE.md CHANGED
@@ -77,6 +77,7 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
77
77
  - iPhone Duo with a side strip ≥ 60pt: back + toolkit leave the bar for `HeaderSideBar` (`navigation/component/SideBar.kt`, 48pt glass controls); custom header-right stays in the bar. `sideBar.top` is 170pt in portrait, 120pt on the inner display in landscape (height ≥ 600), 24pt on the outer display in landscape, or below the header when the status bar is on top; UIKit's `statusBarFrame` is useless on Duo. Unlike RN the column is clamped above footer (24pt gap) / rail (12pt gap).
78
78
  - Reserved regions (iOS 27.1 `reservedRegionsOfKind:`, reached through the ObjC runtime so older SDKs still build): a probe `UIView` (`platform/ReservedRegions.ios.kt` on the Compose root view; `ReservedRegionsProbe` inside SwiftUI `momoScreenLayout()`) re-reads them in `layoutSubviews`, which UIKit re-runs when they change. They push `sideBar.top` below the status cluster as it grows for calls / Live Activities, and `sideBar.bottom` (≥ 24pt) above a camera at the bottom end of the strip.
79
79
  - Tab bar on Duo is `bottomtab/DuoTabBar.kt`: a rail in the side strip (`sideBar.bottom` above the window bottom, QR below it) or, without a side bar, a floating bar spanning 6/8 grid columns. Both overlay the content; `duoFloatingTabBarInset` pads tab content, footer and FAB.
80
+ - Duo tab selection motion (`bottomtab/DuoLiquidSelection.kt` / `ios/Navigation/BottomTab/DuoLiquidSelection.swift`, port of RN `useLiquidSelection.ts`, momo-kits !682): press lifts the lens, a drag past 10pt takes over (Compose: the bar's `pointerInput` consumes and so cancels the tab's clickable; SwiftUI: one `DragGesture` over the bar, tabs are not `Button`s), long press calls `BottomTab(onTabLongPress)` and release still selects, Reduce Motion (`platform/ReduceMotion`) falls back to a plain slide. SwiftUI integrates the lens spring on a display link because the stretch and the tabs' active tint read it every frame. Constants mirror RN — change both together.
80
81
  - Bar compression (`bottomtab/DuoBarCompression.kt`, HIG "Vertical controls"): when toolbar + rail don't fit in the strip, one is compressed — the toolkit into a `navigation_menu` button, the rail into one button showing the current tab — and tapping it swaps them; `BottomTab(compressionBehavior)` picks which starts compressed. If neither fits beside the other compressed, both rest compressed and a tap opens one for a moment. Side bar columns report their full height (0 when the screen puts nothing there) so the decision follows each screen's toolkit.
81
82
  - Glass header: on Duo with a side bar, Default/Extended headers without search and with a `ScrollState` let content scroll under the bar (`usesDuoGlassHeader`); the bar fades in a translucent surface + hairline over 16pt (Compose has no backdrop blur — RN's fallback look), the gradient leaves with the content.
82
83
  - Quick return header: glass headers and Animated headers (with a `ScrollState`) on the Duo side bar layout slide out with the content and back in on a reverse scroll; a half-shown header settles in or out once the scroll stops. The side bar is drawn apart from the header, so it stays put.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.168.1-beta.32-debug"
43
+ version = "0.168.1-beta.33-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -88,11 +88,10 @@ actual fun LottieAnimation(
88
88
  isPlaying: Boolean,
89
89
  onEvent: ((String) -> Unit)?,
90
90
  modifier: Modifier,
91
- useCompose: Boolean,
92
- progress: (() -> Float)?,
91
+ useCompose: Boolean
93
92
  ) {
94
93
  if (useCompose) {
95
- ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier, progress)
94
+ ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
96
95
  return
97
96
  }
98
97
 
@@ -0,0 +1,17 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import android.provider.Settings
4
+ import androidx.compose.runtime.Composable
5
+ import androidx.compose.runtime.remember
6
+ import androidx.compose.ui.platform.LocalConfiguration
7
+ import androidx.compose.ui.platform.LocalContext
8
+
9
+ @Composable
10
+ actual fun rememberReduceMotion(): Boolean {
11
+ val context = LocalContext.current
12
+ // re-read on configuration changes; the setting has no observer of its own
13
+ val configuration = LocalConfiguration.current
14
+ return remember(context, configuration) {
15
+ Settings.Global.getFloat(context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) == 0f
16
+ }
17
+ }
@@ -61,6 +61,7 @@ import vn.momo.kits.const.Colors
61
61
  import vn.momo.kits.const.Spacing
62
62
  import vn.momo.kits.modifier.conditional
63
63
  import vn.momo.kits.modifier.hideKeyboardOnTap
64
+ import vn.momo.kits.navigation.bottomtab.BOTTOM_TAB_BAR_HEIGHT
64
65
  import vn.momo.kits.navigation.component.FABPosition
65
66
  import vn.momo.kits.navigation.component.FloatingButton
66
67
  import vn.momo.kits.navigation.component.HEADER_HEIGHT
@@ -69,7 +70,6 @@ import vn.momo.kits.navigation.component.HeaderBackground
69
70
  import vn.momo.kits.navigation.component.HeaderRight
70
71
  import vn.momo.kits.navigation.component.HeaderSideBar
71
72
  import vn.momo.kits.navigation.bottomtab.LocalDuoRailReserve
72
- import vn.momo.kits.navigation.bottomtab.LocalTabBarHasCenterAction
73
73
  import vn.momo.kits.navigation.bottomtab.duoFloatingTabBarInset
74
74
  import vn.momo.kits.navigation.component.HeaderType
75
75
  import vn.momo.kits.navigation.component.InputSearchType
@@ -93,16 +93,18 @@ import kotlin.time.ExperimentalTime
93
93
  internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
94
94
  internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
95
95
 
96
- // Space a tab's content leaves for the tab bar and home indicator: the horizontal bar floats over the
97
- // content (phone and unfolded Duo); the Duo rail lives in the side strip, so only the home indicator.
96
+ // Space a tab's content leaves for the tab bar and home indicator. On iPhone Duo the floating bar
97
+ // overlays the content and the rail lives in the side strip, so only their own inset applies.
98
98
  @Composable
99
99
  private fun bottomTabChildInset(): Dp {
100
100
  val keyboard = keyboardSizeState().value
101
101
  val navigationBar = AppNavigationBar.current
102
102
  val layout = getScreenLayout()
103
103
  return when {
104
- layout.isIPhoneDuo && layout.sideBar != null -> (navigationBar - keyboard).coerceAtLeast(0.dp)
105
- else -> (duoFloatingTabBarInset(layout, LocalTabBarHasCenterAction.current) - keyboard).coerceAtLeast(0.dp)
104
+ layout.isIPhoneDuo && layout.sideBar == null -> (duoFloatingTabBarInset(layout) - keyboard).coerceAtLeast(0.dp)
105
+ layout.isIPhoneDuo -> (navigationBar - keyboard).coerceAtLeast(0.dp)
106
+ else -> (BOTTOM_TAB_BAR_HEIGHT.dp + Spacing.S - keyboard).coerceAtLeast(0.dp) +
107
+ (navigationBar - keyboard).coerceAtLeast(0.dp)
106
108
  }
107
109
  }
108
110
 
@@ -349,8 +351,6 @@ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTa
349
351
  .padding(
350
352
  bottom = when {
351
353
  options.hasFooter() || isBottomTabRoot -> 0.dp
352
- // after verticalScroll this pads inside the scroll content: it runs under the floating
353
- // tab bar and ends clear of it; static content stays above the bar
354
354
  isBottomTabChild -> bottomTabChildInset()
355
355
  !options.scrollData.scrollable && options.scrollData.scrollState == null -> 0.dp
356
356
  else -> navigationBar
@@ -401,8 +401,8 @@ internal fun FooterContent() {
401
401
  val options = LocalOptions.current
402
402
  if (options.hasFooter()) {
403
403
  val keyboardSize = keyboardSizeState()
404
- // the floating tab bar overlays tab content, so a tab's footer sits above it
405
- val duoTabInset = if (LocalNavigation.current.bottomTabIndex != -1) duoFloatingTabBarInset(getScreenLayout(), LocalTabBarHasCenterAction.current) else 0.dp
404
+ // the Duo floating tab bar overlays tab content, so a tab's footer sits above it
405
+ val duoTabInset = if (LocalNavigation.current.bottomTabIndex != -1) duoFloatingTabBarInset(getScreenLayout()) else 0.dp
406
406
  val bottomPadding = (maxOf(AppNavigationBar.current, duoTabInset) - keyboardSize.value).coerceAtLeast(0.dp)
407
407
  Footer(
408
408
  footerComponent = options.footerComponent,
@@ -1,10 +1,7 @@
1
1
  package vn.momo.kits.navigation.bottomtab
2
2
 
3
- import androidx.compose.runtime.getValue
4
- import androidx.compose.runtime.setValue
5
3
  import androidx.compose.animation.core.Animatable
6
4
  import androidx.compose.animation.core.AnimationVector1D
7
- import androidx.compose.animation.core.CubicBezierEasing
8
5
  import androidx.compose.animation.core.Easing
9
6
  import androidx.compose.animation.core.tween
10
7
  import androidx.compose.foundation.background
@@ -13,12 +10,14 @@ import androidx.compose.runtime.Composable
13
10
  import androidx.compose.runtime.CompositionLocalProvider
14
11
  import androidx.compose.runtime.DisposableEffect
15
12
  import androidx.compose.runtime.LaunchedEffect
13
+ import androidx.compose.runtime.getValue
16
14
  import androidx.compose.runtime.key
17
15
  import androidx.compose.runtime.mutableIntStateOf
18
16
  import androidx.compose.runtime.mutableStateOf
19
17
  import androidx.compose.runtime.remember
20
18
  import androidx.compose.runtime.saveable.rememberSaveable
21
19
  import androidx.compose.runtime.saveable.rememberSaveableStateHolder
20
+ import androidx.compose.runtime.setValue
22
21
  import androidx.compose.runtime.staticCompositionLocalOf
23
22
  import androidx.compose.ui.Alignment
24
23
  import androidx.compose.ui.Modifier
@@ -26,8 +25,9 @@ import androidx.compose.ui.graphics.graphicsLayer
26
25
  import androidx.compose.ui.layout.layout
27
26
  import androidx.compose.ui.unit.dp
28
27
  import androidx.compose.ui.zIndex
29
- import kotlin.math.abs
28
+ import vn.momo.kits.const.AppNavigationBar
30
29
  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,13 +40,8 @@ import vn.momo.kits.platform.reportFloatingArrowBack
40
40
  import vn.momo.kits.layout.getScreenLayout
41
41
  import kotlinx.coroutines.launch
42
42
 
43
- internal val inOutQuad = Easing { t -> if (t < 0.5f) 2 * t * t else 1 - 2 * (1 - t) * (1 - t) }
43
+ private val inOutQuad = Easing { t -> if (t < 0.5f) 2 * t * t else 1 - 2 * (1 - t) * (1 - t) }
44
44
  internal val tabTimingSpec = tween<Float>(durationMillis = 200, easing = inOutQuad)
45
- // the tab screens slide in index order over 280ms, CSS `ease`
46
- private val tabSwitchSpec = tween<Float>(durationMillis = 280, easing = CubicBezierEasing(0.25f, 0.1f, 0.25f, 1f))
47
-
48
- // -1 for tabs before the selected one, 1 for tabs after it: they wait a full width off screen on their side
49
- private fun tabPosition(index: Int, selected: Int) = (index - selected).coerceIn(-1, 1).toFloat()
50
45
 
51
46
  internal val LocalBottomTabFocused = staticCompositionLocalOf { true }
52
47
 
@@ -77,6 +72,8 @@ fun BottomTab(
77
72
  initialRouteName: String? = null,
78
73
  onTabPress: ((index: Int, switchTab: () -> Unit) -> Unit)? = null,
79
74
  backToInitialTab: Boolean = true,
75
+ // RN tabLongPress; on iPhone Duo the held tab is still selected on release
76
+ onTabLongPress: ((index: Int) -> Unit)? = null,
80
77
  ) {
81
78
  val navigation = LocalNavigation.current
82
79
  val navigator = LocalNavigator.current
@@ -110,21 +107,14 @@ fun BottomTab(
110
107
  var lastFocusedIndex by rememberSaveable { mutableStateOf<Int?>(null) }
111
108
  val tabProgress = remember { mutableMapOf<Int, Animatable<Float, AnimationVector1D>>() }
112
109
  fun progressOf(index: Int) = tabProgress.getOrPut(index) {
113
- Animatable(tabPosition(index, lastFocusedIndex ?: index))
110
+ Animatable(if (index == lastFocusedIndex) 1f else 0f)
114
111
  }
115
112
  LaunchedEffect(selectedIndex) {
116
- val previousIndex = lastFocusedIndex
117
113
  lastFocusedIndex = selectedIndex
118
114
  tabProgress.forEach { (index, progress) ->
119
- val target = tabPosition(index, selectedIndex)
120
- launch {
121
- if (index == selectedIndex || index == previousIndex) {
122
- progress.animateTo(target, tabSwitchSpec)
123
- } else {
124
- progress.snapTo(target)
125
- }
126
- }
115
+ if (index != selectedIndex) launch { progress.animateTo(0f, tabTimingSpec) }
127
116
  }
117
+ progressOf(selectedIndex).animateTo(1f, tabTimingSpec)
128
118
  }
129
119
 
130
120
  DisposableEffect(isFirstTab) {
@@ -159,20 +149,21 @@ fun BottomTab(
159
149
  CompositionLocalProvider(
160
150
  LocalDuoRailReserve provides railReserve,
161
151
  LocalDuoBarCompression provides compression,
162
- LocalTabBarHasCenterAction provides hasCenterAction(floatingButton, items.size),
163
152
  ) {
164
153
  loadedTabs.forEach { index ->
165
154
  val item = items.getOrNull(index) ?: return@forEach
166
155
  val focused = index == selectedIndex
167
156
  val progress = progressOf(index)
168
- // the leaving tab stays drawn until it has slid off screen
169
- val visible = focused || abs(progress.value) < 1f
170
157
  key(index) {
171
158
  Box(
172
159
  Modifier
173
160
  .fillMaxSize()
174
161
  .zIndex(if (focused) 0f else -1f)
175
- .then(if (visible) Modifier.graphicsLayer { translationX = progress.value * size.width } else Hidden)
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)
176
167
  ) {
177
168
  CompositionLocalProvider(LocalBottomTabFocused provides focused) {
178
169
  tabStateHolder.SaveableStateProvider(index) {
@@ -206,14 +197,19 @@ fun BottomTab(
206
197
  selectedIndex = selectedIndex,
207
198
  onTabSelected = onTabSelected,
208
199
  compression = compression,
200
+ onTabLongPress = onTabLongPress,
209
201
  )
210
202
  } else {
211
- BottomTabBar(
212
- items = items,
213
- floatingButton = floatingButton,
214
- selectedIndex = selectedIndex,
215
- onTabSelected = onTabSelected,
216
- )
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
+ }
217
213
  }
218
214
  }
219
215
  }
@@ -233,8 +229,4 @@ data class BottomTabFloatingButton(
233
229
  val icon: String,
234
230
  val label: String,
235
231
  val onPress: () -> Unit,
236
- // replaces the icon inside the 48 button, e.g. the button part of a Lottie; centered, unclipped
237
- val iconContent: (@Composable () -> Unit)? = null,
238
- // drawn over the label text, which stays, e.g. the label part of a Lottie; centered, unclipped
239
- val labelContent: (@Composable () -> Unit)? = null,
240
232
  )