@momo-kits/native-kits 0.169.7-debug → 0.169.8-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/CLAUDE.md +2 -1
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +19 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +28 -58
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +3 -0
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +4 -1
- package/ios/Navigation/BottomTab/BottomTab.swift +19 -16
- package/ios/Navigation/BottomTab/BottomTabBar.swift +19 -33
- package/ios/Navigation/BottomTab/DuoTabBar.swift +3 -4
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +3 -0
- package/ios/Typography/FontScale.swift +44 -8
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +13 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -107,12 +107,13 @@ The SwiftUI port differs from Compose in one important way: **it follows the hos
|
|
|
107
107
|
|
|
108
108
|
## Font scale (`scaleSize`)
|
|
109
109
|
|
|
110
|
-
One formula, both platforms: the device-width scale (`width / 375`, capped at `+5pt`) and the OS Dynamic Type scale (capped at `1.5×`) are computed independently and the **larger wins**. When `useOSScaleRate` is false neither applies — the size is just multiplied by `userScaleRate`.
|
|
110
|
+
One formula, both platforms: the device-width scale (`width / 375`, capped at `+5pt`) and the OS Dynamic Type scale (capped at `1.5×`) are computed independently and the **larger wins**. When `useOSScaleRate` is false neither applies — the size is just multiplied by `userScaleRate`. The OS scale is capped at 1.5 by default; `MiniAppContext.scaleSizeMaxRate` (both sides) or `ScaleSizeScope(rate)` (Compose; SwiftUI also `.scaleSizeMaxRate(_:)`) caps a subtree at size × rate on both paths, nearest scope wins, null/nil lifts it (RN `ScaleSizeProvider`). The `ScaleSizeMaxRate` CompositionLocal is deprecated and not read.
|
|
111
111
|
|
|
112
112
|
- **Compose** — `const/Typography.kt` (`scaleSize` overloads for `Float`/`Dp`/`TextUnit`/`TextStyle`). The `TextUnit` overload divides by `density.fontScale` so Compose's own `sp` scaling isn't applied twice. Inputs: `LocalContext.current` (`MiniAppContext.userScaleRate` / `useOSScaleRate`, per-field) falling back to `DesignSystemKits.getConfigs()`. On iOS, `platform/OsFontScale.ios.kt` observes `UIContentSizeCategoryDidChangeNotification` and overrides `LocalDensity` — Compose MP otherwise reads `fontScale` once at `ComposeUIViewController` creation. Wired at `NavigationContainer`.
|
|
113
113
|
- **SwiftUI** — `ios/Typography/FontScale.swift`. `FontScale` is an immutable snapshot with `callAsFunction`, so a view reads `@Environment(\.momoFontScale) private var fontScale` and calls `fontScale(16)`. `DesignSystemKits.shared` is the `ObservableObject` holding the host inputs and the OS factor (it observes `UIContentSizeCategory.didChangeNotification`); the host pushes them with `setConfigs(_:)`.
|
|
114
114
|
- **Never set `\.momoFontScale` directly** — same trap as `\.localize`. Inject via `.momoFontScale(_:context:)`, which holds `DesignSystemKits` as `@ObservedObject`; that is what re-publishes the snapshot. It also injects `\.designSystemKitsConfigs`, which `MomoText` (whitelist font) and `TrustBanner` (fallback after `ApplicationEnvironment.config`) read so a host push re-renders them. `NavigationContainer` does it (passing `MiniAppContext` so the per-mini-app override applies); a bare `UIHostingController` root must too. The environment default reads the live store, so an un-injected subtree still gets correct values — just not live ones.
|
|
115
115
|
- The global `scaleSize(_:)` and `Font.appFont(size:)` remain for call sites that can't read the environment (UIKit bridges, free functions). They are **not** reactive. `Font.header_default_bold` & friends are computed `static var`s for the same reason — as stored `static let`s they froze the scale at first access. `UIViewRepresentable`s should read `context.environment.momoFontScale` instead, and re-apply the font in `updateUIView`, not only in `makeUIView`.
|
|
116
|
+
- **Bottom tab bar** — `BottomTab` caps the whole bar once at its root at `TabBarMetrics.LABEL_MAX_SCALE` / `labelMaxScale` (1.2, RN wraps `renderTabBar` in `ScaleSizeProvider`), so labels fit the fixed-height slots and the notch; the tab badge nests a scope of 1 to keep its design size. Consumer `iconContent` / `labelContent` sit under the same cap.
|
|
116
117
|
|
|
117
118
|
## Code conventions
|
|
118
119
|
|
package/compose/build.gradle.kts
CHANGED
package/compose/compose.podspec
CHANGED
|
@@ -106,5 +106,5 @@ val LocalDesignSystemConfig = staticCompositionLocalOf<DesignSystemConfig?> {
|
|
|
106
106
|
null
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
@Deprecated("
|
|
109
|
+
@Deprecated("No longer read; wrap content in ScaleSizeScope(scaleSizeMaxRate) to cap the font scale.")
|
|
110
110
|
val ScaleSizeMaxRate = staticCompositionLocalOf<Float?> { null }
|
|
@@ -2,20 +2,20 @@ package vn.momo.kits.components
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
5
|
-
import
|
|
5
|
+
import androidx.compose.runtime.remember
|
|
6
|
+
import vn.momo.kits.application.LocalContext
|
|
7
|
+
import vn.momo.kits.application.MiniAppContext
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ReplaceWith("content()"),
|
|
10
|
-
)
|
|
9
|
+
// Caps scaleSize() for the subtree at size × scaleSizeMaxRate through MiniAppContext.scaleSizeMaxRate
|
|
10
|
+
// (RN ScaleSizeProvider); the nearest scope wins and null lifts the cap.
|
|
11
11
|
@Composable
|
|
12
12
|
fun ScaleSizeScope(
|
|
13
13
|
scaleSizeMaxRate: Float? = null,
|
|
14
14
|
content: @Composable () -> Unit
|
|
15
15
|
) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
content()
|
|
16
|
+
val context = LocalContext.current
|
|
17
|
+
val scoped = remember(context, scaleSizeMaxRate) {
|
|
18
|
+
(context ?: MiniAppContext()).copy(scaleSizeMaxRate = scaleSizeMaxRate)
|
|
20
19
|
}
|
|
20
|
+
CompositionLocalProvider(LocalContext provides scoped, content = content)
|
|
21
21
|
}
|
|
@@ -27,6 +27,7 @@ import androidx.compose.ui.layout.layout
|
|
|
27
27
|
import androidx.compose.ui.unit.dp
|
|
28
28
|
import androidx.compose.ui.zIndex
|
|
29
29
|
import kotlin.math.abs
|
|
30
|
+
import vn.momo.kits.components.ScaleSizeScope
|
|
30
31
|
import vn.momo.kits.const.AppTheme
|
|
31
32
|
import vn.momo.kits.navigation.KeyboardOptions
|
|
32
33
|
import vn.momo.kits.navigation.LocalMaxApi
|
|
@@ -197,22 +198,24 @@ fun BottomTab(
|
|
|
197
198
|
BackHandler(enabled = !onFirstTab) {
|
|
198
199
|
if (backToInitialTab) backToFirstTab() else navigator.pop()
|
|
199
200
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
201
|
+
ScaleSizeScope(TabBarMetrics.LABEL_MAX_SCALE) {
|
|
202
|
+
if (layout.isIPhoneDuo) {
|
|
203
|
+
DuoTabBar(
|
|
204
|
+
layout = layout,
|
|
205
|
+
items = items,
|
|
206
|
+
floatingButton = floatingButton,
|
|
207
|
+
selectedIndex = selectedIndex,
|
|
208
|
+
onTabSelected = onTabSelected,
|
|
209
|
+
compression = compression,
|
|
210
|
+
)
|
|
211
|
+
} else {
|
|
212
|
+
BottomTabBar(
|
|
213
|
+
items = items,
|
|
214
|
+
floatingButton = floatingButton,
|
|
215
|
+
selectedIndex = selectedIndex,
|
|
216
|
+
onTabSelected = onTabSelected,
|
|
217
|
+
)
|
|
218
|
+
}
|
|
216
219
|
}
|
|
217
220
|
}
|
|
218
221
|
}
|
|
@@ -30,7 +30,6 @@ import androidx.compose.foundation.layout.*
|
|
|
30
30
|
import androidx.compose.foundation.shape.CircleShape
|
|
31
31
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
32
32
|
import androidx.compose.runtime.Composable
|
|
33
|
-
import androidx.compose.runtime.CompositionLocalProvider
|
|
34
33
|
import androidx.compose.runtime.remember
|
|
35
34
|
import androidx.compose.ui.Alignment
|
|
36
35
|
import androidx.compose.ui.Modifier
|
|
@@ -38,8 +37,6 @@ import androidx.compose.ui.text.style.TextAlign
|
|
|
38
37
|
import androidx.compose.ui.text.style.TextOverflow
|
|
39
38
|
import androidx.compose.ui.unit.dp
|
|
40
39
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
41
|
-
import vn.momo.kits.application.LocalContext
|
|
42
|
-
import vn.momo.kits.application.MiniAppContext
|
|
43
40
|
import vn.momo.kits.components.*
|
|
44
41
|
import vn.momo.kits.const.*
|
|
45
42
|
import vn.momo.kits.layout.getScreenLayout
|
|
@@ -71,7 +68,6 @@ internal fun BottomTabBar(
|
|
|
71
68
|
floatingButton = floatingButton,
|
|
72
69
|
selectedIndex = selectedIndex,
|
|
73
70
|
onTabSelected = onTabSelected,
|
|
74
|
-
fixedFontScale = true,
|
|
75
71
|
modifier = Modifier
|
|
76
72
|
.offset(x = (layout.insetLeft - layout.insetRight) / 2)
|
|
77
73
|
.width(
|
|
@@ -94,7 +90,6 @@ internal fun HorizontalTabBar(
|
|
|
94
90
|
selectedIndex: Int,
|
|
95
91
|
onTabSelected: (Int) -> Unit,
|
|
96
92
|
modifier: Modifier = Modifier,
|
|
97
|
-
fixedFontScale: Boolean = false,
|
|
98
93
|
) {
|
|
99
94
|
val cta = floatingButton?.takeIf { hasCenterAction(it, items.size) }
|
|
100
95
|
val mid = items.size / 2
|
|
@@ -136,7 +131,6 @@ internal fun HorizontalTabBar(
|
|
|
136
131
|
TabBarItem(
|
|
137
132
|
item = item,
|
|
138
133
|
selected = index == selectedIndex,
|
|
139
|
-
fixedFontScale = fixedFontScale,
|
|
140
134
|
modifier = Modifier.onPlaced {
|
|
141
135
|
itemBounds[index] = it.positionInParent().x to it.size.width.toFloat()
|
|
142
136
|
},
|
|
@@ -145,10 +139,19 @@ internal fun HorizontalTabBar(
|
|
|
145
139
|
}
|
|
146
140
|
}
|
|
147
141
|
}
|
|
148
|
-
cta?.let { CenterAction(it,
|
|
142
|
+
cta?.let { CenterAction(it, Modifier.align(Alignment.TopCenter).offset(y = centerActionTop())) }
|
|
149
143
|
}
|
|
150
144
|
}
|
|
151
145
|
|
|
146
|
+
// Offset of the center action column from the bar top: the items are centered in the container (which
|
|
147
|
+
// starts ctaLift down), so the column is placed for its label to start on the tab labels' line.
|
|
148
|
+
private fun centerActionTop() = with(TabBarMetrics) {
|
|
149
|
+
val itemHeight = indicatorHeight + itemIconLabelGap + labelHeight
|
|
150
|
+
val itemLabelTop = ctaLift + paddingVertical + (height - paddingVertical * 2 - itemHeight) / 2 +
|
|
151
|
+
indicatorHeight + itemIconLabelGap
|
|
152
|
+
itemLabelTop - ctaLabelGap - ctaSize
|
|
153
|
+
}
|
|
154
|
+
|
|
152
155
|
// One active indicator per bar (Background/tonal with its inner shadows) sliding to the selected item
|
|
153
156
|
// along x (horizontal bar) or y (rail); it lands in place on the first measure and slides from then on.
|
|
154
157
|
@Composable
|
|
@@ -176,7 +179,6 @@ internal fun ActiveIndicator(offset: Float, modifier: Modifier, shape: Shape, ax
|
|
|
176
179
|
private fun RowScope.TabBarItem(
|
|
177
180
|
item: BottomTabItem,
|
|
178
181
|
selected: Boolean,
|
|
179
|
-
fixedFontScale: Boolean,
|
|
180
182
|
modifier: Modifier,
|
|
181
183
|
onClick: () -> Unit,
|
|
182
184
|
) {
|
|
@@ -195,7 +197,7 @@ private fun RowScope.TabBarItem(
|
|
|
195
197
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
196
198
|
verticalArrangement = Arrangement.spacedBy(TabBarMetrics.itemIconLabelGap),
|
|
197
199
|
) {
|
|
198
|
-
TabItemContent(item, selected
|
|
200
|
+
TabItemContent(item, selected)
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
|
|
@@ -207,7 +209,6 @@ internal fun ColumnScope.TabItemContent(
|
|
|
207
209
|
selected: Boolean,
|
|
208
210
|
vertical: Boolean = false,
|
|
209
211
|
showLabel: Boolean = true,
|
|
210
|
-
fixedFontScale: Boolean = false,
|
|
211
212
|
) {
|
|
212
213
|
val colors = AppTheme.current.colors
|
|
213
214
|
val tint by animateColorAsState(
|
|
@@ -226,7 +227,13 @@ internal fun ColumnScope.TabItemContent(
|
|
|
226
227
|
TabIcon(item, tint, vertical)
|
|
227
228
|
}
|
|
228
229
|
if (showLabel) {
|
|
229
|
-
|
|
230
|
+
// fixed slot so a capped-scale label overflows downward and the icon above it stays put
|
|
231
|
+
Box(
|
|
232
|
+
modifier = Modifier.height(
|
|
233
|
+
if (vertical) TabBarMetrics.railLabelHeight else TabBarMetrics.labelHeight
|
|
234
|
+
),
|
|
235
|
+
contentAlignment = Alignment.TopCenter,
|
|
236
|
+
) {
|
|
230
237
|
Text(
|
|
231
238
|
text = item.label,
|
|
232
239
|
color = tint,
|
|
@@ -238,43 +245,9 @@ internal fun ColumnScope.TabItemContent(
|
|
|
238
245
|
.wrapContentHeight(Alignment.Top, unbounded = true),
|
|
239
246
|
)
|
|
240
247
|
}
|
|
241
|
-
// fixed slot so a capped-scale label overflows downward and the icon above it stays put
|
|
242
|
-
Box(
|
|
243
|
-
modifier = Modifier.height(
|
|
244
|
-
if (vertical) TabBarMetrics.railLabelHeight else TabBarMetrics.labelHeight
|
|
245
|
-
),
|
|
246
|
-
contentAlignment = Alignment.TopCenter,
|
|
247
|
-
) {
|
|
248
|
-
if (fixedFontScale) CappedFontScale(label) else label()
|
|
249
|
-
}
|
|
250
248
|
}
|
|
251
249
|
}
|
|
252
250
|
|
|
253
|
-
// Like the system tab bar the label keeps its design size; Text grows it up to 5pt on the wide Duo displays.
|
|
254
|
-
@Composable
|
|
255
|
-
internal fun FixedFontScale(content: @Composable () -> Unit) {
|
|
256
|
-
val context = LocalContext.current
|
|
257
|
-
val fixedScale = remember(context) {
|
|
258
|
-
(context ?: MiniAppContext()).copy(userScaleRate = 1f, useOSScaleRate = false)
|
|
259
|
-
}
|
|
260
|
-
CompositionLocalProvider(LocalContext provides fixedScale, content = content)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Tab labels follow the OS/host font scale but never grow past this, so the fixed-height container
|
|
264
|
-
// and the notch stay aligned.
|
|
265
|
-
private const val TAB_LABEL_MAX_SCALE = 1.2f
|
|
266
|
-
|
|
267
|
-
// Caps the label scale at TAB_LABEL_MAX_SCALE: it keeps following the host/OS font scale but stops
|
|
268
|
-
// growing past 1.2× so it fits the fixed bar geometry.
|
|
269
|
-
@Composable
|
|
270
|
-
internal fun CappedFontScale(content: @Composable () -> Unit) {
|
|
271
|
-
val context = LocalContext.current
|
|
272
|
-
val capped = remember(context) {
|
|
273
|
-
(context ?: MiniAppContext()).copy(scaleSizeMaxRate = TAB_LABEL_MAX_SCALE)
|
|
274
|
-
}
|
|
275
|
-
CompositionLocalProvider(LocalContext provides capped, content = content)
|
|
276
|
-
}
|
|
277
|
-
|
|
278
251
|
// Badge value shown on a tab: null hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
|
|
279
252
|
internal fun tabBadgeLabel(item: BottomTabItem): String? {
|
|
280
253
|
val label = item.badgeLabel ?: return if (item.showDot) "" else null
|
|
@@ -331,7 +304,7 @@ private fun TabBadge(label: String, modifier: Modifier) {
|
|
|
331
304
|
.padding(horizontal = Spacing.XS),
|
|
332
305
|
contentAlignment = Alignment.Center,
|
|
333
306
|
) {
|
|
334
|
-
|
|
307
|
+
ScaleSizeScope(1f) {
|
|
335
308
|
Text(
|
|
336
309
|
text = label,
|
|
337
310
|
style = Typography.actionXxsBold,
|
|
@@ -374,9 +347,14 @@ internal fun Modifier.centerActionButton(size: androidx.compose.ui.unit.Dp, pres
|
|
|
374
347
|
}
|
|
375
348
|
|
|
376
349
|
@Composable
|
|
377
|
-
internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?, vertical: Boolean
|
|
350
|
+
internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?, vertical: Boolean) {
|
|
378
351
|
val colors = AppTheme.current.colors
|
|
379
|
-
|
|
352
|
+
Box(
|
|
353
|
+
modifier = Modifier
|
|
354
|
+
.then(if (vertical) Modifier else Modifier.heightIn(min = TabBarMetrics.ctaLabelHeight))
|
|
355
|
+
.padding(horizontal = if (vertical) Spacing.XS else Spacing.XXS),
|
|
356
|
+
contentAlignment = Alignment.Center,
|
|
357
|
+
) {
|
|
380
358
|
Text(
|
|
381
359
|
text = label,
|
|
382
360
|
style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
|
|
@@ -385,14 +363,6 @@ internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?
|
|
|
385
363
|
maxLines = 1,
|
|
386
364
|
overflow = TextOverflow.Ellipsis,
|
|
387
365
|
)
|
|
388
|
-
}
|
|
389
|
-
Box(
|
|
390
|
-
modifier = Modifier
|
|
391
|
-
.then(if (vertical) Modifier else Modifier.heightIn(min = TabBarMetrics.ctaLabelHeight))
|
|
392
|
-
.padding(horizontal = if (vertical) Spacing.XS else Spacing.XXS),
|
|
393
|
-
contentAlignment = Alignment.Center,
|
|
394
|
-
) {
|
|
395
|
-
if (fixedFontScale) CappedFontScale(text) else text()
|
|
396
366
|
overlay?.let {
|
|
397
367
|
Box(Modifier.matchParentSize().wrapContentSize(Alignment.Center, unbounded = true)) { it() }
|
|
398
368
|
}
|
|
@@ -401,7 +371,7 @@ internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?
|
|
|
401
371
|
|
|
402
372
|
// Center action (.Nav/CTA): button rising out of the notch, label under it.
|
|
403
373
|
@Composable
|
|
404
|
-
private fun CenterAction(data: BottomTabFloatingButton,
|
|
374
|
+
private fun CenterAction(data: BottomTabFloatingButton, modifier: Modifier) {
|
|
405
375
|
val (interactionSource, pressed) = rememberCenterActionPress()
|
|
406
376
|
Column(
|
|
407
377
|
modifier = modifier
|
|
@@ -425,6 +395,6 @@ private fun CenterAction(data: BottomTabFloatingButton, fixedFontScale: Boolean,
|
|
|
425
395
|
Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
|
|
426
396
|
}
|
|
427
397
|
}
|
|
428
|
-
CenterActionLabel(data.label, data.labelContent, vertical = false
|
|
398
|
+
CenterActionLabel(data.label, data.labelContent, vertical = false)
|
|
429
399
|
}
|
|
430
400
|
}
|
|
@@ -80,7 +80,6 @@ internal fun BoxScope.DuoTabBar(
|
|
|
80
80
|
floatingButton = floatingButton,
|
|
81
81
|
selectedIndex = selectedIndex,
|
|
82
82
|
onTabSelected = onTabSelected,
|
|
83
|
-
fixedFontScale = true,
|
|
84
83
|
modifier = Modifier
|
|
85
84
|
.align(Alignment.BottomCenter)
|
|
86
85
|
.padding(bottom = tabBarBottomGap(layout.insetBottom))
|
|
@@ -180,7 +179,7 @@ private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (I
|
|
|
180
179
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
181
180
|
verticalArrangement = Arrangement.Center,
|
|
182
181
|
) {
|
|
183
|
-
TabItemContent(item, selected = index == selectedIndex, vertical = true
|
|
182
|
+
TabItemContent(item, selected = index == selectedIndex, vertical = true)
|
|
184
183
|
}
|
|
185
184
|
}
|
|
186
185
|
}
|
|
@@ -203,6 +202,6 @@ private fun RailCenterAction(data: BottomTabFloatingButton) {
|
|
|
203
202
|
Box(Modifier.centerActionButton(TabBarMetrics.railCtaSize, pressed), contentAlignment = Alignment.Center) {
|
|
204
203
|
data.iconContent?.invoke() ?: Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
|
|
205
204
|
}
|
|
206
|
-
CenterActionLabel(data.label, data.labelContent, vertical = true
|
|
205
|
+
CenterActionLabel(data.label, data.labelContent, vertical = true)
|
|
207
206
|
}
|
|
208
207
|
}
|
|
@@ -33,6 +33,9 @@ internal object TabBarMetrics {
|
|
|
33
33
|
// label overflows downward instead of pushing the icon up
|
|
34
34
|
val labelHeight = 18.dp
|
|
35
35
|
val railLabelHeight = 14.dp
|
|
36
|
+
// font scale cap for the whole bar (RN ScaleSizeProvider around renderTabBar): its text follows the
|
|
37
|
+
// OS/host scale up to 1.2× so the fixed-height container and the notch stay aligned
|
|
38
|
+
const val LABEL_MAX_SCALE = 1.2f
|
|
36
39
|
// active indicator behind the icon: 24 icon + XS·M padding
|
|
37
40
|
val indicatorPaddingHorizontal = Spacing.M
|
|
38
41
|
val indicatorRadius = Radius.XL
|
package/gradle.properties
CHANGED
|
@@ -21,8 +21,10 @@ public class MiniAppContext {
|
|
|
21
21
|
// MiniAppContext.userScaleRate / useOSScaleRate, which win per field over DesignSystemKits.
|
|
22
22
|
public var userScaleRate: CGFloat? = nil
|
|
23
23
|
public var useOSScaleRate: Bool? = nil
|
|
24
|
+
// Caps the font scale at size × rate, nil means no cap (Compose MiniAppContext.scaleSizeMaxRate).
|
|
25
|
+
public var scaleSizeMaxRate: CGFloat? = nil
|
|
24
26
|
|
|
25
|
-
public init(appId: String, appCode: String, appName: Any? = nil, appIcon: String, description: Any? = nil, support: [String: Any] = [:], toolkitConfig: [String: Any] = [:], providerId: String = "momo", permissions: [[String: Any]] = [], userScaleRate: CGFloat? = nil, useOSScaleRate: Bool? = nil) {
|
|
27
|
+
public init(appId: String, appCode: String, appName: Any? = nil, appIcon: String, description: Any? = nil, support: [String: Any] = [:], toolkitConfig: [String: Any] = [:], providerId: String = "momo", permissions: [[String: Any]] = [], userScaleRate: CGFloat? = nil, useOSScaleRate: Bool? = nil, scaleSizeMaxRate: CGFloat? = nil) {
|
|
26
28
|
self.appId = appId
|
|
27
29
|
self.appCode = appCode
|
|
28
30
|
self.appName = appName
|
|
@@ -34,6 +36,7 @@ public class MiniAppContext {
|
|
|
34
36
|
self.permissions = permissions
|
|
35
37
|
self.userScaleRate = userScaleRate
|
|
36
38
|
self.useOSScaleRate = useOSScaleRate
|
|
39
|
+
self.scaleSizeMaxRate = scaleSizeMaxRate
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -87,23 +87,26 @@ public struct BottomTab: View {
|
|
|
87
87
|
.environment(\.duoTabBarInsets, duoInsets(compression))
|
|
88
88
|
.environment(\.duoBarCompression, compression)
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
90
|
+
Group {
|
|
91
|
+
if layout.isIPhoneDuo {
|
|
92
|
+
DuoTabBar(
|
|
93
|
+
items: items,
|
|
94
|
+
floatingButton: floatingButton,
|
|
95
|
+
selectedIndex: selectedIndex,
|
|
96
|
+
onTabSelected: selectTab,
|
|
97
|
+
compression: compression
|
|
98
|
+
)
|
|
99
|
+
} else {
|
|
100
|
+
BottomTabBar(
|
|
101
|
+
items: items,
|
|
102
|
+
floatingButton: floatingButton,
|
|
103
|
+
selectedIndex: selectedIndex,
|
|
104
|
+
onTabSelected: selectTab,
|
|
105
|
+
bottomInset: bottomInset
|
|
106
|
+
)
|
|
107
|
+
}
|
|
106
108
|
}
|
|
109
|
+
.scaleSizeMaxRate(TabBarMetrics.labelMaxScale)
|
|
107
110
|
}
|
|
108
111
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
109
112
|
.ignoresSafeArea(edges: .bottom)
|
|
@@ -95,8 +95,7 @@ struct BottomTabBar: View {
|
|
|
95
95
|
layout,
|
|
96
96
|
itemCount: items.count,
|
|
97
97
|
hasCta: TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count)
|
|
98
|
-
)
|
|
99
|
-
fixedFontScale: true
|
|
98
|
+
)
|
|
100
99
|
)
|
|
101
100
|
.padding(.bottom, TabBarMetrics.bottomGap(bottomInset))
|
|
102
101
|
.frame(maxWidth: .infinity)
|
|
@@ -112,7 +111,6 @@ struct HorizontalTabBar: View {
|
|
|
112
111
|
let selectedIndex: Int
|
|
113
112
|
let onTabSelected: (Int) -> Void
|
|
114
113
|
let width: CGFloat
|
|
115
|
-
var fixedFontScale = false
|
|
116
114
|
|
|
117
115
|
private var cta: BottomTabFloatingButton? {
|
|
118
116
|
TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count) ? floatingButton : nil
|
|
@@ -147,7 +145,7 @@ struct HorizontalTabBar: View {
|
|
|
147
145
|
}
|
|
148
146
|
SwiftUI.Button { onTabSelected(index) } label: {
|
|
149
147
|
VStack(spacing: TabBarMetrics.itemIconLabelGap) {
|
|
150
|
-
TabItemContent(item: items[index], selected: index == selectedIndex
|
|
148
|
+
TabItemContent(item: items[index], selected: index == selectedIndex)
|
|
151
149
|
}
|
|
152
150
|
.frame(width: itemWidth)
|
|
153
151
|
.contentShape(Rectangle())
|
|
@@ -167,11 +165,20 @@ struct HorizontalTabBar: View {
|
|
|
167
165
|
.padding(.top, cta == nil ? 0 : TabBarMetrics.ctaLift)
|
|
168
166
|
|
|
169
167
|
if let cta {
|
|
170
|
-
CenterAction(data: cta
|
|
168
|
+
CenterAction(data: cta)
|
|
169
|
+
.offset(y: centerActionTop)
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
.frame(width: width)
|
|
174
173
|
}
|
|
174
|
+
|
|
175
|
+
/// Offset of the center action column from the bar top: the items sit at the top of the container
|
|
176
|
+
/// (which starts ctaLift down), so the column is placed for its label to start on the tab labels' line.
|
|
177
|
+
private var centerActionTop: CGFloat {
|
|
178
|
+
let itemLabelTop = TabBarMetrics.ctaLift + TabBarMetrics.paddingVertical
|
|
179
|
+
+ TabBarMetrics.indicatorHeight + TabBarMetrics.itemIconLabelGap
|
|
180
|
+
return itemLabelTop - TabBarMetrics.ctaLabelGap - TabBarMetrics.ctaSize
|
|
181
|
+
}
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
/// One active indicator per bar: Background/tonal with its inner light (white 12% from below) and
|
|
@@ -203,21 +210,6 @@ struct ActiveIndicator: View {
|
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
/// Tab labels follow the host/OS font scale but never grow past this, so the fixed-height container
|
|
207
|
-
/// and the notch stay aligned.
|
|
208
|
-
private let tabLabelMaxScale: CGFloat = 1.2
|
|
209
|
-
|
|
210
|
-
/// Compose's `CappedFontScale`: caps the label scale at `tabLabelMaxScale` when enabled.
|
|
211
|
-
struct CappedFontScale: ViewModifier {
|
|
212
|
-
let enabled: Bool
|
|
213
|
-
|
|
214
|
-
@Environment(\.momoFontScale) private var fontScale
|
|
215
|
-
|
|
216
|
-
func body(content: Content) -> some View {
|
|
217
|
-
content.environment(\.momoFontScale, enabled ? fontScale.cappedAt(tabLabelMaxScale) : fontScale)
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
213
|
// MARK: - Tab item
|
|
222
214
|
|
|
223
215
|
/// Icon in its indicator slot, label under it. The bar slides one shared active indicator behind the
|
|
@@ -227,7 +219,6 @@ struct TabItemContent: View {
|
|
|
227
219
|
let selected: Bool
|
|
228
220
|
var vertical = false
|
|
229
221
|
var showLabel = true
|
|
230
|
-
var fixedFontScale = false
|
|
231
222
|
|
|
232
223
|
@Environment(\.appTheme) private var theme
|
|
233
224
|
|
|
@@ -235,19 +226,17 @@ struct TabItemContent: View {
|
|
|
235
226
|
TabIcon(item: item, selected: selected, vertical: vertical)
|
|
236
227
|
.frame(height: vertical ? TabBarMetrics.railIndicatorHeight : TabBarMetrics.indicatorHeight)
|
|
237
228
|
if showLabel {
|
|
238
|
-
|
|
229
|
+
ZStack {
|
|
239
230
|
labelText(theme.colors.text.secondary).opacity(selected ? 0 : 1)
|
|
240
231
|
labelText(theme.colors.primary).opacity(selected ? 1 : 0)
|
|
241
232
|
}
|
|
242
233
|
.animation(TabBarMetrics.tintMotion, value: selected)
|
|
243
234
|
.frame(maxWidth: vertical ? nil : .infinity)
|
|
244
235
|
// fixed slot so a capped-scale label overflows downward and the icon above it stays put
|
|
245
|
-
|
|
246
|
-
.
|
|
247
|
-
.
|
|
248
|
-
|
|
249
|
-
alignment: .top
|
|
250
|
-
)
|
|
236
|
+
.frame(
|
|
237
|
+
height: vertical ? TabBarMetrics.railLabelHeight : TabBarMetrics.labelHeight,
|
|
238
|
+
alignment: .top
|
|
239
|
+
)
|
|
251
240
|
}
|
|
252
241
|
}
|
|
253
242
|
|
|
@@ -324,7 +313,7 @@ private struct TabBadge: View {
|
|
|
324
313
|
var body: some View {
|
|
325
314
|
MomoText(label, typography: .actionXxsBold, color: Colors.black01, maxLines: 1)
|
|
326
315
|
.truncationMode(.tail)
|
|
327
|
-
.
|
|
316
|
+
.scaleSizeMaxRate(1)
|
|
328
317
|
.padding(.horizontal, Spacing.XS)
|
|
329
318
|
.frame(minWidth: 16, maxWidth: TabBarMetrics.badgeMaxWidth, minHeight: 16, maxHeight: 16)
|
|
330
319
|
.background(Capsule().fill(isNumber ? theme.colors.error.primary : theme.colors.warning.primary))
|
|
@@ -342,7 +331,6 @@ struct CenterActionStyle: ButtonStyle {
|
|
|
342
331
|
var iconContent: AnyView? = nil
|
|
343
332
|
var labelContent: AnyView? = nil
|
|
344
333
|
let label: String
|
|
345
|
-
var fixedFontScale = false
|
|
346
334
|
|
|
347
335
|
@Environment(\.appTheme) private var theme
|
|
348
336
|
|
|
@@ -379,7 +367,6 @@ struct CenterActionStyle: ButtonStyle {
|
|
|
379
367
|
maxLines: 1
|
|
380
368
|
)
|
|
381
369
|
.truncationMode(.tail)
|
|
382
|
-
.modifier(CappedFontScale(enabled: fixedFontScale))
|
|
383
370
|
.padding(.horizontal, vertical ? Spacing.XS : Spacing.XXS)
|
|
384
371
|
.frame(minHeight: vertical ? nil : TabBarMetrics.ctaLabelHeight)
|
|
385
372
|
.overlay(labelContent?.allowsHitTesting(false))
|
|
@@ -393,13 +380,12 @@ struct CenterActionStyle: ButtonStyle {
|
|
|
393
380
|
/// Center action (.Nav/CTA): button rising out of the notch, label under it.
|
|
394
381
|
private struct CenterAction: View {
|
|
395
382
|
let data: BottomTabFloatingButton
|
|
396
|
-
var fixedFontScale = false
|
|
397
383
|
|
|
398
384
|
var body: some View {
|
|
399
385
|
SwiftUI.Button(action: data.onPress) { EmptyView() }
|
|
400
386
|
.buttonStyle(CenterActionStyle(size: TabBarMetrics.ctaSize, vertical: false, icon: data.icon,
|
|
401
387
|
iconContent: data.iconContent, labelContent: data.labelContent,
|
|
402
|
-
label: data.label
|
|
388
|
+
label: data.label))
|
|
403
389
|
.frame(width: TabBarMetrics.ctaSlotWidth, height: TabBarMetrics.ctaSize + TabBarMetrics.ctaLabelGap + TabBarMetrics.ctaLabelHeight)
|
|
404
390
|
.accessibilityLabel(data.label)
|
|
405
391
|
.accessibilityIdentifier(data.label)
|
|
@@ -131,7 +131,7 @@ private struct DuoRailTabBar: View {
|
|
|
131
131
|
compression.onTabSelected()
|
|
132
132
|
} label: {
|
|
133
133
|
VStack(spacing: 0) {
|
|
134
|
-
TabItemContent(item: items[index], selected: index == selectedIndex, vertical: true
|
|
134
|
+
TabItemContent(item: items[index], selected: index == selectedIndex, vertical: true)
|
|
135
135
|
}
|
|
136
136
|
.frame(width: TabBarMetrics.railItemWidth, height: TabBarMetrics.railItemHeight)
|
|
137
137
|
.contentShape(Rectangle())
|
|
@@ -170,8 +170,7 @@ private struct DuoFloatingTabBar: View {
|
|
|
170
170
|
layout,
|
|
171
171
|
itemCount: items.count,
|
|
172
172
|
hasCta: TabBarMetrics.hasCenterAction(floatingButton, tabCount: items.count)
|
|
173
|
-
)
|
|
174
|
-
fixedFontScale: true
|
|
173
|
+
)
|
|
175
174
|
)
|
|
176
175
|
.padding(.bottom, layout.duoFloatingTabBarBottom)
|
|
177
176
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
|
|
@@ -187,7 +186,7 @@ private struct RailCenterAction: View {
|
|
|
187
186
|
SwiftUI.Button(action: data.onPress) { EmptyView() }
|
|
188
187
|
.buttonStyle(CenterActionStyle(size: TabBarMetrics.railCtaSize, vertical: true, icon: data.icon,
|
|
189
188
|
iconContent: data.iconContent, labelContent: data.labelContent,
|
|
190
|
-
label: data.label
|
|
189
|
+
label: data.label))
|
|
191
190
|
.frame(width: TabBarMetrics.railCtaWidth, height: TabBarMetrics.railCtaHeight)
|
|
192
191
|
.accessibilityLabel(data.label)
|
|
193
192
|
.accessibilityIdentifier(data.label)
|
|
@@ -23,6 +23,9 @@ enum TabBarMetrics {
|
|
|
23
23
|
// label overflows downward instead of pushing the icon up
|
|
24
24
|
static let labelHeight: CGFloat = 18
|
|
25
25
|
static let railLabelHeight: CGFloat = 14
|
|
26
|
+
// font scale cap for the whole bar (RN ScaleSizeProvider around renderTabBar): its text follows the
|
|
27
|
+
// OS/host scale up to 1.2× so the fixed-height container and the notch stay aligned
|
|
28
|
+
static let labelMaxScale: CGFloat = 1.2
|
|
26
29
|
static let indicatorRadius = Radius.XL
|
|
27
30
|
// home indicator / gesture bar area under the container
|
|
28
31
|
static let systemIndicatorHeight: CGFloat = 24
|
|
@@ -15,7 +15,8 @@ public struct FontScale: Equatable {
|
|
|
15
15
|
/// From the app window, not UIScreen.main (which stays on one display on iPhone Duo).
|
|
16
16
|
public let windowShortSide: CGFloat
|
|
17
17
|
/// Opt-in ceiling (Compose's `MiniAppContext.scaleSizeMaxRate`): caps the result at size × maxScaleRate
|
|
18
|
-
/// on both the userScaleRate and OS paths; nil means no cap.
|
|
18
|
+
/// on both the userScaleRate and OS paths; nil means no cap. Set it with `ScaleSizeScope` or
|
|
19
|
+
/// `MiniAppContext.scaleSizeMaxRate`.
|
|
19
20
|
public let maxScaleRate: CGFloat?
|
|
20
21
|
|
|
21
22
|
public init(
|
|
@@ -54,9 +55,8 @@ public struct FontScale: Equatable {
|
|
|
54
55
|
return cap(max(deviceScaled, osScaled))
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
/// A copy that caps the scale at `rate` while keeping the host/OS inputs
|
|
58
|
-
|
|
59
|
-
public func cappedAt(_ rate: CGFloat) -> FontScale {
|
|
58
|
+
/// A copy that caps the scale at `rate` (nil lifts the cap) while keeping the host/OS inputs.
|
|
59
|
+
public func cappedAt(_ rate: CGFloat?) -> FontScale {
|
|
60
60
|
FontScale(
|
|
61
61
|
userScaleRate: userScaleRate,
|
|
62
62
|
useOSScaleRate: useOSScaleRate,
|
|
@@ -74,14 +74,15 @@ public struct FontScale: Equatable {
|
|
|
74
74
|
|
|
75
75
|
/// A host-pushed mini-app context wins per field, matching Compose's
|
|
76
76
|
/// `context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate`.
|
|
77
|
-
public func overriding(userScaleRate: CGFloat?, useOSScaleRate: Bool?) -> FontScale {
|
|
78
|
-
|
|
77
|
+
public func overriding(userScaleRate: CGFloat?, useOSScaleRate: Bool?, maxScaleRate: CGFloat? = nil) -> FontScale {
|
|
78
|
+
let overridesAny = userScaleRate != nil || useOSScaleRate != nil || maxScaleRate != nil
|
|
79
|
+
guard overridesAny else { return self }
|
|
79
80
|
return FontScale(
|
|
80
81
|
userScaleRate: userScaleRate ?? self.userScaleRate,
|
|
81
82
|
useOSScaleRate: useOSScaleRate ?? self.useOSScaleRate,
|
|
82
83
|
osFontScale: osFontScale,
|
|
83
84
|
windowShortSide: windowShortSide,
|
|
84
|
-
maxScaleRate: maxScaleRate
|
|
85
|
+
maxScaleRate: maxScaleRate ?? self.maxScaleRate
|
|
85
86
|
)
|
|
86
87
|
}
|
|
87
88
|
}
|
|
@@ -120,9 +121,44 @@ private struct MomoFontScaleModifier: ViewModifier {
|
|
|
120
121
|
\.momoFontScale,
|
|
121
122
|
store.fontScale.overriding(
|
|
122
123
|
userScaleRate: context?.userScaleRate,
|
|
123
|
-
useOSScaleRate: context?.useOSScaleRate
|
|
124
|
+
useOSScaleRate: context?.useOSScaleRate,
|
|
125
|
+
maxScaleRate: context?.scaleSizeMaxRate
|
|
124
126
|
)
|
|
125
127
|
)
|
|
126
128
|
.environment(\.designSystemKitsConfigs, store.getConfigs())
|
|
127
129
|
}
|
|
128
130
|
}
|
|
131
|
+
|
|
132
|
+
/// Compose's `ScaleSizeScope` (RN `ScaleSizeProvider`): caps the font scale of `content` at
|
|
133
|
+
/// size × `scaleSizeMaxRate`; the nearest scope wins and nil lifts the cap.
|
|
134
|
+
public struct ScaleSizeScope<Content: View>: View {
|
|
135
|
+
private let scaleSizeMaxRate: CGFloat?
|
|
136
|
+
private let content: Content
|
|
137
|
+
|
|
138
|
+
public init(scaleSizeMaxRate: CGFloat? = nil, @ViewBuilder content: () -> Content) {
|
|
139
|
+
self.scaleSizeMaxRate = scaleSizeMaxRate
|
|
140
|
+
self.content = content()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public var body: some View {
|
|
144
|
+
content.scaleSizeMaxRate(scaleSizeMaxRate)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public extension View {
|
|
149
|
+
/// Modifier form of `ScaleSizeScope`.
|
|
150
|
+
func scaleSizeMaxRate(_ rate: CGFloat?) -> some View {
|
|
151
|
+
modifier(ScaleSizeMaxRateModifier(rate: rate))
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// Derives from the injected snapshot, so it stays live under `.momoFontScale()`.
|
|
156
|
+
private struct ScaleSizeMaxRateModifier: ViewModifier {
|
|
157
|
+
let rate: CGFloat?
|
|
158
|
+
|
|
159
|
+
@Environment(\.momoFontScale) private var fontScale
|
|
160
|
+
|
|
161
|
+
func body(content: Content) -> some View {
|
|
162
|
+
content.environment(\.momoFontScale, fontScale.cappedAt(rate))
|
|
163
|
+
}
|
|
164
|
+
}
|
package/ios/native-kits.podspec
CHANGED
|
@@ -39,6 +39,8 @@ private struct DemoConfig: Hashable {
|
|
|
39
39
|
var initialRouteName = "Momo"
|
|
40
40
|
var compressionBehavior: DuoBarCompressionBehavior = .toolbar
|
|
41
41
|
var backToInitialTab = true
|
|
42
|
+
// a sticky footer in the tab's content body, to check it clears the floating bar
|
|
43
|
+
var footer = false
|
|
42
44
|
|
|
43
45
|
var visibleTabs: [TabConfig] { Array(tabs.prefix(tabCount)) }
|
|
44
46
|
}
|
|
@@ -107,7 +109,10 @@ struct BottomTabDemoContent: View {
|
|
|
107
109
|
icon: tab.icon,
|
|
108
110
|
showDot: tab.showDot,
|
|
109
111
|
badgeLabel: tab.badgeLabel,
|
|
110
|
-
options: NavigationOptions(
|
|
112
|
+
options: NavigationOptions(
|
|
113
|
+
headerTitle: .default(tab.label),
|
|
114
|
+
footer: config.footer ? { AnyView(demoFooter) } : nil
|
|
115
|
+
),
|
|
111
116
|
screen: { TabContent(name: tab.name, config: $config, focused: $focused) }
|
|
112
117
|
)
|
|
113
118
|
},
|
|
@@ -124,6 +129,10 @@ struct BottomTabDemoContent: View {
|
|
|
124
129
|
.onAppear { ctaLottieLoader.load() }
|
|
125
130
|
}
|
|
126
131
|
|
|
132
|
+
private var demoFooter: some View {
|
|
133
|
+
MoMoUIKits.Button(title: "Footer trong content", action: {}, isFull: true)
|
|
134
|
+
}
|
|
135
|
+
|
|
127
136
|
private var floatingButton: BottomTabFloatingButton? {
|
|
128
137
|
guard config.special else { return nil }
|
|
129
138
|
guard config.ctaLottie else {
|
|
@@ -202,6 +211,9 @@ private struct TabContent: View {
|
|
|
202
211
|
])
|
|
203
212
|
Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
|
|
204
213
|
options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
|
|
214
|
+
Options(title: "footer",
|
|
215
|
+
hint: "Footer dính trong content body, kiểm tra nó nằm trên thanh tab nổi",
|
|
216
|
+
options: yesNo(config.footer) { config.footer = $0 })
|
|
205
217
|
}
|
|
206
218
|
|
|
207
219
|
Section(title: "Nút giữa (floatingButton)") {
|
|
@@ -39,6 +39,8 @@ struct TypographyDemo: View {
|
|
|
39
39
|
// MARK: - Preview
|
|
40
40
|
|
|
41
41
|
private struct TypographyPreview: View {
|
|
42
|
+
@Environment(\.appTheme) private var theme
|
|
43
|
+
|
|
42
44
|
var body: some View {
|
|
43
45
|
BasicColumnBox("Headers", alignment: .leading) {
|
|
44
46
|
MomoText("Headline Default Bold", typography: .headlineDefaultBold)
|
|
@@ -63,6 +65,20 @@ private struct TypographyPreview: View {
|
|
|
63
65
|
MomoText("Action XS Bold", typography: .actionXsBold)
|
|
64
66
|
MomoText("Action XXS Bold", typography: .actionXxsBold)
|
|
65
67
|
}
|
|
68
|
+
BasicColumnBox("ScaleSizeScope", alignment: .leading) {
|
|
69
|
+
MomoText(
|
|
70
|
+
"Increase the system font size to compare",
|
|
71
|
+
typography: .descriptionXsRegular,
|
|
72
|
+
color: theme.colors.text.secondary
|
|
73
|
+
)
|
|
74
|
+
MomoText("No scope", typography: .bodyDefaultRegular)
|
|
75
|
+
ScaleSizeScope(scaleSizeMaxRate: 1) {
|
|
76
|
+
MomoText("ScaleSizeScope(1)", typography: .bodyDefaultRegular)
|
|
77
|
+
}
|
|
78
|
+
ScaleSizeScope(scaleSizeMaxRate: 1.2) {
|
|
79
|
+
MomoText("ScaleSizeScope(1.2)", typography: .bodyDefaultRegular)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
66
82
|
}
|
|
67
83
|
}
|
|
68
84
|
|