@momo-kits/native-kits 0.169.14-debug → 0.169.15-beta.1-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.
- package/compose/build.gradle.kts +2 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +10 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +19 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyBottomTabBar.kt +262 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyCurvedContainer.kt +86 -0
- package/gradle.properties +1 -1
- package/ios/Navigation/BottomTab/BottomTab.swift +22 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +2 -0
- package/ios/Navigation/BottomTab/LegacyBottomTabBar.swift +226 -0
- package/ios/Navigation/StackScreen.swift +2 -1
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +5 -1
- package/package.json +1 -1
- package/settings.gradle.kts +1 -0
package/compose/build.gradle.kts
CHANGED
|
@@ -40,7 +40,7 @@ kotlin {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
cocoapods {
|
|
43
|
-
version = "0.169.
|
|
43
|
+
version = "0.169.15-beta.1-debug"
|
|
44
44
|
summary = "IOS Shared module"
|
|
45
45
|
homepage = "https://momo.vn"
|
|
46
46
|
ios.deploymentTarget = "15.0"
|
|
@@ -113,6 +113,7 @@ repositories {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
mavenCentral()
|
|
116
|
+
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
|
|
116
117
|
maven {
|
|
117
118
|
url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
|
|
118
119
|
credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
|
package/compose/compose.podspec
CHANGED
|
@@ -77,6 +77,8 @@ 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
|
|
80
82
|
import vn.momo.kits.platform.BackHandler
|
|
81
83
|
import vn.momo.kits.platform.supportsImePadding
|
|
82
84
|
import vn.momo.kits.navigation.tracking.ScreenTracker
|
|
@@ -100,13 +102,17 @@ import kotlin.time.ExperimentalTime
|
|
|
100
102
|
fun floatingTabBarContentPadding(): PaddingValues {
|
|
101
103
|
val navigation = LocalNavigation.current
|
|
102
104
|
LaunchedEffect(navigation) { navigation.bottomTabEdgeToEdge = true }
|
|
103
|
-
val reserve = navigation.bottomTabIndex != -1 && navigation.bottomTabEdgeToEdge
|
|
105
|
+
val reserve = navigation.bottomTabIndex != -1 && navigation.bottomTabEdgeToEdge && !isLegacyPhoneTabBar()
|
|
104
106
|
return PaddingValues(bottom = if (reserve) bottomTabChildInset() else 0.dp)
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
|
|
108
110
|
internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
|
|
109
111
|
|
|
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
|
+
|
|
110
116
|
// Space a tab's content leaves for the tab bar and home indicator: the horizontal bar floats over the
|
|
111
117
|
// content (phone and unfolded Duo); the Duo rail lives in the side strip, so only the home indicator.
|
|
112
118
|
@Composable
|
|
@@ -116,6 +122,8 @@ private fun bottomTabChildInset(): Dp {
|
|
|
116
122
|
val layout = getScreenLayout()
|
|
117
123
|
return when {
|
|
118
124
|
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)
|
|
119
127
|
else -> (duoFloatingTabBarInset(layout, LocalTabBarHasCenterAction.current) - keyboard).coerceAtLeast(0.dp)
|
|
120
128
|
}
|
|
121
129
|
}
|
|
@@ -349,7 +357,7 @@ internal fun ColumnScope.MainContent(content: @Composable () -> Unit, isBottomTa
|
|
|
349
357
|
bottom = when {
|
|
350
358
|
options.hasFooter() || isBottomTabRoot -> 0.dp
|
|
351
359
|
// 0 when the tab pads itself via floatingTabBarContentPadding(), else the kit reserves the bar space
|
|
352
|
-
isBottomTabChild -> if (LocalNavigation.current.bottomTabEdgeToEdge) 0.dp else bottomTabChildInset()
|
|
360
|
+
isBottomTabChild -> if (LocalNavigation.current.bottomTabEdgeToEdge && !isLegacyPhoneTabBar()) 0.dp else bottomTabChildInset()
|
|
353
361
|
!options.scrollData.scrollable && options.scrollData.scrollState == null -> 0.dp
|
|
354
362
|
else -> navigationBar
|
|
355
363
|
}
|
|
@@ -50,6 +50,9 @@ 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
|
+
|
|
53
56
|
private val Hidden = Modifier.layout { measurable, constraints ->
|
|
54
57
|
val placeable = measurable.measure(constraints)
|
|
55
58
|
layout(placeable.width, placeable.height) {}
|
|
@@ -67,6 +70,10 @@ internal fun getBottomTabOption(index: Int): NavigationOptions? {
|
|
|
67
70
|
} else null
|
|
68
71
|
}
|
|
69
72
|
|
|
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
|
+
*/
|
|
70
77
|
@Composable
|
|
71
78
|
fun BottomTab(
|
|
72
79
|
items: List<BottomTabItem>,
|
|
@@ -77,6 +84,9 @@ fun BottomTab(
|
|
|
77
84
|
initialRouteName: String? = null,
|
|
78
85
|
onTabPress: ((index: Int, switchTab: () -> Unit) -> Unit)? = null,
|
|
79
86
|
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,
|
|
80
90
|
) {
|
|
81
91
|
val navigation = LocalNavigation.current
|
|
82
92
|
val navigator = LocalNavigator.current
|
|
@@ -160,6 +170,7 @@ fun BottomTab(
|
|
|
160
170
|
LocalDuoRailReserve provides railReserve,
|
|
161
171
|
LocalDuoBarCompression provides compression,
|
|
162
172
|
LocalTabBarHasCenterAction provides hasCenterAction(floatingButton, items.size),
|
|
173
|
+
LocalBottomTabLegacy provides useLegacy,
|
|
163
174
|
) {
|
|
164
175
|
loadedTabs.forEach { index ->
|
|
165
176
|
val item = items.getOrNull(index) ?: return@forEach
|
|
@@ -198,7 +209,14 @@ fun BottomTab(
|
|
|
198
209
|
BackHandler(enabled = !onFirstTab) {
|
|
199
210
|
if (backToInitialTab) backToFirstTab() else navigator.pop()
|
|
200
211
|
}
|
|
201
|
-
|
|
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) {
|
|
202
220
|
if (layout.isIPhoneDuo) {
|
|
203
221
|
DuoTabBar(
|
|
204
222
|
layout = layout,
|
|
@@ -0,0 +1,262 @@
|
|
|
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
|
+
// no vertical padding: icon (36) + label (14) centered in the 64 bar; a fixed 8 top/bottom left
|
|
172
|
+
// the label 12 and cut its bottom
|
|
173
|
+
.padding(horizontal = Spacing.S),
|
|
174
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
175
|
+
verticalArrangement = Arrangement.Center
|
|
176
|
+
) {
|
|
177
|
+
Box(modifier = Modifier.padding(Spacing.XS)) {
|
|
178
|
+
Icon(
|
|
179
|
+
source = item.icon,
|
|
180
|
+
size = 28.dp,
|
|
181
|
+
color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint)
|
|
182
|
+
if (showDot) {
|
|
183
|
+
val dotAnchor = Modifier.matchParentSize().wrapContentSize(Alignment.TopEnd, unbounded = true)
|
|
184
|
+
BadgeDot(size = DotSize.Small, modifier = dotAnchor.offset(x = 4.dp, y = (-4).dp))
|
|
185
|
+
} else if (!badgeLabel.isNullOrEmpty()) {
|
|
186
|
+
// starts at the icon's center and grows toward the cell's end edge, ellipsized past it
|
|
187
|
+
val badgeAnchor = Modifier.matchParentSize().wrapContentSize(Alignment.TopStart, unbounded = true)
|
|
188
|
+
Badge(badgeLabel, modifier = badgeAnchor.offset(x = 14.dp, y = (-8).dp).widthIn(max = badgeMaxWidth))
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
Text(
|
|
192
|
+
text = item.label,
|
|
193
|
+
color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint,
|
|
194
|
+
style = if (selected) Typography.labelXsMedium else Typography.descriptionXsRegular,
|
|
195
|
+
maxLines = 1,
|
|
196
|
+
overflow = TextOverflow.Ellipsis
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@Composable
|
|
203
|
+
internal fun LegacyFloatingButton(data: BottomTabFloatingButton, width: Dp) {
|
|
204
|
+
Column(
|
|
205
|
+
modifier = Modifier
|
|
206
|
+
.width(width)
|
|
207
|
+
.padding(horizontal = Spacing.XXS, vertical = Spacing.S)
|
|
208
|
+
.conditional(IsShowBaseLineDebug) {
|
|
209
|
+
border(1.dp, Colors.blue_03)
|
|
210
|
+
}
|
|
211
|
+
.activeOpacityClickable {
|
|
212
|
+
data.onPress()
|
|
213
|
+
},
|
|
214
|
+
verticalArrangement = Arrangement.Bottom,
|
|
215
|
+
horizontalAlignment = Alignment.CenterHorizontally
|
|
216
|
+
|
|
217
|
+
){
|
|
218
|
+
LegacyCurvedContainer()
|
|
219
|
+
Box(
|
|
220
|
+
modifier = Modifier
|
|
221
|
+
.size(48.dp)
|
|
222
|
+
.background(AppTheme.current.colors.primary, CircleShape),
|
|
223
|
+
contentAlignment = Alignment.Center
|
|
224
|
+
) {
|
|
225
|
+
val iconContent = data.iconContent
|
|
226
|
+
if (iconContent != null) iconContent() else Icon(source = data.icon, color = Color.White, size = 28.dp)
|
|
227
|
+
}
|
|
228
|
+
Spacer(modifier = Modifier.height(4.dp))
|
|
229
|
+
Box(contentAlignment = Alignment.Center) {
|
|
230
|
+
Text(
|
|
231
|
+
text = data.label,
|
|
232
|
+
style = Typography.labelXsMedium,
|
|
233
|
+
color = Colors.black_01,
|
|
234
|
+
textAlign = TextAlign.Center,
|
|
235
|
+
modifier = Modifier
|
|
236
|
+
.height(14.dp)
|
|
237
|
+
.fillMaxWidth()
|
|
238
|
+
.background(AppTheme.current.colors.primary, shape = RoundedCornerShape(size = Radius.XL))
|
|
239
|
+
)
|
|
240
|
+
data.labelContent?.invoke()
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Pre-redesign phone bar plus the surface filler under it down to the home indicator. */
|
|
246
|
+
@Composable
|
|
247
|
+
internal fun LegacyBottomTabBarWithFiller(
|
|
248
|
+
items: List<BottomTabItem>,
|
|
249
|
+
floatingButton: BottomTabFloatingButton?,
|
|
250
|
+
selectedIndex: Int,
|
|
251
|
+
onTabSelected: (Int) -> Unit,
|
|
252
|
+
) {
|
|
253
|
+
Column {
|
|
254
|
+
LegacyBottomTabBar(
|
|
255
|
+
items = items,
|
|
256
|
+
floatingButton = floatingButton,
|
|
257
|
+
selectedIndex = selectedIndex,
|
|
258
|
+
onTabSelected = onTabSelected,
|
|
259
|
+
)
|
|
260
|
+
Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
|
|
261
|
+
}
|
|
262
|
+
}
|
package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyCurvedContainer.kt
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
}
|
package/gradle.properties
CHANGED
|
@@ -10,6 +10,7 @@ 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
|
|
13
14
|
|
|
14
15
|
@EnvironmentObject private var navigator: Navigator
|
|
15
16
|
/// The screen hosting the tabs (Compose's `LocalNavigation` in BottomTab).
|
|
@@ -26,19 +27,22 @@ public struct BottomTab: View {
|
|
|
26
27
|
|
|
27
28
|
/// `compressionBehavior`: iPhone Duo bar that starts compressed when the side bar can't hold both (a tap swaps).
|
|
28
29
|
/// `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).
|
|
29
31
|
public init(
|
|
30
32
|
items: [BottomTabItem],
|
|
31
33
|
floatingButton: BottomTabFloatingButton? = nil,
|
|
32
34
|
compressionBehavior: DuoBarCompressionBehavior = .toolbar,
|
|
33
35
|
initialRouteName: String? = nil,
|
|
34
36
|
onTabPress: ((_ index: Int, _ switchTab: @escaping () -> Void) -> Void)? = nil,
|
|
35
|
-
backToInitialTab: Bool = true
|
|
37
|
+
backToInitialTab: Bool = true,
|
|
38
|
+
useLegacy: Bool = false
|
|
36
39
|
) {
|
|
37
40
|
self.items = items
|
|
38
41
|
self.floatingButton = floatingButton
|
|
39
42
|
self.compressionBehavior = compressionBehavior
|
|
40
43
|
self.onTabPress = onTabPress
|
|
41
44
|
self.backToInitialTab = backToInitialTab
|
|
45
|
+
self.useLegacy = useLegacy
|
|
42
46
|
let start = items.firstIndex { $0.name == initialRouteName } ?? 0
|
|
43
47
|
_startIndex = State(initialValue: start)
|
|
44
48
|
_selectedIndex = State(initialValue: start)
|
|
@@ -47,7 +51,13 @@ public struct BottomTab: View {
|
|
|
47
51
|
private var bottomInset: CGFloat { safeAreaBottomInset() }
|
|
48
52
|
// the bars float over the content (tab screens keep clear of them through duoTabBarInsets) or sit
|
|
49
53
|
// in the side strip, so only the home indicator is kept clear
|
|
50
|
-
|
|
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 }
|
|
51
61
|
|
|
52
62
|
private var compression: DuoBarCompression {
|
|
53
63
|
DuoBarCompression.resolve(
|
|
@@ -68,7 +78,8 @@ public struct BottomTab: View {
|
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
private func duoInsets(_ compression: DuoBarCompression) -> DuoTabBarInsets {
|
|
71
|
-
|
|
81
|
+
if isLegacyBar { return DuoTabBarInsets(isLegacyBar: true) }
|
|
82
|
+
return layout.duoTabBarInsets(
|
|
72
83
|
itemCount: items.count,
|
|
73
84
|
hasFloatingButton: floatingButton != nil,
|
|
74
85
|
tabBarCompressed: compression.tabBarCompressed
|
|
@@ -94,6 +105,14 @@ public struct BottomTab: View {
|
|
|
94
105
|
onTabSelected: selectTab,
|
|
95
106
|
compression: compression
|
|
96
107
|
)
|
|
108
|
+
} else if isLegacyBar {
|
|
109
|
+
LegacyBottomTabBar(
|
|
110
|
+
items: items,
|
|
111
|
+
floatingButton: floatingButton,
|
|
112
|
+
selectedIndex: selectedIndex,
|
|
113
|
+
onTabSelected: selectTab,
|
|
114
|
+
bottomInset: bottomInset
|
|
115
|
+
)
|
|
97
116
|
} else {
|
|
98
117
|
BottomTabBar(
|
|
99
118
|
items: items,
|
|
@@ -11,6 +11,8 @@ 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
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
private struct DuoTabBarInsetsKey: EnvironmentKey {
|
|
@@ -0,0 +1,226 @@
|
|
|
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
|
+
}
|
|
@@ -167,7 +167,8 @@ 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
|
|
170
|
+
guard let navigation, navigation.bottomTabIndex != -1, navigation.bottomTabEdgeToEdge,
|
|
171
|
+
!duoTabBarInsets.isLegacyBar else {
|
|
171
172
|
return duoTabBarInsets.overlay
|
|
172
173
|
}
|
|
173
174
|
return -layout.insets.bottom
|
package/ios/native-kits.podspec
CHANGED
|
@@ -38,6 +38,7 @@ private struct DemoConfig: Hashable {
|
|
|
38
38
|
var ctaLottie = false
|
|
39
39
|
var initialRouteName = "Momo"
|
|
40
40
|
var compressionBehavior: DuoBarCompressionBehavior = .toolbar
|
|
41
|
+
var useLegacy = false
|
|
41
42
|
var backToInitialTab = true
|
|
42
43
|
// a sticky footer in the tab's content body, to check it clears the floating bar
|
|
43
44
|
var footer = false
|
|
@@ -134,7 +135,8 @@ struct BottomTabDemoContent: View {
|
|
|
134
135
|
focused = tabs[index].name
|
|
135
136
|
switchTab()
|
|
136
137
|
},
|
|
137
|
-
backToInitialTab: config.backToInitialTab
|
|
138
|
+
backToInitialTab: config.backToInitialTab,
|
|
139
|
+
useLegacy: config.useLegacy
|
|
138
140
|
)
|
|
139
141
|
.id(config)
|
|
140
142
|
.onAppear { ctaLottieLoader.load() }
|
|
@@ -222,6 +224,8 @@ private struct TabContent: View {
|
|
|
222
224
|
config.compressionBehavior = .tabBar
|
|
223
225
|
},
|
|
224
226
|
])
|
|
227
|
+
Options(title: "useLegacy", hint: "Thanh tab cũ (trước redesign), iPhone thường",
|
|
228
|
+
options: yesNo(config.useLegacy) { config.useLegacy = $0 })
|
|
225
229
|
Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
|
|
226
230
|
options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
|
|
227
231
|
Options(title: "footer",
|
package/package.json
CHANGED
package/settings.gradle.kts
CHANGED