@momo-kits/native-kits 0.168.1-beta.30-debug → 0.168.1-beta.31-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 +2 -1
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/compose.podspec +1 -1
  4. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +13 -1
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +3 -3
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +9 -9
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +18 -10
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +167 -313
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +71 -79
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +380 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +326 -93
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +2 -1
  15. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  16. package/gradle.properties +1 -1
  17. package/ios/Input/Input.swift +3 -1
  18. package/ios/Input/InputTextArea.swift +3 -1
  19. package/ios/Navigation/BottomTab/BottomTab.swift +33 -14
  20. package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -254
  21. package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
  22. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
  23. package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -71
  24. package/ios/Navigation/StackScreen.swift +1 -3
  25. package/ios/native-kits.podspec +1 -1
  26. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  27. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -224
  28. package/package.json +1 -1
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -106
  30. package/ios/Navigation/BottomTab/TabBarMetrics.swift +0 -88
  31. package/local.properties +0 -9
package/CLAUDE.md CHANGED
@@ -71,12 +71,13 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
71
71
  ## Screen layout / iPhone Duo (port of RN `useScreenLayout`, momo-kits !664)
72
72
 
73
73
  - `layout/ScreenLayout.kt`: `getScreenLayout()` returns window size, raw top/bottom + side insets, `contentWidth`, header geometry, the iPhone Duo `sideBar` and `duoTopInset`. `NavigationContainer` computes it once and provides `LocalScreenLayout`; reactive to fold/unfold and rotation (window size + `WindowInsets`). Metrics (`DuoMetrics`, 72pt iPhone header floor, 20pt status-bar threshold) mirror RN `Layout/utils.ts` — change both together.
74
- - iPhone-only: everything gates on `isPhoneIdiom()` (`platform/`), never on "iOS", so iPad windows keep the regular layout. Two detectors, as in RN: `isIPhoneDuo` (window aspect < 1.6 or asymmetric side insets) drives layout; `isIPhoneDuoDevice` (Apple's foldable check: a `.division` reserved region, queried with include-inactive; Swift also latches on `UIHingeInteraction`; or asymmetric side insets, since the outer display reports no hinge) drives popups, modal and bottom sheet.
74
+ - iPhone-only: everything gates on `isPhoneIdiom()` (`platform/`), never on "iOS", so iPad windows keep the regular layout. Two detectors, as in RN: `isIPhoneDuo` (window aspect < 1.6 or asymmetric side insets) drives layout; `isIPhoneDuoDevice` (Apple's foldable check: a `.division` reserved region, queried with include-inactive; Swift also latches on `UIHingeInteraction`; or asymmetric side insets, since the outer display reports no hinge; on Android the hinge angle sensor feature, so foldables get the sizes but no side strip or side column) drives popups, modal and bottom sheet.
75
75
  - Header height is `headerHeight` (not `AppStatusBar + HEADER_HEIGHT`); the bar row is `headerBarHeight` and starts `headerStatusBarHeight` below the window top. When the status bar is off the top edge (iPhone landscape, iPhone Duo) `headerStatusBarHeight` is 0 so the title stays centered — except on the Duo outer display: in portrait the header is 76pt and the row starts at 14pt so the title centers on the camera punchout; in landscape the row centers on the camera when it sits at the top end of the strip (else on the back button) and the header reaches 8pt below the back button.
76
76
  - iPhone Duo inner display in portrait (status bar on top): the header row shares the status bar band — `headerHeight` 94pt (2 × the clock digits' y 47), `headerStatusBarHeight` 0 — and `ScreenLayout.statusBarClearance` keeps it between the clock / battery clusters (from reserved regions, else 128pt on the right). Back and toolkit use the 48pt side bar controls laid out horizontally (`ToolkitLayout.SideBarRow`); the collapsed search and a centered title stay clear of the clusters. Port of momo-kits `90af33ba2`.
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.30-debug"
43
+ version = "0.168.1-beta.31-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.168.1-beta.30-debug'
3
+ spec.version = '0.168.1-beta.24-debug'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -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
+ }
@@ -1,6 +1,18 @@
1
1
  package vn.momo.kits.platform
2
2
 
3
+ import android.content.pm.PackageManager
4
+ import android.os.Build
3
5
  import androidx.compose.runtime.Composable
6
+ import androidx.compose.runtime.remember
7
+ import androidx.compose.ui.platform.LocalContext
4
8
 
5
9
  @Composable
6
- internal actual fun rememberReservedRegions(): ReservedRegions = ReservedRegions()
10
+ internal actual fun rememberReservedRegions(): ReservedRegions {
11
+ val context = LocalContext.current
12
+ return remember(context) {
13
+ ReservedRegions(
14
+ isFoldable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
15
+ context.packageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_HINGE_ANGLE),
16
+ )
17
+ }
18
+ }
@@ -51,8 +51,8 @@ data class ScreenLayout(
51
51
  val headerStatusBarHeight: Dp,
52
52
  // iPhone Duo moves back and toolkit into a column in the side safe area; null while they stay in the bar.
53
53
  val sideBar: SideBarLayout? = null,
54
- // iPhone Duo folded or not, whatever the window size (its hinge, or the outer display's one-sided strip);
55
- // drives popups, modal and bottom sheet.
54
+ // iPhone Duo folded or not, whatever the window size (its hinge, or the outer display's one-sided strip),
55
+ // and Android foldables (their hinge, no side strip); drives popups, modal and bottom sheet.
56
56
  val isIPhoneDuoDevice: Boolean = isIPhoneDuo,
57
57
  // Portrait iPhone Duo puts the status bar in the side strip, about twice as tall as the strip is wide.
58
58
  // Stored so it survives consumeHorizontalInsets().
@@ -151,7 +151,7 @@ internal fun calculateScreenLayout(topInset: Dp, parent: ScreenLayout? = null):
151
151
  bottomInset = bottomPx.toDp(),
152
152
  isPhone = isPhone,
153
153
  asymmetricInsets = leftPx != rightPx,
154
- isDuoDevice = isPhone && reservedRegions.isFoldable,
154
+ isDuoDevice = reservedRegions.isFoldable,
155
155
  reservedRegions = reservedRegions.occlusion,
156
156
  )
157
157
  }
@@ -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,7 +1,5 @@
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
5
  import androidx.compose.animation.core.Easing
@@ -12,12 +10,14 @@ import androidx.compose.runtime.Composable
12
10
  import androidx.compose.runtime.CompositionLocalProvider
13
11
  import androidx.compose.runtime.DisposableEffect
14
12
  import androidx.compose.runtime.LaunchedEffect
13
+ import androidx.compose.runtime.getValue
15
14
  import androidx.compose.runtime.key
16
15
  import androidx.compose.runtime.mutableIntStateOf
17
16
  import androidx.compose.runtime.mutableStateOf
18
17
  import androidx.compose.runtime.remember
19
18
  import androidx.compose.runtime.saveable.rememberSaveable
20
19
  import androidx.compose.runtime.saveable.rememberSaveableStateHolder
20
+ import androidx.compose.runtime.setValue
21
21
  import androidx.compose.runtime.staticCompositionLocalOf
22
22
  import androidx.compose.ui.Alignment
23
23
  import androidx.compose.ui.Modifier
@@ -25,7 +25,9 @@ import androidx.compose.ui.graphics.graphicsLayer
25
25
  import androidx.compose.ui.layout.layout
26
26
  import androidx.compose.ui.unit.dp
27
27
  import androidx.compose.ui.zIndex
28
+ import vn.momo.kits.const.AppNavigationBar
28
29
  import vn.momo.kits.const.AppTheme
30
+ import vn.momo.kits.const.Spacing
29
31
  import vn.momo.kits.navigation.KeyboardOptions
30
32
  import vn.momo.kits.navigation.LocalMaxApi
31
33
  import vn.momo.kits.navigation.LocalNavigation
@@ -38,7 +40,7 @@ import vn.momo.kits.platform.reportFloatingArrowBack
38
40
  import vn.momo.kits.layout.getScreenLayout
39
41
  import kotlinx.coroutines.launch
40
42
 
41
- 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) }
42
44
  internal val tabTimingSpec = tween<Float>(durationMillis = 200, easing = inOutQuad)
43
45
 
44
46
  internal val LocalBottomTabFocused = staticCompositionLocalOf { true }
@@ -70,6 +72,8 @@ fun BottomTab(
70
72
  initialRouteName: String? = null,
71
73
  onTabPress: ((index: Int, switchTab: () -> Unit) -> Unit)? = null,
72
74
  backToInitialTab: Boolean = true,
75
+ // RN tabLongPress; on iPhone Duo the held tab is still selected on release
76
+ onTabLongPress: ((index: Int) -> Unit)? = null,
73
77
  ) {
74
78
  val navigation = LocalNavigation.current
75
79
  val navigator = LocalNavigator.current
@@ -145,7 +149,6 @@ fun BottomTab(
145
149
  CompositionLocalProvider(
146
150
  LocalDuoRailReserve provides railReserve,
147
151
  LocalDuoBarCompression provides compression,
148
- LocalTabBarHasCenterAction provides hasCenterAction(floatingButton, items.size),
149
152
  ) {
150
153
  loadedTabs.forEach { index ->
151
154
  val item = items.getOrNull(index) ?: return@forEach
@@ -194,14 +197,19 @@ fun BottomTab(
194
197
  selectedIndex = selectedIndex,
195
198
  onTabSelected = onTabSelected,
196
199
  compression = compression,
200
+ onTabLongPress = onTabLongPress,
197
201
  )
198
202
  } else {
199
- BottomTabBar(
200
- items = items,
201
- floatingButton = floatingButton,
202
- selectedIndex = selectedIndex,
203
- onTabSelected = onTabSelected,
204
- )
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
+ }
205
213
  }
206
214
  }
207
215
  }