@momo-kits/native-kits 0.169.14-beta.2-debug → 0.169.14-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.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.169.14-beta.2-debug"
43
+ version = "0.169.14-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -113,7 +113,6 @@ repositories {
113
113
  }
114
114
  }
115
115
  mavenCentral()
116
- maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
117
116
  maven {
118
117
  url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
119
118
  credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.169.14-beta.2-debug'
3
+ spec.version = '0.169.14-debug'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -77,8 +77,6 @@ import vn.momo.kits.navigation.bottomtab.duoFloatingTabBarInset
77
77
  import vn.momo.kits.navigation.component.HeaderType
78
78
  import vn.momo.kits.navigation.component.InputSearchType
79
79
  import vn.momo.kits.navigation.bottomtab.LocalBottomTabFocused
80
- import vn.momo.kits.navigation.bottomtab.LocalBottomTabLegacy
81
- import vn.momo.kits.navigation.bottomtab.LEGACY_BOTTOM_TAB_BAR_HEIGHT
82
80
  import vn.momo.kits.platform.BackHandler
83
81
  import vn.momo.kits.platform.supportsImePadding
84
82
  import vn.momo.kits.navigation.tracking.ScreenTracker
@@ -102,17 +100,13 @@ import kotlin.time.ExperimentalTime
102
100
  fun floatingTabBarContentPadding(): PaddingValues {
103
101
  val navigation = LocalNavigation.current
104
102
  LaunchedEffect(navigation) { navigation.bottomTabEdgeToEdge = true }
105
- val reserve = navigation.bottomTabIndex != -1 && navigation.bottomTabEdgeToEdge && !isLegacyPhoneTabBar()
103
+ val reserve = navigation.bottomTabIndex != -1 && navigation.bottomTabEdgeToEdge
106
104
  return PaddingValues(bottom = if (reserve) bottomTabChildInset() else 0.dp)
107
105
  }
108
106
 
109
107
  internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
110
108
  internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
111
109
 
112
- // BottomTab(useLegacy = true) off iPhone Duo: the docked bar takes layout space, so no edge-to-edge
113
- @Composable
114
- private fun isLegacyPhoneTabBar(): Boolean = LocalBottomTabLegacy.current && !getScreenLayout().isIPhoneDuo
115
-
116
110
  // Space a tab's content leaves for the tab bar and home indicator: the horizontal bar floats over the
117
111
  // content (phone and unfolded Duo); the Duo rail lives in the side strip, so only the home indicator.
118
112
  @Composable
@@ -122,8 +116,6 @@ private fun bottomTabChildInset(): Dp {
122
116
  val layout = getScreenLayout()
123
117
  return when {
124
118
  layout.isIPhoneDuo && layout.sideBar != null -> (navigationBar - keyboard).coerceAtLeast(0.dp)
125
- isLegacyPhoneTabBar() -> (LEGACY_BOTTOM_TAB_BAR_HEIGHT.dp + Spacing.S - keyboard).coerceAtLeast(0.dp) +
126
- (navigationBar - keyboard).coerceAtLeast(0.dp)
127
119
  else -> (duoFloatingTabBarInset(layout, LocalTabBarHasCenterAction.current) - keyboard).coerceAtLeast(0.dp)
128
120
  }
129
121
  }
@@ -357,7 +349,7 @@ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTa
357
349
  bottom = when {
358
350
  options.hasFooter() || isBottomTabRoot -> 0.dp
359
351
  // 0 when the tab pads itself via floatingTabBarContentPadding(), else the kit reserves the bar space
360
- isBottomTabChild -> if (LocalNavigation.current.bottomTabEdgeToEdge && !isLegacyPhoneTabBar()) 0.dp else bottomTabChildInset()
352
+ isBottomTabChild -> if (LocalNavigation.current.bottomTabEdgeToEdge) 0.dp else bottomTabChildInset()
361
353
  !options.scrollData.scrollable && options.scrollData.scrollState == null -> 0.dp
362
354
  else -> navigationBar
363
355
  }
@@ -50,9 +50,6 @@ private fun tabPosition(index: Int, selected: Int) = (index - selected).coerceIn
50
50
 
51
51
  internal val LocalBottomTabFocused = staticCompositionLocalOf { true }
52
52
 
53
- // True under a BottomTab(useLegacy = true): tab content reserves the old docked bar instead of the floating one
54
- internal val LocalBottomTabLegacy = staticCompositionLocalOf { false }
55
-
56
53
  private val Hidden = Modifier.layout { measurable, constraints ->
57
54
  val placeable = measurable.measure(constraints)
58
55
  layout(placeable.width, placeable.height) {}
@@ -70,10 +67,6 @@ internal fun getBottomTabOption(index: Int): NavigationOptions? {
70
67
  } else null
71
68
  }
72
69
 
73
- /**
74
- * Tab container: one [StackScreen] per tab plus the tab bar (floating pill on phones, rail / floating
75
- * bar on iPhone Duo). [useLegacy] renders the pre-redesign docked phone bar instead (DS-984 not rolled out yet).
76
- */
77
70
  @Composable
78
71
  fun BottomTab(
79
72
  items: List<BottomTabItem>,
@@ -84,9 +77,6 @@ fun BottomTab(
84
77
  initialRouteName: String? = null,
85
78
  onTabPress: ((index: Int, switchTab: () -> Unit) -> Unit)? = null,
86
79
  backToInitialTab: Boolean = true,
87
- // phone only: the pre-redesign docked bar (64dp, top indicator, curved center button) and its content
88
- // inset; floatingTabBarContentPadding() is then 0 and content keeps reserving the bar. Duo is unchanged.
89
- useLegacy: Boolean = false,
90
80
  ) {
91
81
  val navigation = LocalNavigation.current
92
82
  val navigator = LocalNavigator.current
@@ -170,7 +160,6 @@ fun BottomTab(
170
160
  LocalDuoRailReserve provides railReserve,
171
161
  LocalDuoBarCompression provides compression,
172
162
  LocalTabBarHasCenterAction provides hasCenterAction(floatingButton, items.size),
173
- LocalBottomTabLegacy provides useLegacy,
174
163
  ) {
175
164
  loadedTabs.forEach { index ->
176
165
  val item = items.getOrNull(index) ?: return@forEach
@@ -209,14 +198,7 @@ fun BottomTab(
209
198
  BackHandler(enabled = !onFirstTab) {
210
199
  if (backToInitialTab) backToFirstTab() else navigator.pop()
211
200
  }
212
- if (useLegacy && !layout.isIPhoneDuo) {
213
- LegacyBottomTabBarWithFiller(
214
- items = items,
215
- floatingButton = floatingButton,
216
- selectedIndex = selectedIndex,
217
- onTabSelected = onTabSelected,
218
- )
219
- } else ScaleSizeScope(TabBarMetrics.LABEL_MAX_SCALE) {
201
+ ScaleSizeScope(TabBarMetrics.LABEL_MAX_SCALE) {
220
202
  if (layout.isIPhoneDuo) {
221
203
  DuoTabBar(
222
204
  layout = layout,
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.169.14-beta.2
21
+ version=0.169.14
22
22
 
23
23
  repo=GitLab
24
24
  url=https://artifacts.mservice.com.vn/repository/maven-momo-app/
@@ -10,7 +10,6 @@ public struct BottomTab: View {
10
10
  private let compressionBehavior: DuoBarCompressionBehavior
11
11
  private let onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)?
12
12
  private let backToInitialTab: Bool
13
- private let useLegacy: Bool
14
13
 
15
14
  @EnvironmentObject private var navigator: Navigator
16
15
  /// The screen hosting the tabs (Compose's `LocalNavigation` in BottomTab).
@@ -27,22 +26,19 @@ public struct BottomTab: View {
27
26
 
28
27
  /// `compressionBehavior`: iPhone Duo bar that starts compressed when the side bar can't hold both (a tap swaps).
29
28
  /// `onTabPress` gets the switch to run, e.g. after a login gate. `backToInitialTab`: back goes to it first.
30
- /// `useLegacy`: the pre-redesign phone bar (full width, content kept above it; edge to edge ignored).
31
29
  public init(
32
30
  items: [BottomTabItem],
33
31
  floatingButton: BottomTabFloatingButton? = nil,
34
32
  compressionBehavior: DuoBarCompressionBehavior = .toolbar,
35
33
  initialRouteName: String? = nil,
36
34
  onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)? = nil,
37
- backToInitialTab: Bool = true,
38
- useLegacy: Bool = false
35
+ backToInitialTab: Bool = true
39
36
  ) {
40
37
  self.items = items
41
38
  self.floatingButton = floatingButton
42
39
  self.compressionBehavior = compressionBehavior
43
40
  self.onTabPress = onTabPress
44
41
  self.backToInitialTab = backToInitialTab
45
- self.useLegacy = useLegacy
46
42
  let start = items.firstIndex { $0.name == initialRouteName } ?? 0
47
43
  _startIndex = State(initialValue: start)
48
44
  _selectedIndex = State(initialValue: start)
@@ -51,13 +47,7 @@ public struct BottomTab: View {
51
47
  private var bottomInset: CGFloat { safeAreaBottomInset() }
52
48
  // the bars float over the content (tab screens keep clear of them through duoTabBarInsets) or sit
53
49
  // in the side strip, so only the home indicator is kept clear
54
- // the legacy bar sits under the content, which keeps clear of all of it
55
- private var reservedBottom: CGFloat {
56
- isLegacyBar ? LEGACY_BOTTOM_TAB_BAR_HEIGHT + bottomInset + Spacing.S : layout.insets.bottom
57
- }
58
-
59
- /// Legacy covers the phone bar only; the iPhone Duo keeps its rail / floating bar.
60
- private var isLegacyBar: Bool { useLegacy && !layout.isIPhoneDuo }
50
+ private var reservedBottom: CGFloat { layout.insets.bottom }
61
51
 
62
52
  private var compression: DuoBarCompression {
63
53
  DuoBarCompression.resolve(
@@ -78,8 +68,7 @@ public struct BottomTab: View {
78
68
  }
79
69
 
80
70
  private func duoInsets(_ compression: DuoBarCompression) -> DuoTabBarInsets {
81
- if isLegacyBar { return DuoTabBarInsets(isLegacyBar: true) }
82
- return layout.duoTabBarInsets(
71
+ layout.duoTabBarInsets(
83
72
  itemCount: items.count,
84
73
  hasFloatingButton: floatingButton != nil,
85
74
  tabBarCompressed: compression.tabBarCompressed
@@ -105,14 +94,6 @@ public struct BottomTab: View {
105
94
  onTabSelected: selectTab,
106
95
  compression: compression
107
96
  )
108
- } else if isLegacyBar {
109
- LegacyBottomTabBar(
110
- items: items,
111
- floatingButton: floatingButton,
112
- selectedIndex: selectedIndex,
113
- onTabSelected: selectTab,
114
- bottomInset: bottomInset
115
- )
116
97
  } else {
117
98
  BottomTabBar(
118
99
  items: items,
@@ -11,8 +11,6 @@ struct DuoTabBarInsets: Equatable {
11
11
  var overlay: CGFloat = 0
12
12
  /// Rail sits at the bottom of the side strip: the header side bar stays this far above the window bottom.
13
13
  var sideBarReserve: CGFloat = 0
14
- /// `BottomTab(useLegacy: true)`: the bar sits under the content, so a tab can't run edge to edge behind it.
15
- var isLegacyBar = false
16
14
  }
17
15
 
18
16
  private struct DuoTabBarInsetsKey: EnvironmentKey {
@@ -167,8 +167,7 @@ public struct StackScreen<Content: View>: View {
167
167
  /// (`floatingTabBarEdgeToEdge()`), when it also covers the home indicator that BottomTab keeps clear of
168
168
  /// (a negative inset extends the content past the tab's frame).
169
169
  private var contentBottomInset: CGFloat {
170
- guard let navigation, navigation.bottomTabIndex != -1, navigation.bottomTabEdgeToEdge,
171
- !duoTabBarInsets.isLegacyBar else {
170
+ guard let navigation, navigation.bottomTabIndex != -1, navigation.bottomTabEdgeToEdge else {
172
171
  return duoTabBarInsets.overlay
173
172
  }
174
173
  return -layout.insets.bottom
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.169.14-beta.2'
3
+ s.version = '0.169.14'
4
4
  s.summary = 'MoMoUIKits for iOS'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKitsDemo'
3
- s.version = '0.169.14-beta.2'
3
+ s.version = '0.169.14'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -38,7 +38,6 @@ private struct DemoConfig: Hashable {
38
38
  var ctaLottie = false
39
39
  var initialRouteName = "Momo"
40
40
  var compressionBehavior: DuoBarCompressionBehavior = .toolbar
41
- var useLegacy = false
42
41
  var backToInitialTab = true
43
42
  // a sticky footer in the tab's content body, to check it clears the floating bar
44
43
  var footer = false
@@ -135,8 +134,7 @@ struct BottomTabDemoContent: View {
135
134
  focused = tabs[index].name
136
135
  switchTab()
137
136
  },
138
- backToInitialTab: config.backToInitialTab,
139
- useLegacy: config.useLegacy
137
+ backToInitialTab: config.backToInitialTab
140
138
  )
141
139
  .id(config)
142
140
  .onAppear { ctaLottieLoader.load() }
@@ -224,8 +222,6 @@ private struct TabContent: View {
224
222
  config.compressionBehavior = .tabBar
225
223
  },
226
224
  ])
227
- Options(title: "useLegacy", hint: "Thanh tab cũ (trước redesign), iPhone thường",
228
- options: yesNo(config.useLegacy) { config.useLegacy = $0 })
229
225
  Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
230
226
  options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
231
227
  Options(title: "footer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.169.14-beta.2-debug",
3
+ "version": "0.169.14-debug",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "publish:local": "bash publish.sh local"
@@ -39,7 +39,6 @@ dependencyResolutionManagement {
39
39
  }
40
40
  }
41
41
  mavenCentral()
42
- maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
43
42
  maven {
44
43
  url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
45
44
  credentials {
@@ -1,260 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.animation.core.Animatable
4
- import androidx.compose.animation.core.animateFloatAsState
5
- import androidx.compose.animation.core.tween
6
- import androidx.compose.foundation.background
7
- import androidx.compose.foundation.border
8
- import androidx.compose.foundation.combinedClickable
9
- import androidx.compose.foundation.interaction.MutableInteractionSource
10
- import androidx.compose.foundation.interaction.collectIsPressedAsState
11
- import androidx.compose.foundation.layout.*
12
- import androidx.compose.foundation.shape.CircleShape
13
- import androidx.compose.foundation.shape.RoundedCornerShape
14
- import androidx.compose.runtime.Composable
15
- import androidx.compose.runtime.LaunchedEffect
16
- import androidx.compose.runtime.getValue
17
- import androidx.compose.runtime.mutableIntStateOf
18
- import androidx.compose.runtime.remember
19
- import androidx.compose.runtime.saveable.rememberSaveable
20
- import androidx.compose.runtime.setValue
21
- import androidx.compose.ui.Alignment
22
- import androidx.compose.ui.Modifier
23
- import androidx.compose.ui.graphics.Brush
24
- import androidx.compose.ui.graphics.Color
25
- import androidx.compose.ui.graphics.graphicsLayer
26
- import androidx.compose.ui.semantics.Role
27
- import androidx.compose.ui.text.style.TextAlign
28
- import androidx.compose.ui.text.style.TextOverflow
29
- import androidx.compose.ui.unit.Dp
30
- import androidx.compose.ui.unit.IntOffset
31
- import androidx.compose.ui.unit.dp
32
- import vn.momo.kits.application.IsShowBaseLineDebug
33
- import vn.momo.kits.components.*
34
- import vn.momo.kits.const.*
35
- import vn.momo.kits.modifier.conditional
36
- import vn.momo.kits.modifier.activeOpacityClickable
37
- import vn.momo.kits.layout.getScreenLayout
38
- import vn.momo.kits.utils.horizontalSafeAreaPadding
39
-
40
- // Height of the pre-redesign docked bar (DS-984 made it a floating pill), used by useLegacy.
41
- internal const val LEGACY_BOTTOM_TAB_BAR_HEIGHT = 64
42
-
43
- private val legacyTabTimingSpec = tween<Float>(durationMillis = 200, easing = inOutQuad)
44
-
45
- @Composable
46
- internal fun LegacyBottomTabBar(
47
- items: List<BottomTabItem>,
48
- floatingButton: BottomTabFloatingButton? = null,
49
- selectedIndex: Int,
50
- onTabSelected: (Int) -> Unit,
51
- onTabLongPress: ((Int) -> Unit)? = null,
52
- ) {
53
-
54
- val layout = getScreenLayout()
55
- val mid = items.size / 2
56
-
57
- val floating = floatingButton?.takeIf { items.size % 2 == 0 }
58
- val slotWidth = layout.contentWidth / (items.size + if (floating != null) 1 else 0)
59
- fun slotOf(index: Int) = if (floating != null && index >= mid) index + 1 else index
60
-
61
- var indicatorSlot by rememberSaveable { mutableIntStateOf(0) }
62
- val indicatorX = remember { Animatable(indicatorSlot.toFloat()) }
63
- LaunchedEffect(selectedIndex) {
64
- val target = slotOf(selectedIndex)
65
- indicatorSlot = target
66
- indicatorX.animateTo(target.toFloat(), legacyTabTimingSpec)
67
- }
68
-
69
- Box(
70
- contentAlignment = Alignment.BottomCenter
71
- ) {
72
- Row(
73
- modifier = Modifier
74
- .fillMaxWidth()
75
- .height(LEGACY_BOTTOM_TAB_BAR_HEIGHT.dp)
76
- .background(AppTheme.current.colors.background.surface)
77
- .conditional(IsShowBaseLineDebug) {
78
- border(1.dp, Colors.blue_03)
79
- }
80
- .horizontalSafeAreaPadding(),
81
- horizontalArrangement = Arrangement.SpaceAround,
82
- ) {
83
- if (floating == null) {
84
- LegacyRenderTabBarItem(items, 0, items.size, selectedIndex, onTabSelected, onTabLongPress)
85
- } else {
86
- LegacyRenderTabBarItem(items, 0, mid, selectedIndex, onTabSelected, onTabLongPress)
87
- Spacer(modifier = Modifier.width(slotWidth))
88
- LegacyRenderTabBarItem(items, mid, items.size, selectedIndex, onTabSelected, onTabLongPress)
89
- }
90
- }
91
-
92
- Box(modifier = Modifier
93
- .offset { IntOffset((layout.insetLeft + slotWidth * (indicatorX.value + 0.5f) - layout.width / 2).roundToPx(), (-LEGACY_BOTTOM_TAB_BAR_HEIGHT + 2).dp.roundToPx()) }
94
- .height(2.dp)
95
- .width(44.dp)
96
- .background(
97
- color = AppTheme.current.colors.primary ,
98
- shape = RoundedCornerShape(bottomStart = 2.dp, bottomEnd = 2.dp)
99
- )
100
- )
101
-
102
- Box(modifier = Modifier
103
- .fillMaxWidth()
104
- .height(6.dp)
105
- .offset(x = 0.dp, y = (-LEGACY_BOTTOM_TAB_BAR_HEIGHT).dp)
106
- .background(
107
- brush = Brush.verticalGradient(
108
- colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
109
- )
110
- )
111
- )
112
- floating?.let {
113
- Box(Modifier.offset(x = (layout.insetLeft - layout.insetRight) / 2)) {
114
- LegacyFloatingButton(it, slotWidth)
115
- }
116
- }
117
- }
118
- }
119
-
120
- @Composable
121
- internal fun RowScope.LegacyRenderTabBarItem(
122
- items: List<BottomTabItem>,
123
- fromIndex: Int,
124
- toIndex: Int,
125
- selectedIndex: Int,
126
- onTabSelected: (Int) -> Unit,
127
- onTabLongPress: ((Int) -> Unit)? = null,
128
- ){
129
- for (index in fromIndex until toIndex) {
130
- Box(modifier = Modifier.weight(1f)) {
131
- LegacyTabBarItem(
132
- item = items[index],
133
- selected = index == selectedIndex,
134
- onClick = { onTabSelected(index) },
135
- onLongClick = onTabLongPress?.let { { it(index) } },
136
- )
137
- }
138
- }
139
- }
140
-
141
- @Composable
142
- internal fun LegacyTabBarItem(item: BottomTabItem, selected: Boolean, onClick: () -> Unit, onLongClick: (() -> Unit)? = null) {
143
- // RN parity: "0" hides the badge, "" renders a dot.
144
- val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
145
- val showDot = badgeLabel?.isEmpty() ?: item.showDot
146
- val interactionSource = remember { MutableInteractionSource() }
147
- val pressed by interactionSource.collectIsPressedAsState()
148
- val alpha by animateFloatAsState(if (pressed) 0.2f else 1f, label = "TabBarItemOpacity")
149
-
150
- BoxWithConstraints(modifier = Modifier
151
- .fillMaxSize()
152
- .padding(horizontal = Spacing.XXS)
153
- .conditional(IsShowBaseLineDebug) {
154
- border(1.dp, Colors.blue_03)
155
- }
156
- .graphicsLayer { this.alpha = alpha }
157
- .combinedClickable(
158
- interactionSource = interactionSource,
159
- indication = null,
160
- role = Role.Tab,
161
- onLongClick = onLongClick,
162
- onClick = onClick,
163
- ),
164
- contentAlignment = Alignment.BottomStart
165
- ){
166
- // from the icon's center to the cell's end edge
167
- val badgeMaxWidth = (maxWidth / 2 - Spacing.XXS).coerceAtLeast(0.dp)
168
- Column(
169
- modifier = Modifier
170
- .fillMaxSize()
171
- .padding(horizontal = Spacing.S, vertical = Spacing.S),
172
- horizontalAlignment = Alignment.CenterHorizontally,
173
- verticalArrangement = Arrangement.Center
174
- ) {
175
- Box(modifier = Modifier.padding(Spacing.XS)) {
176
- Icon(
177
- source = item.icon,
178
- size = 28.dp,
179
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint)
180
- if (showDot) {
181
- val dotAnchor = Modifier.matchParentSize().wrapContentSize(Alignment.TopEnd, unbounded = true)
182
- BadgeDot(size = DotSize.Small, modifier = dotAnchor.offset(x = 4.dp, y = (-4).dp))
183
- } else if (!badgeLabel.isNullOrEmpty()) {
184
- // starts at the icon's center and grows toward the cell's end edge, ellipsized past it
185
- val badgeAnchor = Modifier.matchParentSize().wrapContentSize(Alignment.TopStart, unbounded = true)
186
- Badge(badgeLabel, modifier = badgeAnchor.offset(x = 14.dp, y = (-8).dp).widthIn(max = badgeMaxWidth))
187
- }
188
- }
189
- Text(
190
- text = item.label,
191
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint,
192
- style = if (selected) Typography.labelXsMedium else Typography.descriptionXsRegular,
193
- maxLines = 1,
194
- overflow = TextOverflow.Ellipsis
195
- )
196
- }
197
- }
198
- }
199
-
200
- @Composable
201
- internal fun LegacyFloatingButton(data: BottomTabFloatingButton, width: Dp) {
202
- Column(
203
- modifier = Modifier
204
- .width(width)
205
- .padding(horizontal = Spacing.XXS, vertical = Spacing.S)
206
- .conditional(IsShowBaseLineDebug) {
207
- border(1.dp, Colors.blue_03)
208
- }
209
- .activeOpacityClickable {
210
- data.onPress()
211
- },
212
- verticalArrangement = Arrangement.Bottom,
213
- horizontalAlignment = Alignment.CenterHorizontally
214
-
215
- ){
216
- LegacyCurvedContainer()
217
- Box(
218
- modifier = Modifier
219
- .size(48.dp)
220
- .background(AppTheme.current.colors.primary, CircleShape),
221
- contentAlignment = Alignment.Center
222
- ) {
223
- val iconContent = data.iconContent
224
- if (iconContent != null) iconContent() else Icon(source = data.icon, color = Color.White, size = 28.dp)
225
- }
226
- Spacer(modifier = Modifier.height(4.dp))
227
- Box(contentAlignment = Alignment.Center) {
228
- Text(
229
- text = data.label,
230
- style = Typography.labelXsMedium,
231
- color = Colors.black_01,
232
- textAlign = TextAlign.Center,
233
- modifier = Modifier
234
- .height(14.dp)
235
- .fillMaxWidth()
236
- .background(AppTheme.current.colors.primary, shape = RoundedCornerShape(size = Radius.XL))
237
- )
238
- data.labelContent?.invoke()
239
- }
240
- }
241
- }
242
-
243
- /** Pre-redesign phone bar plus the surface filler under it down to the home indicator. */
244
- @Composable
245
- internal fun LegacyBottomTabBarWithFiller(
246
- items: List<BottomTabItem>,
247
- floatingButton: BottomTabFloatingButton?,
248
- selectedIndex: Int,
249
- onTabSelected: (Int) -> Unit,
250
- ) {
251
- Column {
252
- LegacyBottomTabBar(
253
- items = items,
254
- floatingButton = floatingButton,
255
- selectedIndex = selectedIndex,
256
- onTabSelected = onTabSelected,
257
- )
258
- Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
259
- }
260
- }
@@ -1,86 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.foundation.Canvas
4
- import androidx.compose.foundation.layout.Box
5
- import androidx.compose.foundation.layout.height
6
- import androidx.compose.foundation.layout.offset
7
- import androidx.compose.foundation.layout.width
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Alignment
10
- import androidx.compose.ui.Modifier
11
- import androidx.compose.ui.graphics.Path
12
- import androidx.compose.ui.platform.LocalDensity
13
- import androidx.compose.ui.unit.Dp
14
- import androidx.compose.ui.unit.IntOffset
15
- import androidx.compose.ui.unit.dp
16
- import androidx.compose.ui.zIndex
17
- import vn.momo.kits.const.AppTheme
18
-
19
- @Composable
20
- internal fun LegacyCurvedContainer(
21
- circleSize: Dp = 48.dp,
22
- tabBarItemIconSize: Dp = 28.dp,
23
- circleOverSize: Dp = 2.dp,
24
- width: Dp = 71.dp,
25
- height: Dp = 16.dp
26
- ) {
27
- val theme = AppTheme.current
28
- val density = LocalDensity.current
29
- val widthPx = with(density) { width.toPx()}
30
-
31
- val circleSizePx = with(density) { circleSize.toPx() }
32
- val tabBarItemIconSizePx = with(density) { tabBarItemIconSize.toPx() }
33
- val circleOverSizePx = with(density) { circleOverSize.toPx() }
34
-
35
- val circlePositionTop = circleSizePx - tabBarItemIconSizePx - 10f
36
- val circleOverTop = circlePositionTop + circleOverSizePx
37
- val circleR = circleSizePx / 2
38
- val circleOverR = circleR + circleOverSizePx
39
-
40
- val centerX = widthPx / 2
41
-
42
- val curvedPath = getLegacyCurvedPath(
43
- circleOverTop = circleOverTop,
44
- centerX = centerX,
45
- circleOverR = circleOverR,
46
- widthPx = widthPx
47
- )
48
-
49
- Box(
50
- contentAlignment = Alignment.BottomCenter
51
- ){
52
- Canvas(
53
- modifier = Modifier
54
- .width(width)
55
- .height(height)
56
- .offset{ IntOffset(x = 0, y = 24) }
57
- .zIndex(-1f)
58
- ) {
59
- drawPath(path = curvedPath, color = theme.colors.background.surface)
60
- }
61
- }
62
- }
63
-
64
- private fun getLegacyCurvedPath(circleOverTop: Float, centerX: Float, circleOverR: Float, widthPx: Float): Path{
65
- return Path().apply {
66
- moveTo(0f, circleOverTop)
67
- lineTo(centerX - circleOverR - 40f, circleOverTop)
68
-
69
- cubicTo(
70
- centerX - circleOverR, circleOverTop,
71
- centerX - circleOverR, 0f,
72
- centerX, 0f
73
- )
74
-
75
- cubicTo(
76
- centerX + circleOverR, 0f,
77
- centerX + circleOverR, circleOverTop,
78
- centerX + circleOverR + 40f, circleOverTop
79
- )
80
-
81
- lineTo(widthPx, circleOverTop)
82
- lineTo(widthPx, 60f)
83
- lineTo(0f, 60f)
84
- close()
85
- }
86
- }
@@ -1,226 +0,0 @@
1
- // The pre-redesign (DS-984) phone tab bar, kept for `BottomTab(useLegacy: true)`: a full-width surface bar with a
2
- // sliding top indicator, a top shadow, badges and the notched center floating button, over a home-indicator filler.
3
-
4
- import SwiftUI
5
-
6
- let LEGACY_BOTTOM_TAB_BAR_HEIGHT: CGFloat = 64
7
- private let legacyFloatingButtonWidth: CGFloat = 75
8
-
9
- /// The legacy bar plus its surface filler under it, down to the window bottom.
10
- struct LegacyBottomTabBar: View {
11
- let items: [BottomTabItem]
12
- let floatingButton: BottomTabFloatingButton?
13
- let selectedIndex: Int
14
- let onTabSelected: (Int) -> Void
15
- let bottomInset: CGFloat
16
-
17
- @Environment(\.screenLayout) private var layout
18
- @Environment(\.appTheme) private var theme
19
-
20
- // the bar sits between the side safe areas
21
- private var screenWidth: CGFloat { layout.width - layout.insets.leading - layout.insets.trailing }
22
- private var mid: Int { items.count / 2 }
23
-
24
- private var tabWidth: CGFloat {
25
- let available = floatingButton != nil ? screenWidth - legacyFloatingButtonWidth : screenWidth
26
- return available / CGFloat(max(items.count, 1))
27
- }
28
-
29
- private var indicatorOffset: CGFloat {
30
- let adjust: CGFloat = (floatingButton != nil && selectedIndex >= mid) ? legacyFloatingButtonWidth : 0
31
- return tabWidth * CGFloat(selectedIndex) + tabWidth / 2 - screenWidth / 2 + adjust
32
- }
33
-
34
- var body: some View {
35
- VStack(spacing: 0) {
36
- bar
37
- theme.colors.background.surface
38
- .frame(height: bottomInset + Spacing.S)
39
- .ignoresSafeArea(edges: .horizontal)
40
- }
41
- }
42
-
43
- private var bar: some View {
44
- ZStack(alignment: .bottom) {
45
- HStack(spacing: 0) {
46
- if floatingButton == nil {
47
- tabItems(from: 0, to: items.count)
48
- } else {
49
- tabItems(from: 0, to: mid)
50
- Spacer()
51
- .frame(width: legacyFloatingButtonWidth)
52
- .padding(.horizontal, Spacing.XXS)
53
- tabItems(from: mid, to: items.count)
54
- }
55
- }
56
- .frame(maxWidth: .infinity)
57
- .frame(height: LEGACY_BOTTOM_TAB_BAR_HEIGHT)
58
- .background(theme.colors.background.surface.ignoresSafeArea(edges: .horizontal))
59
-
60
- RoundedRectangle(cornerRadius: 2)
61
- .fill(theme.colors.primary)
62
- .frame(width: 44, height: 2)
63
- .offset(x: indicatorOffset, y: -LEGACY_BOTTOM_TAB_BAR_HEIGHT + 2)
64
- .animation(.easeInOut(duration: 0.25), value: selectedIndex)
65
-
66
- LinearGradient(colors: [Color.black.opacity(0.05), .clear], startPoint: .bottom, endPoint: .top)
67
- .frame(height: 6)
68
- .frame(maxWidth: .infinity)
69
- .offset(y: -LEGACY_BOTTOM_TAB_BAR_HEIGHT)
70
-
71
- if let floatingButton {
72
- LegacyCenterFloatingButton(data: floatingButton)
73
- }
74
- }
75
- }
76
-
77
- @ViewBuilder
78
- private func tabItems(from: Int, to: Int) -> some View {
79
- ForEach(from..<to, id: \.self) { index in
80
- LegacyTabBarItem(
81
- item: items[index],
82
- selected: index == selectedIndex,
83
- // from the icon's center to the cell's end edge, inside both XXS paddings
84
- badgeMaxWidth: tabWidth / 2 - Spacing.XXS * 2,
85
- onClick: { onTabSelected(index) }
86
- )
87
- .frame(maxWidth: .infinity)
88
- }
89
- }
90
- }
91
-
92
- private struct LegacyTabBarItem: View {
93
- let item: BottomTabItem
94
- let selected: Bool
95
- let badgeMaxWidth: CGFloat
96
- let onClick: () -> Void
97
-
98
- @Environment(\.appTheme) private var theme
99
-
100
- private var tintColor: Color { selected ? theme.colors.primary : theme.colors.text.hint }
101
-
102
- /// Compose's `formatLabel`: a badge that is the number "0" is hidden.
103
- private var badgeLabel: String? {
104
- guard let label = item.badgeLabel else { return nil }
105
- if let number = Int(label), number == 0 { return nil }
106
- return label
107
- }
108
-
109
- var body: some View {
110
- VStack(spacing: 0) {
111
- Icon(source: item.icon, size: 28, color: tintColor)
112
- .overlay(alignment: .topLeading) {
113
- // starts at the icon's center and grows toward the cell's end edge, ellipsized past it
114
- if let badgeLabel, !badgeLabel.isEmpty {
115
- Badge(label: badgeLabel)
116
- .frame(width: max(badgeMaxWidth, 0), alignment: .leading)
117
- .offset(x: 14, y: -Spacing.S)
118
- }
119
- }
120
- .overlay(alignment: .topTrailing) {
121
- if badgeLabel?.isEmpty == true || (badgeLabel == nil && item.showDot) {
122
- BadgeDot(size: .small).offset(x: 4, y: -4)
123
- }
124
- }
125
- .padding(Spacing.XS)
126
- MomoText(
127
- item.label,
128
- typography: selected ? .labelXsMedium : .descriptionXsRegular,
129
- color: tintColor,
130
- textAlign: .center,
131
- maxLines: 1
132
- )
133
- .truncationMode(.tail)
134
- }
135
- .frame(maxWidth: .infinity, maxHeight: .infinity)
136
- .padding(Spacing.S)
137
- .frame(maxWidth: .infinity, maxHeight: .infinity)
138
- .padding(.horizontal, Spacing.XXS)
139
- .contentShape(Rectangle())
140
- .onTapGesture { onClick() }
141
- }
142
- }
143
-
144
- /// The 48 primary circle in the bar's notch; `iconContent` replaces the icon, `labelContent` overlays the label.
145
- private struct LegacyCenterFloatingButton: View {
146
- let data: BottomTabFloatingButton
147
-
148
- @Environment(\.appTheme) private var theme
149
-
150
- var body: some View {
151
- VStack(spacing: 0) {
152
- LegacyCurvedContainer()
153
- Circle()
154
- .fill(theme.colors.primary)
155
- .frame(width: 48, height: 48)
156
- .overlay(icon)
157
- Spacer().frame(height: 4)
158
- MomoText(data.label, typography: .labelXsMedium, color: Colors.black01, textAlign: .center, maxLines: 1)
159
- .frame(maxWidth: .infinity)
160
- .frame(height: 14)
161
- .background(theme.colors.primary)
162
- .clipShape(RoundedRectangle(cornerRadius: Radius.XL))
163
- .overlay(data.labelContent)
164
- }
165
- .frame(width: legacyFloatingButtonWidth)
166
- .padding(.horizontal, Spacing.XXS)
167
- .padding(.vertical, Spacing.S)
168
- .contentShape(Rectangle())
169
- .onTapGesture { data.onPress() }
170
- }
171
-
172
- @ViewBuilder
173
- private var icon: some View {
174
- if let iconContent = data.iconContent {
175
- iconContent
176
- } else {
177
- Icon(source: data.icon, size: 28, color: .white)
178
- }
179
- }
180
- }
181
-
182
- /// Compose's legacy `CurvedContainer`: the surface notch carved into the bar's top edge behind the center button.
183
- private struct LegacyCurvedContainer: View {
184
- private let circleSize: CGFloat = 48
185
- private let iconSize: CGFloat = 28
186
- private let circleOverSize: CGFloat = 2
187
- private let width: CGFloat = 71
188
- private let height: CGFloat = 16
189
-
190
- var body: some View {
191
- let circleOverTop = circleSize - iconSize - 10 + circleOverSize
192
- LegacyCurvedShape(circleOverTop: circleOverTop, centerX: width / 2, circleOverR: circleSize / 2 + circleOverSize)
193
- .fill(Colors.black01)
194
- .frame(width: width, height: height)
195
- .offset(y: 24)
196
- .zIndex(-1)
197
- }
198
- }
199
-
200
- /// A flat bar with a smooth circular dip in the middle, sized to cradle the floating button.
201
- private struct LegacyCurvedShape: Shape {
202
- let circleOverTop: CGFloat
203
- let centerX: CGFloat
204
- let circleOverR: CGFloat
205
-
206
- func path(in rect: CGRect) -> Path {
207
- var path = Path()
208
- path.move(to: CGPoint(x: 0, y: circleOverTop))
209
- path.addLine(to: CGPoint(x: centerX - circleOverR - 40, y: circleOverTop))
210
- path.addCurve(
211
- to: CGPoint(x: centerX, y: 0),
212
- control1: CGPoint(x: centerX - circleOverR, y: circleOverTop),
213
- control2: CGPoint(x: centerX - circleOverR, y: 0)
214
- )
215
- path.addCurve(
216
- to: CGPoint(x: centerX + circleOverR + 40, y: circleOverTop),
217
- control1: CGPoint(x: centerX + circleOverR, y: 0),
218
- control2: CGPoint(x: centerX + circleOverR, y: circleOverTop)
219
- )
220
- path.addLine(to: CGPoint(x: rect.width, y: circleOverTop))
221
- path.addLine(to: CGPoint(x: rect.width, y: 60))
222
- path.addLine(to: CGPoint(x: 0, y: 60))
223
- path.closeSubpath()
224
- return path
225
- }
226
- }