@momo-kits/native-kits 0.169.3-debug → 0.169.4-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.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.169.3-debug"
43
+ version = "0.169.4-beta.1-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.169.3-debug'
3
+ spec.version = '0.169.4-beta.1-debug'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -21,11 +21,15 @@ const val MAX_DEVICE_SCALE = 5
21
21
  @Composable
22
22
  fun scaleSize(size: Float): Float {
23
23
  val context = LocalContext.current
24
+ // opt-in ceiling: when context.scaleSizeMaxRate is set, the result never exceeds size × capRate,
25
+ // in both the userScaleRate path and the OS path. Null keeps the old behavior.
26
+ val capRate = context?.scaleSizeMaxRate
27
+ fun cap(scaled: Float): Float = if (capRate != null) min(scaled, size * capRate) else scaled
24
28
  val useOsScale = context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate
25
29
  if (!useOsScale) {
26
- return size * (context?.userScaleRate ?: DesignSystemKits.getConfigs().userScaleRate)
30
+ return cap(size * (context?.userScaleRate ?: DesignSystemKits.getConfigs().userScaleRate))
27
31
  }
28
- val scaleSizeMaxRate: Float = MAX_FONT_SCALE
32
+ val scaleSizeMaxRate: Float = capRate ?: MAX_FONT_SCALE
29
33
  // Short side, not width: landscape must not inflate every font.
30
34
  val deviceWidth = getScreenDimensions().let { minOf(it.width, it.height) }
31
35
  val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
@@ -45,9 +49,11 @@ fun scaleSize(size: Float): Float {
45
49
  fontSizeScaleOS = min(fontScale * fontSizeScaleOS, fontSizeScaleOS * scaleSizeMaxRate)
46
50
  }
47
51
 
48
- return max(
49
- fontSizeScaleDevice,
50
- fontSizeScaleOS
52
+ return cap(
53
+ max(
54
+ fontSizeScaleDevice,
55
+ fontSizeScaleOS
56
+ )
51
57
  )
52
58
  }
53
59
 
@@ -69,6 +69,7 @@ internal fun BottomTabBar(
69
69
  floatingButton = floatingButton,
70
70
  selectedIndex = selectedIndex,
71
71
  onTabSelected = onTabSelected,
72
+ fixedFontScale = true,
72
73
  modifier = Modifier
73
74
  .offset(x = (layout.insetLeft - layout.insetRight) / 2)
74
75
  .width(horizontalBarWidth(layout.width, layout.height, layout.insetLeft, layout.insetRight)),
@@ -226,10 +227,19 @@ internal fun ColumnScope.TabItemContent(
226
227
  textAlign = TextAlign.Center,
227
228
  maxLines = 1,
228
229
  overflow = TextOverflow.Ellipsis,
229
- modifier = if (vertical) Modifier else Modifier.fillMaxWidth(),
230
+ modifier = (if (vertical) Modifier else Modifier.fillMaxWidth())
231
+ .wrapContentHeight(Alignment.Top, unbounded = true),
230
232
  )
231
233
  }
232
- if (fixedFontScale) FixedFontScale(label) else label()
234
+ // fixed slot so a capped-scale label overflows downward and the icon above it stays put
235
+ Box(
236
+ modifier = Modifier.height(
237
+ if (vertical) TabBarMetrics.railLabelHeight else TabBarMetrics.labelHeight
238
+ ),
239
+ contentAlignment = Alignment.TopCenter,
240
+ ) {
241
+ if (fixedFontScale) CappedFontScale(label) else label()
242
+ }
233
243
  }
234
244
  }
235
245
 
@@ -243,6 +253,21 @@ internal fun FixedFontScale(content: @Composable () -> Unit) {
243
253
  CompositionLocalProvider(LocalContext provides fixedScale, content = content)
244
254
  }
245
255
 
256
+ // Tab labels follow the OS/host font scale but never grow past this, so the fixed-height container
257
+ // and the notch stay aligned.
258
+ private const val TAB_LABEL_MAX_SCALE = 1.2f
259
+
260
+ // Caps the label scale at TAB_LABEL_MAX_SCALE: it keeps following the host/OS font scale but stops
261
+ // growing past 1.2× so it fits the fixed bar geometry.
262
+ @Composable
263
+ internal fun CappedFontScale(content: @Composable () -> Unit) {
264
+ val context = LocalContext.current
265
+ val capped = remember(context) {
266
+ (context ?: MiniAppContext()).copy(scaleSizeMaxRate = TAB_LABEL_MAX_SCALE)
267
+ }
268
+ CompositionLocalProvider(LocalContext provides capped, content = content)
269
+ }
270
+
246
271
  // Badge value shown on a tab: null hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
247
272
  internal fun tabBadgeLabel(item: BottomTabItem): String? {
248
273
  val label = item.badgeLabel ?: return if (item.showDot) "" else null
@@ -359,7 +384,7 @@ internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?
359
384
  .padding(horizontal = if (vertical) Spacing.XS else Spacing.XXS),
360
385
  contentAlignment = Alignment.Center,
361
386
  ) {
362
- if (fixedFontScale) FixedFontScale(text) else text()
387
+ if (fixedFontScale) CappedFontScale(text) else text()
363
388
  overlay?.let {
364
389
  Box(Modifier.matchParentSize().wrapContentSize(Alignment.Center, unbounded = true)) { it() }
365
390
  }
@@ -22,6 +22,10 @@ internal object TabBarMetrics {
22
22
  val itemGap = Spacing.XS
23
23
  val iconSize = 24.dp
24
24
  val indicatorHeight = 32.dp
25
+ // label_s_medium / label_xs_medium line heights: the label slot keeps this height so a scaled
26
+ // label overflows downward instead of pushing the icon up
27
+ val labelHeight = 18.dp
28
+ val railLabelHeight = 14.dp
25
29
  // active indicator behind the icon: 24 icon + XS·M padding
26
30
  val indicatorPaddingHorizontal = Spacing.M
27
31
  val indicatorRadius = Radius.XL
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.3
21
+ version=0.169.4-beta.1
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
@@ -96,7 +96,8 @@ struct BottomTabBar: View {
96
96
  floatingButton: floatingButton,
97
97
  selectedIndex: selectedIndex,
98
98
  onTabSelected: onTabSelected,
99
- width: TabBarMetrics.horizontalBarWidth(layout)
99
+ width: TabBarMetrics.horizontalBarWidth(layout),
100
+ fixedFontScale: true
100
101
  )
101
102
  .padding(.bottom, TabBarMetrics.bottomGap(bottomInset))
102
103
  .frame(maxWidth: .infinity)
@@ -203,14 +204,19 @@ struct ActiveIndicator: View {
203
204
  }
204
205
  }
205
206
 
206
- /// Like the system tab bar, text keeps its design size instead of growing with the wide Duo displays.
207
- struct FixedFontScale: ViewModifier {
207
+ /// Tab labels follow the host/OS font scale but never grow past this, so the fixed-height container
208
+ /// and the notch stay aligned.
209
+ private let tabLabelMaxScale: CGFloat = 1.2
210
+
211
+ /// Caps the label scale at `tabLabelMaxScale` (Compose's `CappedFontScale`): it keeps following the
212
+ /// host/OS font scale but stops growing past 1.2× so it fits the fixed bar geometry.
213
+ struct CappedFontScale: ViewModifier {
208
214
  let enabled: Bool
209
215
 
210
216
  @Environment(\.momoFontScale) private var fontScale
211
217
 
212
218
  func body(content: Content) -> some View {
213
- content.environment(\.momoFontScale, enabled ? FontScale(userScaleRate: 1, useOSScaleRate: false) : fontScale)
219
+ content.environment(\.momoFontScale, enabled ? fontScale.cappedAt(tabLabelMaxScale) : fontScale)
214
220
  }
215
221
  }
216
222
 
@@ -237,7 +243,13 @@ struct TabItemContent: View {
237
243
  }
238
244
  .animation(TabBarMetrics.tintMotion, value: selected)
239
245
  .frame(maxWidth: vertical ? nil : .infinity)
240
- label.modifier(FixedFontScale(enabled: fixedFontScale))
246
+ // fixed slot so a capped-scale label overflows downward and the icon above it stays put
247
+ label
248
+ .modifier(CappedFontScale(enabled: fixedFontScale))
249
+ .frame(
250
+ height: vertical ? TabBarMetrics.railLabelHeight : TabBarMetrics.labelHeight,
251
+ alignment: .top
252
+ )
241
253
  }
242
254
  }
243
255
 
@@ -364,7 +376,7 @@ struct CenterActionStyle: ButtonStyle {
364
376
  maxLines: 1
365
377
  )
366
378
  .truncationMode(.tail)
367
- .modifier(FixedFontScale(enabled: fixedFontScale))
379
+ .modifier(CappedFontScale(enabled: fixedFontScale))
368
380
  .padding(.horizontal, vertical ? Spacing.XS : Spacing.XXS)
369
381
  .frame(minHeight: vertical ? nil : TabBarMetrics.ctaLabelHeight)
370
382
  .overlay(labelContent?.allowsHitTesting(false))
@@ -18,6 +18,10 @@ enum TabBarMetrics {
18
18
  static let itemGap = Spacing.XS
19
19
  static let iconSize: CGFloat = 24
20
20
  static let indicatorHeight: CGFloat = 32
21
+ // label_s_medium / label_xs_medium line heights: the label slot keeps this height so a scaled
22
+ // label overflows downward instead of pushing the icon up
23
+ static let labelHeight: CGFloat = 18
24
+ static let railLabelHeight: CGFloat = 14
21
25
  static let indicatorRadius = Radius.XL
22
26
  // home indicator / gesture bar area under the container
23
27
  static let systemIndicatorHeight: CGFloat = 24
@@ -21,22 +21,32 @@ public struct FontScale: Equatable {
21
21
  public let osFontScale: CGFloat
22
22
  // AI-GENERATED START: device scale from the app window, not UIScreen.main (fixed to one display on iPhone Duo)
23
23
  public let windowShortSide: CGFloat
24
+ /// Opt-in ceiling (Compose's `MiniAppContext.scaleSizeMaxRate`): when set, the result never
25
+ /// exceeds size × maxScaleRate, in both the userScaleRate path and the OS path. nil keeps the
26
+ /// old behavior. Used by `CappedFontScale` for the bottom-tab labels.
27
+ public let maxScaleRate: CGFloat?
24
28
 
25
29
  public init(
26
30
  userScaleRate: CGFloat = 1,
27
31
  useOSScaleRate: Bool = true,
28
32
  osFontScale: CGFloat = 1,
29
- windowShortSide: CGFloat? = nil
33
+ windowShortSide: CGFloat? = nil,
34
+ maxScaleRate: CGFloat? = nil
30
35
  ) {
31
36
  self.userScaleRate = userScaleRate
32
37
  self.useOSScaleRate = useOSScaleRate
33
38
  self.osFontScale = osFontScale
34
39
  self.windowShortSide = windowShortSide ?? DesignSystemKits.currentWindowShortSide()
40
+ self.maxScaleRate = maxScaleRate
35
41
  }
36
42
 
37
43
  /// `callAsFunction` so call sites keep reading like Compose's `scaleSize(16)`.
38
44
  public func callAsFunction(_ size: CGFloat) -> CGFloat {
39
- guard useOSScaleRate else { return size * userScaleRate }
45
+ func cap(_ scaled: CGFloat) -> CGFloat {
46
+ guard let maxScaleRate else { return scaled }
47
+ return min(scaled, size * maxScaleRate)
48
+ }
49
+ guard useOSScaleRate else { return cap(size * userScaleRate) }
40
50
 
41
51
  // Short side, not width: landscape must not inflate every font (and so every popup's height).
42
52
  let deviceScale = windowShortSide / Self.defaultScreenSize
@@ -48,9 +58,21 @@ public struct FontScale: Equatable {
48
58
  deviceScaled = min(size * deviceScale, size + Self.maxDeviceScale)
49
59
  }
50
60
  if osFontScale > 1 {
51
- osScaled = min(size * osFontScale, size * Self.maxFontScale)
61
+ osScaled = min(size * osFontScale, size * (maxScaleRate ?? Self.maxFontScale))
52
62
  }
53
- return max(deviceScaled, osScaled)
63
+ return cap(max(deviceScaled, osScaled))
64
+ }
65
+
66
+ /// A copy that caps the scale at `rate` while keeping the host/OS inputs — the SwiftUI mirror of
67
+ /// Compose's `CappedFontScale` wrapper.
68
+ public func cappedAt(_ rate: CGFloat) -> FontScale {
69
+ FontScale(
70
+ userScaleRate: userScaleRate,
71
+ useOSScaleRate: useOSScaleRate,
72
+ osFontScale: osFontScale,
73
+ windowShortSide: windowShortSide,
74
+ maxScaleRate: rate
75
+ )
54
76
  }
55
77
 
56
78
  /// `.system(size:)` is a fixed-size font — SwiftUI does not Dynamic-Type it — so the scale has to
@@ -68,8 +90,9 @@ public struct FontScale: Equatable {
68
90
  useOSScaleRate: useOSScaleRate ?? self.useOSScaleRate,
69
91
  osFontScale: osFontScale,
70
92
  // AI-GENERATED START: keep the window size through context overrides
71
- windowShortSide: windowShortSide
93
+ windowShortSide: windowShortSide,
72
94
  // AI-GENERATED END: keep the window size through context overrides
95
+ maxScaleRate: maxScaleRate
73
96
  )
74
97
  }
75
98
  }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.169.3'
3
+ s.version = '0.169.4-beta.1'
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.3'
3
+ s.version = '0.169.4-beta.1'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.169.3-debug",
3
+ "version": "0.169.4-beta.1-debug",
4
4
  "private": false,
5
5
  "dependeNavigationncies": {},
6
6
  "devDependencies": {},