@momo-kits/native-kits 0.169.12 → 0.169.13-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.
@@ -250,7 +250,11 @@ struct TabItemContent: View {
250
250
  }
251
251
  }
252
252
 
253
- /// Badge value shown on a tab: nil hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
253
+ /// Text badges keep 5 characters, then "..." ("Khám phá" -> "Khám...").
254
+ private let badgeMaxChars = 5
255
+
256
+ /// Badge value shown on a tab: nil hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity),
257
+ /// text keeps its first 5 characters.
254
258
  func tabBadgeLabel(_ item: BottomTabItem) -> String? {
255
259
  guard let label = item.badgeLabel else { return item.showDot ? "" : nil }
256
260
  if label.isEmpty { return "" }
@@ -259,7 +263,9 @@ func tabBadgeLabel(_ item: BottomTabItem) -> String? {
259
263
  if value == 0 { return item.showDot ? "" : nil }
260
264
  return value > 99 ? "99+" : label
261
265
  }
262
- return label
266
+ guard label.count > badgeMaxChars else { return label }
267
+ let head = String(label.prefix(badgeMaxChars))
268
+ return head.trimmingCharacters(in: .whitespaces) + "..."
263
269
  }
264
270
 
265
271
  /// 24 icon, active and inactive tints cross-faded; badges hang off it: dot at 16/-2, label badge at
@@ -314,8 +320,12 @@ private struct TabBadge: View {
314
320
  .scaleSizeMaxRate(1)
315
321
  .padding(.horizontal, Spacing.XS)
316
322
  .frame(minWidth: 16, maxWidth: TabBarMetrics.badgeMaxWidth, minHeight: 16, maxHeight: 16)
317
- .background(Capsule().fill(isNumber ? theme.colors.error.primary : theme.colors.warning.primary))
318
- .overlay(Capsule().strokeBorder(theme.colors.background.surface, lineWidth: 1))
323
+ // the ring sits under the label: an overlay stroke would paint over the text
324
+ .background(
325
+ Capsule()
326
+ .fill(isNumber ? theme.colors.error.primary : theme.colors.warning.primary)
327
+ .overlay(Capsule().strokeBorder(theme.colors.background.surface, lineWidth: 1))
328
+ )
319
329
  }
320
330
  }
321
331
 
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.169.12'
3
+ s.version = '0.169.13-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.12'
3
+ s.version = '0.169.13-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' }
@@ -89,7 +89,18 @@ private func ctaLottie(_ animation: LottieAnimation?, offset: CGFloat) -> some V
89
89
  }
90
90
  private let badges: [(String, String?)] = [
91
91
  ("Không", nil), ("Dot \"\"", ""), ("\"0\"", "0"), ("\"5\"", "5"),
92
- ("\"1999\"", "1999"), ("\"Mới\"", "Mới"), ("Chữ dài", "Khuyến mãi lớn"),
92
+ ("\"1999\"", "1999"), ("\"Mới\"", "Mới"),
93
+ ]
94
+
95
+ /// "Chữ dài" picks one of these at random on every tap.
96
+ private let longBadges = [
97
+ "Khuyến mãi lớn",
98
+ "Khám phá ngay",
99
+ "Ưu đãi cực sốc",
100
+ "Quà tặng hấp dẫn",
101
+ "Hoàn tiền mỗi ngày",
102
+ "Siêu sale cuối tuần",
103
+ "Thanh toán hóa đơn",
93
104
  ]
94
105
 
95
106
  struct BottomTabDemoContent: View {
@@ -175,10 +186,12 @@ private struct TabContent: View {
175
186
  Section(title: "Tab đang mở · \(name)") {
176
187
  IconOptions(title: "icon", icons: icons, value: tab.icon) { icon in updateTab { $0.icon = icon } }
177
188
  Options(title: "badgeLabel",
178
- hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ dài bị cắt ở 58",
189
+ hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ > 5 ký tự cắt thành 5 ký tự + \"...\"",
179
190
  options: badges.map { title, value in
180
191
  Option(title: title, selected: tab.badgeLabel == value) { updateTab { $0.badgeLabel = value } }
181
- })
192
+ } + [Option(title: "Chữ dài", selected: longBadges.contains(tab.badgeLabel ?? "")) {
193
+ updateTab { $0.badgeLabel = longBadges.randomElement() }
194
+ }])
182
195
  Options(title: "showDot",
183
196
  hint: "Hiện dot khi không có badgeLabel hoặc badgeLabel là \"0\"",
184
197
  options: yesNo(tab.showDot) { value in updateTab { $0.showDot = value } })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.169.12",
3
+ "version": "0.169.13-beta.1",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "publish:local": "bash publish.sh local"