@momo-kits/native-kits 0.169.12-beta.1 → 0.169.12-beta.2
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.
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
/// Stretch frame on hold until design confirms it: `.stretch` lays out like `.grid`.
|
|
7
|
-
private let isStretchFrameEnabled = false
|
|
8
|
-
|
|
9
6
|
/// Header spec values, in points. Public so custom header rights and extensions can match them.
|
|
10
7
|
public enum HeaderLayoutMetrics {
|
|
11
8
|
public static let buttonSize: CGFloat = 32
|
|
@@ -26,7 +23,6 @@ public enum ContentLayout: Equatable {
|
|
|
26
23
|
/// 12 column grid: the header keeps the 12pt side padding.
|
|
27
24
|
case grid
|
|
28
25
|
/// One column of at most `HeaderLayoutMetrics.frameMaxWidth`, centered: the header row sits in the same frame.
|
|
29
|
-
/// On hold: same as `.grid` for now.
|
|
30
26
|
case stretch
|
|
31
27
|
}
|
|
32
28
|
|
|
@@ -47,8 +43,7 @@ public extension ScreenLayout {
|
|
|
47
43
|
let isLargeWindow = min(width, height) >= ModalMetrics.foldableMinWidth
|
|
48
44
|
let isWide = !isIPhoneDuo && !isDuoDevice && isLargeWindow
|
|
49
45
|
let safeWidth = width - insets.leading - insets.trailing
|
|
50
|
-
let
|
|
51
|
-
let frameInset = isWide && isStretch
|
|
46
|
+
let frameInset = isWide && contentLayout == .stretch
|
|
52
47
|
? max(HeaderLayoutMetrics.sidePadding, (safeWidth - HeaderLayoutMetrics.frameMaxWidth) / 2)
|
|
53
48
|
: HeaderLayoutMetrics.sidePadding
|
|
54
49
|
return HeaderLayout(
|
|
@@ -250,7 +250,11 @@ struct TabItemContent: View {
|
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
///
|
|
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
|
-
|
|
318
|
-
.
|
|
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
|
|
package/ios/native-kits.podspec
CHANGED
|
@@ -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"),
|
|
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ữ
|
|
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 } })
|