@momo-kits/native-kits 0.169.3 → 0.169.4-beta.1

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.
@@ -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",
3
+ "version": "0.169.4-beta.1",
4
4
  "private": false,
5
5
  "dependeNavigationncies": {},
6
6
  "devDependencies": {},