@momo-kits/native-kits 0.169.10-beta.1-debug → 0.169.10-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 (96) hide show
  1. package/compose/build.gradle.kts +1 -1
  2. package/compose/compose.podspec +1 -1
  3. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +19 -19
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +3 -2
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +5 -6
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -17
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -59
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -2
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +11 -12
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +5 -20
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +2 -2
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +2 -3
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +5 -8
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +7 -5
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +3 -4
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +18 -20
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +1 -2
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +6 -7
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +2 -7
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +3 -2
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +2 -3
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +27 -44
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +1 -3
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +13 -10
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +7 -6
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +14 -13
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +39 -29
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +35 -32
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +16 -9
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +3 -4
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +1 -2
  42. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
  43. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +1 -2
  44. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +2 -3
  45. package/gradle.properties +1 -1
  46. package/ios/Application/DesignSystemKits.swift +2 -3
  47. package/ios/Application/LanguageSource.swift +2 -3
  48. package/ios/Application/Localize.swift +4 -7
  49. package/ios/Application/LocalizeModifier.swift +2 -3
  50. package/ios/Badge/Badge.swift +5 -7
  51. package/ios/Button/Button.swift +2 -3
  52. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +3 -5
  53. package/ios/Carousel/Carousel.swift +2 -3
  54. package/ios/Collapse/Collapse.swift +17 -11
  55. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  56. package/ios/Icon/Icon.swift +2 -3
  57. package/ios/IconButton/IconButton.swift +2 -3
  58. package/ios/Input/InputSearch.swift +6 -23
  59. package/ios/Layout/ModalLayout.swift +2 -3
  60. package/ios/Layout/ScreenLayout.swift +10 -12
  61. package/ios/Layout/Section.swift +2 -3
  62. package/ios/Navigation/BottomSheet.swift +6 -9
  63. package/ios/Navigation/BottomTab/BottomTab.swift +6 -9
  64. package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -6
  65. package/ios/Navigation/BottomTab/CurvedContainer.swift +2 -3
  66. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  67. package/ios/Navigation/BottomTab/DuoTabBar.swift +6 -6
  68. package/ios/Navigation/BottomTab/TabBarMetrics.swift +4 -6
  69. package/ios/Navigation/Component/Header.swift +46 -31
  70. package/ios/Navigation/Component/HeaderJourney.swift +1 -2
  71. package/ios/Navigation/Component/HeaderLocation.swift +1 -2
  72. package/ios/Navigation/Component/HeaderRight.swift +15 -18
  73. package/ios/Navigation/Component/HeaderUser.swift +1 -2
  74. package/ios/Navigation/Component/SideBar.swift +15 -7
  75. package/ios/Navigation/HostBackGestureBridge.swift +2 -3
  76. package/ios/Navigation/ModalScreen.swift +13 -11
  77. package/ios/Navigation/Navigation.swift +3 -9
  78. package/ios/Navigation/NavigationContainer.swift +4 -6
  79. package/ios/Navigation/Navigator.swift +12 -18
  80. package/ios/Navigation/StackScreen.swift +25 -40
  81. package/ios/Navigation/StackTransition.swift +7 -6
  82. package/ios/Skeleton/Skeleton.swift +3 -6
  83. package/ios/Steps/Steps.swift +20 -15
  84. package/ios/TabView/TabView.swift +2 -3
  85. package/ios/Title/Title.swift +1 -3
  86. package/ios/Typography/FontScale.swift +6 -9
  87. package/ios/Typography/Text.swift +2 -3
  88. package/ios/Typography/Typography.swift +3 -4
  89. package/ios/native-kits.podspec +1 -1
  90. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  91. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +2 -11
  92. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -11
  93. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +1 -1
  94. package/package.json +1 -1
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -67
  96. package/ios/Layout/HeaderLayout.swift +0 -67
@@ -7,11 +7,15 @@ import androidx.compose.runtime.remember
7
7
  import androidx.compose.ui.Modifier
8
8
  import androidx.compose.ui.graphics.Color
9
9
  import androidx.compose.ui.text.AnnotatedString
10
+ import androidx.compose.ui.text.SpanStyle
10
11
  import androidx.compose.ui.text.TextLayoutResult
11
12
  import androidx.compose.ui.text.TextStyle
13
+ import androidx.compose.ui.text.buildAnnotatedString
14
+ import androidx.compose.ui.text.font.FontSynthesis
12
15
  import androidx.compose.ui.text.style.TextAlign
13
16
  import androidx.compose.ui.text.style.TextDecoration
14
17
  import androidx.compose.ui.text.style.TextOverflow
18
+ import androidx.compose.ui.text.withStyle
15
19
  import androidx.compose.ui.unit.TextUnit
16
20
  import androidx.compose.ui.unit.dp
17
21
  import vn.momo.kits.application.IsShowBaseLineDebug
@@ -118,3 +122,54 @@ fun Text(
118
122
  )
119
123
  }
120
124
 
125
+ // Highlighted keywords keep the caller's text size; only the weight changes.
126
+ @Composable
127
+ internal fun rememberHighlightedText(text: String, highlightText: List<String>): AnnotatedString {
128
+ // Host fonts are one file per weight: swap fontFamily and disable synthesis so the SemiBold file isn't
129
+ // faux-bolded again; fontWeight still applies when no host font is bundled and the system font is used.
130
+ val highlightWeight = Typography.headerXsSemibold.fontWeight
131
+ val highlightFontFamily = getFontFamily(AppTheme.current.font, highlightWeight)
132
+ return remember(text, highlightText, highlightFontFamily) {
133
+ buildHighlightedText(
134
+ text,
135
+ highlightText,
136
+ SpanStyle(
137
+ fontFamily = highlightFontFamily,
138
+ fontWeight = highlightWeight,
139
+ fontSynthesis = FontSynthesis.None,
140
+ ),
141
+ )
142
+ }
143
+ }
144
+
145
+ // Whole-word matches only; the longest keyword wins when keywords overlap (RN parity).
146
+ private fun buildHighlightedText(
147
+ text: String,
148
+ highlightText: List<String>,
149
+ style: SpanStyle,
150
+ ): AnnotatedString {
151
+ val keywords = highlightText.filter { it.isNotEmpty() }
152
+ if (keywords.isEmpty()) return AnnotatedString(text)
153
+ val regex = Regex(keywords.sortedByDescending { it.length }.joinToString("|") { Regex.escape(it) })
154
+ fun isWordChar(index: Int) = text.getOrNull(index)?.let { it.isLetterOrDigit() || it == '_' } == true
155
+
156
+ return buildAnnotatedString {
157
+ var lastIndex = 0
158
+ var searchFrom = 0
159
+ while (true) {
160
+ val match = regex.find(text, searchFrom) ?: break
161
+ val start = match.range.first
162
+ val end = match.range.last + 1
163
+ if (isWordChar(start - 1) || isWordChar(end)) {
164
+ searchFrom = start + 1
165
+ continue
166
+ }
167
+ append(text.substring(lastIndex, start))
168
+ withStyle(style) { append(match.value) }
169
+ lastIndex = end
170
+ searchFrom = end
171
+ }
172
+ append(text.substring(lastIndex))
173
+ }
174
+ }
175
+
@@ -164,10 +164,9 @@ internal fun getDateComponents(
164
164
  formatParts.size == 1 && formatParts[0] == "HH"
165
165
  }
166
166
 
167
- val dayData =
168
- remember(currentDate.year, currentDate.month, effectiveMinDate, effectiveMaxDate) {
169
- getDaysInMonth(currentDate.year, currentDate.month, effectiveMinDate, effectiveMaxDate)
170
- }
167
+ val dayData = remember(currentDate.year, currentDate.month, effectiveMinDate, effectiveMaxDate) {
168
+ getDaysInMonth(currentDate.year, currentDate.month, effectiveMinDate, effectiveMaxDate)
169
+ }
171
170
 
172
171
  val monthData = remember(currentDate.year, effectiveMinDate, effectiveMaxDate) {
173
172
  getMonths(effectiveMinDate, effectiveMaxDate, currentDate.year)
@@ -185,26 +184,25 @@ internal fun getDateComponents(
185
184
  getMinutes(minuteInterval)
186
185
  }
187
186
 
188
- val dateComponents =
189
- remember(formatParts, dayData, monthData, yearData, hourData, minData, isOnlyHour) {
190
- val components = mutableListOf<DateComponent>()
191
-
192
- formatParts.forEach { part ->
193
- when (part) {
194
- "DD" -> components.add(DateComponent("day", dayData))
195
- "MM" -> components.add(DateComponent("month", monthData))
196
- "YYYY" -> components.add(DateComponent("year", yearData))
197
- "HH" -> components.add(DateComponent("hour", hourData))
198
- "mm" -> components.add(DateComponent("minute", minData))
199
- }
200
- }
187
+ val dateComponents = remember(formatParts, dayData, monthData, yearData, hourData, minData, isOnlyHour) {
188
+ val components = mutableListOf<DateComponent>()
201
189
 
202
- if (isOnlyHour) {
203
- components.add(DateComponent("timeMode", timeMode))
190
+ formatParts.forEach { part ->
191
+ when (part) {
192
+ "DD" -> components.add(DateComponent("day", dayData))
193
+ "MM" -> components.add(DateComponent("month", monthData))
194
+ "YYYY" -> components.add(DateComponent("year", yearData))
195
+ "HH" -> components.add(DateComponent("hour", hourData))
196
+ "mm" -> components.add(DateComponent("minute", minData))
204
197
  }
198
+ }
205
199
 
206
- components
200
+ if (isOnlyHour) {
201
+ components.add(DateComponent("timeMode", timeMode))
207
202
  }
208
203
 
204
+ components
205
+ }
206
+
209
207
  return dateComponents
210
208
  }
@@ -40,8 +40,7 @@ fun scaleSize(size: Float): Float {
40
40
  var fontSizeScaleOS = size
41
41
 
42
42
  if (deviceScale > 1) {
43
- fontSizeScaleDevice =
44
- min(deviceScale * fontSizeScaleDevice, fontSizeScaleDevice + MAX_DEVICE_SCALE)
43
+ fontSizeScaleDevice = min(deviceScale * fontSizeScaleDevice, fontSizeScaleDevice + MAX_DEVICE_SCALE)
45
44
  }
46
45
 
47
46
  if (fontScale > 1) {
@@ -105,8 +105,7 @@ internal val LocalScreenLayout = compositionLocalOf<ScreenLayout?> { null }
105
105
 
106
106
  // Port of RN `useScreenLayout`; follows fold/unfold and rotation through the window size and safe area.
107
107
  @Composable
108
- fun getScreenLayout(): ScreenLayout =
109
- LocalScreenLayout.current ?: calculateScreenLayout(getAppStatusBarHeight())
108
+ fun getScreenLayout(): ScreenLayout = LocalScreenLayout.current ?: calculateScreenLayout(getAppStatusBarHeight())
110
109
 
111
110
  @Composable
112
111
  internal fun calculateScreenLayout(topInset: Dp, parent: ScreenLayout? = null): ScreenLayout {
@@ -158,8 +157,9 @@ internal fun calculateScreenLayout(topInset: Dp, parent: ScreenLayout? = null):
158
157
  }
159
158
 
160
159
  // Content inside the safe-area padding: the insets are spent and the side bar belongs to the screen.
161
- internal fun ScreenLayout.consumeHorizontalInsets(): ScreenLayout =
162
- copy(width = contentWidth, insetLeft = 0.dp, insetRight = 0.dp, sideBar = null)
160
+ internal fun ScreenLayout.consumeHorizontalInsets(): ScreenLayout {
161
+ return copy(width = contentWidth, insetLeft = 0.dp, insetRight = 0.dp, sideBar = null)
162
+ }
163
163
 
164
164
  // titleCenterY: window y the title row centers on for the outer display in landscape.
165
165
  private fun headerGeometry(
@@ -191,9 +191,8 @@ private fun statusBarRowGeometry(): Pair<Dp, Dp> = DuoMetrics.innerStatusBarCent
191
191
 
192
192
  private data class StripOcclusion(val top: Dp, val topCenter: Dp, val bottom: Dp)
193
193
 
194
- // How far system regions reach into a side strip from its top and from its bottom end
195
- // (e.g. the camera, which sits at either end depending on the rotation), and the center y
196
- // of the region reaching furthest from the top.
194
+ // Reach of system regions into a side strip from each end (the camera sits at either end by rotation),
195
+ // plus the center y of the region reaching furthest from the top.
197
196
  private fun stripOcclusion(regions: List<ReservedRegion>, stripLeft: Dp, stripRight: Dp, windowHeight: Dp): StripOcclusion {
198
197
  var top = 0.dp
199
198
  var topCenter = 0.dp
@@ -18,10 +18,12 @@ fun Modifier.setAutomationId(accessibilityId: String, mergeDescendants: Boolean
18
18
  semantics(mergeDescendants = mergeDescendants) {
19
19
  testTag = accessibilityId
20
20
  }
21
- }}
21
+ }
22
+ }
22
23
 
23
- fun Modifier.kitsAutomationId(accessibilityId: String, label: String? = null) =
24
- this then KitsAutomationIdElement(accessibilityId, label)
24
+ fun Modifier.kitsAutomationId(accessibilityId: String, label: String? = null): Modifier {
25
+ return this then KitsAutomationIdElement(accessibilityId, label)
26
+ }
25
27
 
26
28
  private data class KitsAutomationIdElement(
27
29
  private val accessibilityId: String,
@@ -3,7 +3,6 @@ package vn.momo.kits.navigation
3
3
  import androidx.compose.foundation.gestures.ScrollableState
4
4
  import androidx.compose.runtime.*
5
5
  import androidx.compose.ui.graphics.Color
6
- import vn.momo.kits.layout.ContentLayout
7
6
  import vn.momo.kits.navigation.bottomtab.setBottomTabOption
8
7
  import vn.momo.kits.navigation.component.*
9
8
 
@@ -41,8 +40,7 @@ class Navigation(
41
40
  footerTransparent: Boolean? = null,
42
41
  footerUseMargin: Boolean? = null,
43
42
  floatingButtonProps: FloatingButtonProps? = null,
44
- keyboardOptions: KeyboardOptions? = null,
45
- contentLayout: ContentLayout? = null,
43
+ keyboardOptions: KeyboardOptions? = null
46
44
  ) {
47
45
  updateOptions(
48
46
  options.copy(
@@ -62,7 +60,6 @@ class Navigation(
62
60
  footerUseMargin = footerUseMargin ?: options.footerUseMargin,
63
61
  floatingButtonProps = floatingButtonProps ?: options.floatingButtonProps,
64
62
  keyboardOptions = keyboardOptions ?: options.keyboardOptions,
65
- contentLayout = contentLayout ?: options.contentLayout,
66
63
  )
67
64
  )
68
65
  }
@@ -100,9 +97,7 @@ data class NavigationOptions(
100
97
  val footerTransparent: Boolean = false,
101
98
  val footerUseMargin: Boolean = true,
102
99
  val floatingButtonProps: FloatingButtonProps? = null,
103
- val keyboardOptions: KeyboardOptions = KeyboardOptions(),
104
- // Wide windows: Stretch puts the header row in the centered 600pt content frame.
105
- val contentLayout: ContentLayout = ContentLayout.Grid,
100
+ val keyboardOptions: KeyboardOptions = KeyboardOptions()
106
101
  ) {
107
102
  internal fun hasFooter() : Boolean = footerComponent != null
108
103
  }
@@ -65,8 +65,9 @@ fun NavigationContainer(
65
65
 
66
66
  val stackTransition = remember { StackTransitionCoordinator() }
67
67
  val theme = remember { mutableStateOf(initialTheme) }
68
- val resolvedDesignSystemConfig =
69
- designSystemConfig ?: LocalDesignSystemConfig.current ?: DesignSystemKits.getConfigs().designSystemConfig
68
+ val resolvedDesignSystemConfig = designSystemConfig
69
+ ?: LocalDesignSystemConfig.current
70
+ ?: DesignSystemKits.getConfigs().designSystemConfig
70
71
  val headerBar = resolvedDesignSystemConfig?.headerBar
71
72
  // RN parity: the theme's own header image wins; config headerBar is only the fallback.
72
73
  val resolvedTheme = remember(theme.value, headerBar) {
@@ -95,9 +95,8 @@ class Navigator(
95
95
  }
96
96
  }
97
97
 
98
- // The swipe-back opt-out predicate in StackScreen needs this: the root screen must keep custom
99
- // back handling so it still reaches maxApi.dismiss.
100
- // Public: the iOS host asks this to decide whether the kit owns the swipe on this screen.
98
+ // Public for the iOS host (does the kit own this swipe?). False on the root, so StackScreen keeps custom
99
+ // back handling and the back still reaches maxApi.dismiss.
101
100
  fun canPop(): Boolean = navController.previousBackStackEntry != null
102
101
 
103
102
  fun pop(count: Int = 1, callBack: (() -> Unit)? = null) {
@@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.ime
23
23
  import androidx.compose.foundation.layout.imePadding
24
24
  import androidx.compose.foundation.layout.offset
25
25
  import androidx.compose.foundation.layout.padding
26
- import androidx.compose.foundation.layout.width
27
26
  import androidx.compose.foundation.lazy.LazyListState
28
27
  import androidx.compose.foundation.rememberScrollState
29
28
  import androidx.compose.foundation.verticalScroll
@@ -56,7 +55,6 @@ import kotlinx.coroutines.flow.Flow
56
55
  import kotlinx.coroutines.flow.filter
57
56
  import kotlinx.coroutines.launch
58
57
  import vn.momo.kits.components.InputSearch
59
- import vn.momo.kits.components.InputSearchSize
60
58
  import vn.momo.kits.const.AppNavigationBar
61
59
  import vn.momo.kits.const.AppTheme
62
60
  import vn.momo.kits.application.IsShowBaseLineDebug
@@ -87,11 +85,8 @@ import vn.momo.kits.utils.horizontalSafeAreaPadding
87
85
  import vn.momo.kits.layout.LocalScreenLayout
88
86
  import vn.momo.kits.layout.ScreenLayout
89
87
  import vn.momo.kits.layout.consumeHorizontalInsets
90
- import vn.momo.kits.layout.HEADER_BANNER_WIDTH
91
- import vn.momo.kits.layout.HEADER_BUTTON_SIZE
92
- import vn.momo.kits.layout.HEADER_TITLE_GAP
88
+ import vn.momo.kits.layout.DuoMetrics
93
89
  import vn.momo.kits.layout.getScreenLayout
94
- import vn.momo.kits.layout.rememberHeaderLayout
95
90
  import kotlin.time.Clock
96
91
  import kotlin.time.Duration.Companion.milliseconds
97
92
  import kotlin.time.ExperimentalTime
@@ -211,9 +206,7 @@ internal fun StackScreen(
211
206
 
212
207
  val canPop = navigator.canPop()
213
208
 
214
- val hasCustomBackHandling = !SwipeBackConfig.enabled ||
215
- OverplayComponentRegistry.isOverplayShowing() ||
216
- !canPop
209
+ val hasCustomBackHandling = !SwipeBackConfig.enabled || OverplayComponentRegistry.isOverplayShowing() || !canPop
217
210
 
218
211
  BackHandler(hasCustomBackHandling) { navigator.onBackSafe() }
219
212
 
@@ -376,25 +369,12 @@ internal fun ScreenContent(content: @Composable () -> Unit, insetContent: Boolea
376
369
 
377
370
  if (options.headerType is HeaderType.Animated) {
378
371
  val animatedHeader = options.headerType
379
- val isBannerCentered = rememberHeaderLayout(options.contentLayout).isBannerCentered
380
372
  Box {
381
- // wide windows and the iPhone Duo inner display keep the phone banner size, centered over
382
- // a fill fading down from bannerBackgroundColor
383
- val bannerWidth = if (isBannerCentered) Modifier.width(HEADER_BANNER_WIDTH) else Modifier.fillMaxWidth()
384
373
  val bannerModifier = animatedHeader.height
385
- ?.let { bannerWidth.height(it) }
386
- ?: bannerWidth.aspectRatio(animatedHeader.aspectRatio.value)
387
- Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.TopCenter) {
388
- val fill = animatedHeader.bannerBackgroundColor
389
- if (isBannerCentered && fill != null) {
390
- Box(
391
- Modifier.matchParentSize()
392
- .background(Brush.verticalGradient(listOf(fill, fill.copy(alpha = 0f))))
393
- )
394
- }
395
- Box(bannerModifier) {
396
- animatedHeader.composable.invoke(scrollState.value)
397
- }
374
+ ?.let { Modifier.fillMaxWidth().height(it) }
375
+ ?: Modifier.fillMaxWidth().aspectRatio(animatedHeader.aspectRatio.value)
376
+ Box(bannerModifier) {
377
+ animatedHeader.composable.invoke(scrollState.value)
398
378
  }
399
379
  Box(
400
380
  Modifier
@@ -527,18 +507,17 @@ internal fun SearchAnimated(
527
507
  // collapsed, the search is centered in the bar row
528
508
  val minTopPadding = screenLayout.headerStatusBarHeight + (screenLayout.headerBarHeight - HEADER_HEIGHT.dp) / 2
529
509
  val maxTopPadding = screenLayout.headerHeight
530
- // collapsed on the iPhone Duo status bar row, the search stays between its clusters
510
+ // collapsed on the iPhone Duo status bar row, the search stays between its clusters (48pt back there)
531
511
  val clearance = screenLayout.statusBarClearance
532
- // stretch screens on wide windows keep the search in the header's centered frame
533
- val sidePadding = rememberHeaderLayout(options.contentLayout).frameInset
534
- val minStartPadding = sidePadding
512
+ val backWidth = if (clearance != null && !useSideBar) DuoMetrics.controlSize else 28.dp
513
+ val minStartPadding = Spacing.M
535
514
  val maxStartPadding = (clearance?.left ?: 0.dp) +
536
- if (options.hiddenBack || useSideBar) sidePadding else HEADER_BUTTON_SIZE + sidePadding + HEADER_TITLE_GAP
537
- val minEndPadding = sidePadding
515
+ if (options.hiddenBack || useSideBar) Spacing.M else backWidth + Spacing.M + Spacing.S
516
+ val minEndPadding = Spacing.M
538
517
  val maxEndPadding = (clearance?.right ?: 0.dp) + when {
539
- options.headerRight is HeaderRight.None -> sidePadding
540
- useSideBar && options.headerRight is HeaderRight.Toolkit -> sidePadding
541
- else -> headerRightWidthDp + sidePadding + Spacing.M
518
+ options.headerRight is HeaderRight.None -> Spacing.M
519
+ useSideBar && options.headerRight is HeaderRight.Toolkit -> Spacing.M
520
+ else -> headerRightWidthDp + Spacing.M * 2
542
521
  }
543
522
 
544
523
  val targetColor = lerp(
@@ -599,8 +578,7 @@ internal fun SearchAnimated(
599
578
  onPressButtonText = {
600
579
  navigator.pop()
601
580
  }
602
- ),
603
- size = InputSearchSize.Header,
581
+ )
604
582
  )
605
583
  }
606
584
  }
@@ -723,15 +701,20 @@ private fun rememberQuickReturnHide(
723
701
  return hide
724
702
  }
725
703
 
726
- internal fun NavigationOptions.usesDuoQuickReturnHeader(layout: ScreenLayout): Boolean =
727
- usesDuoGlassHeader(layout) || (layout.sideBar != null && headerType is HeaderType.Animated &&
728
- scrollData.scrollable && scrollData.scrollState is ScrollState)
704
+ internal fun NavigationOptions.usesDuoQuickReturnHeader(layout: ScreenLayout): Boolean {
705
+ if (usesDuoGlassHeader(layout)) return true
706
+ return layout.sideBar != null && headerType is HeaderType.Animated && scrollsWithScrollState()
707
+ }
729
708
 
730
709
  // iPhone Duo side bar: content scrolls under a glass header instead of starting below it (RN Screen).
731
- internal fun NavigationOptions.usesDuoGlassHeader(layout: ScreenLayout): Boolean =
732
- layout.sideBar != null && headerType is HeaderType.DefaultOrExtended &&
733
- getInputSearchType(this) == InputSearchType.None &&
734
- scrollData.scrollable && scrollData.scrollState is ScrollState
710
+ internal fun NavigationOptions.usesDuoGlassHeader(layout: ScreenLayout): Boolean {
711
+ if (layout.sideBar == null || headerType !is HeaderType.DefaultOrExtended) return false
712
+ return getInputSearchType(this) == InputSearchType.None && scrollsWithScrollState()
713
+ }
714
+
715
+ private fun NavigationOptions.scrollsWithScrollState(): Boolean {
716
+ return scrollData.scrollable && scrollData.scrollState is ScrollState
717
+ }
735
718
 
736
719
  internal fun getInputSearchType(options: NavigationOptions): InputSearchType {
737
720
  return when (val headerType = options.headerType) {
@@ -52,19 +52,23 @@ object SwipeBackConfig {
52
52
  // decouple the card from the finger.
53
53
  private val stackSpec = tween<IntOffset>(STACK_TRANSITION_DURATION, easing = LinearEasing)
54
54
 
55
- internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackEnter(): EnterTransition =
56
- slideInHorizontally(stackSpec) { it }
55
+ internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackEnter(): EnterTransition {
56
+ return slideInHorizontally(stackSpec) { it }
57
+ }
57
58
 
58
- internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackExit(): ExitTransition =
59
- if (targetState.destination.hasRoute<DynamicDialogRoute>()) ExitTransition.None
60
- else slideOutHorizontally(stackSpec) { -(it * PARALLAX_RATIO).roundToInt() }
59
+ internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackExit(): ExitTransition {
60
+ if (targetState.destination.hasRoute<DynamicDialogRoute>()) return ExitTransition.None
61
+ return slideOutHorizontally(stackSpec) { -(it * PARALLAX_RATIO).roundToInt() }
62
+ }
61
63
 
62
- internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopEnter(): EnterTransition =
63
- if (initialState.destination.hasRoute<DynamicDialogRoute>()) EnterTransition.None
64
- else slideInHorizontally(stackSpec) { -(it * PARALLAX_RATIO).roundToInt() }
64
+ internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopEnter(): EnterTransition {
65
+ if (initialState.destination.hasRoute<DynamicDialogRoute>()) return EnterTransition.None
66
+ return slideInHorizontally(stackSpec) { -(it * PARALLAX_RATIO).roundToInt() }
67
+ }
65
68
 
66
- internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopExit(): ExitTransition =
67
- slideOutHorizontally(stackSpec) { it }
69
+ internal fun AnimatedContentTransitionScope<NavBackStackEntry>.stackPopExit(): ExitTransition {
70
+ return slideOutHorizontally(stackSpec) { it }
71
+ }
68
72
 
69
73
  /**
70
74
  * Which composed screen is the top card. Ids are monotonic and NavHost keeps both entries composed
@@ -80,9 +80,7 @@ internal fun BottomTabBar(
80
80
  }
81
81
  }
82
82
 
83
- // Horizontal navigation bar: floating container, items split evenly; Special type puts the center
84
- // action in a notch in the middle, rising ctaLift above the container. One active indicator slides
85
- // behind the selected item.
83
+ // Floating bar, items split evenly; Special type puts the center action in a notch, rising ctaLift above the bar.
86
84
  @Composable
87
85
  internal fun HorizontalTabBar(
88
86
  items: List<BottomTabItem>,
@@ -76,18 +76,20 @@ internal class InsetShape(private val shape: Shape, private val inset: Dp) : Sha
76
76
  }
77
77
 
78
78
  // Shadow with a negative spread, cast from the shrunk shape.
79
- internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier =
80
- if (shadow.spread < 0.dp) dropShadow(
81
- InsetShape(shape, -shadow.spread),
82
- Shadow(radius = shadow.radius, color = shadow.color, offset = shadow.offset, alpha = shadow.alpha),
83
- )
84
- else dropShadow(shape, shadow)
79
+ internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier {
80
+ if (shadow.spread < 0.dp) {
81
+ return dropShadow(
82
+ InsetShape(shape, -shadow.spread),
83
+ Shadow(radius = shadow.radius, color = shadow.color, offset = shadow.offset, alpha = shadow.alpha),
84
+ )
85
+ }
86
+ return dropShadow(shape, shadow)
87
+ }
85
88
 
86
- // Navigation bar container: translucent glass fill with the floating shadow following the shape (Figma
87
- // Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16; .Nav/Background: white 86%, Blur=On).
89
+ // Floating shadow follows the shape (Figma Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16).
88
90
  @Composable
89
- internal fun Modifier.tabBarContainer(shape: Shape): Modifier =
90
- dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
91
+ internal fun Modifier.tabBarContainer(shape: Shape): Modifier {
92
+ return dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
91
93
  .spreadShadow(
92
94
  shape,
93
95
  Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
@@ -98,3 +100,4 @@ internal fun Modifier.tabBarContainer(shape: Shape): Modifier =
98
100
  )
99
101
  // Figma .Nav/Background: 1px light-gray hairline defining the pill edge
100
102
  .border(1.dp, AppTheme.current.colors.border.default, shape)
103
+ }
@@ -40,11 +40,7 @@ private val DEFAULT_TOOLBAR_HEIGHT = DuoMetrics.controlSize + Spacing.M + DuoMet
40
40
  // Back, then the single button the toolbar folds into
41
41
  private val COMPRESSED_TOOLBAR_HEIGHT = DuoMetrics.controlSize * 2 + Spacing.M
42
42
 
43
- // Port of RN DuoBarCompression (HIG, Designing for iPhone Duo: Vertical controls):
44
- // - both fit: both stay whole
45
- // - one fits whole beside the other compressed: one is compressed, tapping it swaps them
46
- // - otherwise both rest compressed; tapping one opens it for a moment (the rail closes
47
- // again once a tab is picked)
43
+ // Port of RN DuoBarCompression (HIG Vertical controls): both whole, else one compressed (tap swaps), else both.
48
44
  @Composable
49
45
  internal fun rememberDuoBarCompression(
50
46
  behavior: DuoBarCompressionBehavior,
@@ -55,9 +55,11 @@ internal fun duoRailHeight(itemCount: Int, hasQr: Boolean, compressed: Boolean =
55
55
 
56
56
  // Space tab content leaves under the floating horizontal bar (phone and unfolded Duo), the rising center
57
57
  // action included; 0 when the Duo rail sits in the side strip.
58
- internal fun duoFloatingTabBarInset(layout: ScreenLayout, hasCenterAction: Boolean = false): Dp =
59
- if (layout.isIPhoneDuo && layout.sideBar != null) 0.dp
60
- else TabBarMetrics.height + tabBarBottomGap(layout.insetBottom) + if (hasCenterAction) TabBarMetrics.ctaLift else 0.dp
58
+ internal fun duoFloatingTabBarInset(layout: ScreenLayout, hasCenterAction: Boolean = false): Dp {
59
+ if (layout.isIPhoneDuo && layout.sideBar != null) return 0.dp
60
+ val ctaLift = if (hasCenterAction) TabBarMetrics.ctaLift else 0.dp
61
+ return TabBarMetrics.height + tabBarBottomGap(layout.insetBottom) + ctaLift
62
+ }
61
63
 
62
64
  // Whether the tabs' bar shows the center action, whose button rises ctaLift above the container.
63
65
  internal val LocalTabBarHasCenterAction = compositionLocalOf { false }
@@ -93,9 +95,8 @@ internal fun BoxScope.DuoTabBar(
93
95
  }
94
96
  }
95
97
 
96
- // Vertical bar anchored to the bottom of the side bar, center action below it. When the side bar is
97
- // short it can shrink to one button showing the current tab (HIG "Tab bar compressed"); tapping it
98
- // expands the rail and compresses the toolbar.
98
+ // Rail at the bottom of the side bar, center action below. A short side bar shrinks it to the current
99
+ // tab's button (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
99
100
  @Composable
100
101
  private fun BoxScope.DuoRailTabBar(
101
102
  layout: ScreenLayout,
@@ -11,9 +11,7 @@ import vn.momo.kits.const.Radius
11
11
  import vn.momo.kits.const.Spacing
12
12
  import vn.momo.kits.platform.getPlatformName
13
13
 
14
- // Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from RN BottomTab/metrics.ts.
15
- // Horizontal: floating container with items split evenly, center action in a notch.
16
- // Vertical: iPhone Duo rail, center action under the container.
14
+ // Mirrored from RN BottomTab/metrics.ts (Figma "Specs Navigation"); `rail*` is the iPhone Duo vertical bar.
17
15
  internal object TabBarMetrics {
18
16
  val height = 60.dp
19
17
  val margin = Spacing.S
@@ -22,8 +20,7 @@ internal object TabBarMetrics {
22
20
  val itemGap = 1.dp
23
21
  // gap between the icon slot and the label inside a tab (Figma: none)
24
22
  val itemIconLabelGap = 0.dp
25
- // .Nav/Background: Compose has no backdrop blur, so use the Figma Blur=Off spec (opacity 95%, no blur)
26
- // — nearly solid, matching the frosted sample — plus the 1px border below; surface keeps dark-mode support.
23
+ // Compose has no backdrop blur: Figma .Nav/Background Blur=Off spec (95%, no blur)
27
24
  val backgroundOpacity = 0.95f
28
25
  // white 60% hairline around the center action button (Figma Icon Button border)
29
26
  val ctaBorderOpacity = 0.6f
@@ -92,9 +89,8 @@ internal fun indicatorInnerShadows(primary: Color) = listOf(
92
89
  Shadow(radius = 2.dp, color = primary, alpha = 0.12f, offset = DpOffset(0.dp, 1.dp)),
93
90
  )
94
91
 
95
- // Notch dipped into the container top edge under the center action (Figma "Backgroud" path): starts
96
- // NOTCH_HALF_WIDTH left of the center, then cubic segments of control1, control2, end, each point as
97
- // (dx from the center, dy below the top edge) in dp.
92
+ // Center-action notch (Figma "Backgroud" path) from NOTCH_HALF_WIDTH left of center: cubic segments of
93
+ // (control1, control2, end), each point (dx from center, dy below the top edge) in dp.
98
94
  internal const val NOTCH_HALF_WIDTH = 50.758f
99
95
  internal val NOTCH_CURVES = listOf(
100
96
  listOf(-39.749f to 0f, -31.231f to 9.765f, -24.563f to 18.526f),
@@ -123,10 +119,15 @@ internal fun horizontalBarWidth(
123
119
  }
124
120
 
125
121
  // Gap under the container: the home indicator / gesture bar area.
126
- internal fun tabBarBottomGap(navigationBar: Dp): Dp =
127
- (if (getPlatformName() == "iOS") minOf(navigationBar, TabBarMetrics.systemIndicatorHeight) else navigationBar)
128
- .coerceAtLeast(Spacing.S)
122
+ internal fun tabBarBottomGap(navigationBar: Dp): Dp {
123
+ var gap = navigationBar
124
+ if (getPlatformName() == "iOS") {
125
+ gap = minOf(navigationBar, TabBarMetrics.systemIndicatorHeight)
126
+ }
127
+ return gap.coerceAtLeast(Spacing.S)
128
+ }
129
129
 
130
130
  // The center action needs a tab on each side: Special type takes 2 or 4 tabs.
131
- internal fun hasCenterAction(floatingButton: BottomTabFloatingButton?, tabCount: Int): Boolean =
132
- floatingButton != null && tabCount % 2 == 0
131
+ internal fun hasCenterAction(floatingButton: BottomTabFloatingButton?, tabCount: Int): Boolean {
132
+ return floatingButton != null && tabCount % 2 == 0
133
+ }