@momo-kits/native-kits 0.168.1-beta.37-debug → 0.168.1-beta.38-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 -3
- package/compose/build.gradle.kts +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +81 -72
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +13 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +163 -54
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +12 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +34 -27
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +319 -167
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +93 -326
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +3 -2
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +3 -9
- package/ios/Input/Input.swift +1 -3
- package/ios/Input/InputTextArea.swift +1 -3
- package/ios/Layout/ScreenLayout.swift +24 -28
- package/ios/Navigation/BottomSheet.swift +157 -29
- package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
- package/ios/Navigation/BottomTab/BottomTabBar.swift +280 -132
- package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
- package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
- package/ios/Navigation/Component/HeaderRight.swift +1 -1
- package/ios/Navigation/ModalScreen.swift +7 -18
- package/ios/Navigation/StackScreen.swift +3 -1
- package/ios/Popup/PopupDisplay.swift +2 -4
- package/ios/Popup/PopupInput.swift +2 -4
- package/ios/Popup/PopupLayout.swift +9 -10
- package/ios/Popup/PopupNotify.swift +23 -26
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -103
- package/package.json +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
- package/ios/Layout/ModalLayout.swift +0 -152
- package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
|
@@ -2,77 +2,294 @@
|
|
|
2
2
|
// BottomTabDemo.swift
|
|
3
3
|
// Example
|
|
4
4
|
//
|
|
5
|
-
// Usage demo for the bottom-tab navigation
|
|
6
|
-
//
|
|
7
|
-
//
|
|
5
|
+
// Usage demo for the bottom-tab navigation, same as RN app/screens/Navigation/BottomTab and
|
|
6
|
+
// Compose's `BottomTabUsage`: the bar shows right away, every tab holds the options and each
|
|
7
|
+
// change rebuilds the bar below. Must be hosted inside a `NavigationContainer`.
|
|
8
8
|
//
|
|
9
9
|
|
|
10
|
+
import Lottie
|
|
10
11
|
import MoMoUIKits
|
|
11
12
|
import SwiftUI
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
private struct TabConfig: Hashable {
|
|
15
|
+
let name: String
|
|
16
|
+
var label: String
|
|
17
|
+
var icon: String
|
|
18
|
+
// nil = no badge, "" = dot, "0" = hidden, numbers > 99 = 99+, text = text badge
|
|
19
|
+
var badgeLabel: String?
|
|
20
|
+
var showDot = false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private struct DemoConfig: Hashable {
|
|
24
|
+
var tabs: [TabConfig] = [
|
|
25
|
+
TabConfig(name: "Momo", label: "Momo", icon: "home_momo_active"),
|
|
26
|
+
TabConfig(name: "UuDai", label: "Ưu đãi", icon: "home_promotions_active", badgeLabel: "Mới"),
|
|
27
|
+
TabConfig(name: "GiaoDich", label: "Giao dịch", icon: "home_history_active", badgeLabel: "5"),
|
|
28
|
+
TabConfig(name: "Toi", label: "Tôi", icon: "home_friends_active", badgeLabel: ""),
|
|
29
|
+
TabConfig(name: "Vi", label: "Ví", icon: "home_wallet_inactive", badgeLabel: "1999"),
|
|
30
|
+
]
|
|
31
|
+
var tabCount = 4
|
|
32
|
+
var longLabels = false
|
|
33
|
+
var special = true
|
|
34
|
+
var ctaLabel = "Quét mọi QR"
|
|
35
|
+
var ctaIcon = "momomain_scan_code"
|
|
36
|
+
// the Home Lottie, split into its button and label parts, instead of icon and label
|
|
37
|
+
var ctaLottie = false
|
|
38
|
+
var initialRouteName = "Momo"
|
|
39
|
+
var compressionBehavior: DuoBarCompressionBehavior = .toolbar
|
|
40
|
+
var backToInitialTab = true
|
|
41
|
+
|
|
42
|
+
var visibleTabs: [TabConfig] { Array(tabs.prefix(tabCount)) }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private let icons = [
|
|
46
|
+
"home_momo_active", "home_promotions_active", "home_history_active", "home_friends_active",
|
|
47
|
+
"home_wallet_inactive", "notifications_bell", "basic_setting",
|
|
48
|
+
]
|
|
49
|
+
private let ctaIcons = ["momomain_scan_code", "navigation_scan", "navigation_qrcode"]
|
|
50
|
+
// The Home "Quét mọi QR" animation in two files on a 160 canvas: pink circle 100 centered at y 70, label
|
|
51
|
+
// centered at y 138. At 77 the circle is the 48 button; the button part moves down 5 onto the button center,
|
|
52
|
+
// the label part up 28 onto the label line.
|
|
53
|
+
private let ctaLottieSize: CGFloat = 77
|
|
54
|
+
private let ctaLottieButtonOffset: CGFloat = 5
|
|
55
|
+
private let ctaLottieLabelOffset: CGFloat = 28
|
|
56
|
+
|
|
57
|
+
/// A Lottie bundled with the demo: in the app bundle (sample iosApp) or the demo pod's resource bundle.
|
|
58
|
+
private func demoLottie(_ name: String) -> LottieAnimation? {
|
|
59
|
+
let podBundle = Bundle.main.url(forResource: "MoMoUIKitsDemoResources", withExtension: "bundle").flatMap(Bundle.init(url:))
|
|
60
|
+
return LottieAnimation.named(name, bundle: .main) ?? podBundle.flatMap { LottieAnimation.named(name, bundle: $0) }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private let ctaLottieButton = demoLottie("tabbar_scan_qr_button")
|
|
64
|
+
private let ctaLottieLabel = demoLottie("tabbar_scan_qr_label")
|
|
65
|
+
|
|
66
|
+
// both parts read their progress from the same clock, two playing views start at different times
|
|
67
|
+
private func ctaLottie(_ animation: LottieAnimation?, offset: CGFloat) -> some View {
|
|
68
|
+
TimelineView(.animation) { timeline in
|
|
69
|
+
let duration = animation?.duration ?? 1
|
|
70
|
+
let elapsed = timeline.date.timeIntervalSinceReferenceDate
|
|
71
|
+
LottieView(animation: animation)
|
|
72
|
+
.currentProgress(elapsed.truncatingRemainder(dividingBy: duration) / duration)
|
|
73
|
+
.resizable()
|
|
74
|
+
.frame(width: ctaLottieSize, height: ctaLottieSize)
|
|
75
|
+
.offset(y: offset)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
private let badges: [(String, String?)] = [
|
|
79
|
+
("Không", nil), ("Dot \"\"", ""), ("\"0\"", "0"), ("\"5\"", "5"),
|
|
80
|
+
("\"1999\"", "1999"), ("\"Mới\"", "Mới"), ("Chữ dài", "Khuyến mãi lớn"),
|
|
81
|
+
]
|
|
82
|
+
|
|
14
83
|
struct BottomTabDemoContent: View {
|
|
15
|
-
@
|
|
84
|
+
@State private var config = DemoConfig()
|
|
85
|
+
// the bar is rebuilt on every change: reopen it on the tab the user is on
|
|
86
|
+
@State private var focused = DemoConfig().initialRouteName
|
|
16
87
|
|
|
17
88
|
var body: some View {
|
|
89
|
+
let tabs = config.visibleTabs
|
|
90
|
+
let initial = tabs.contains { $0.name == focused } ? focused : tabs[0].name
|
|
18
91
|
BottomTab(
|
|
19
|
-
items:
|
|
20
|
-
BottomTabItem(
|
|
21
|
-
name: "Tab1",
|
|
22
|
-
label: "Option 1",
|
|
23
|
-
icon: "16_basic_home",
|
|
24
|
-
badgeLabel: "",
|
|
25
|
-
options: NavigationOptions(headerTitle: .default("Option 1"), hiddenBack: false),
|
|
26
|
-
screen: { tabBody("Option 1", Colors.blue09) }
|
|
27
|
-
),
|
|
92
|
+
items: tabs.map { tab in
|
|
28
93
|
BottomTabItem(
|
|
29
|
-
name:
|
|
30
|
-
label: "
|
|
31
|
-
icon:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
BottomTabItem(
|
|
37
|
-
name: "Tab3",
|
|
38
|
-
label: "Option 3 with a very long label",
|
|
39
|
-
icon: "pin_star",
|
|
40
|
-
badgeLabel: "New",
|
|
41
|
-
options: NavigationOptions(headerTitle: .default("Option 3")),
|
|
42
|
-
screen: { tabBody("Option 3", Colors.yellow09) }
|
|
43
|
-
),
|
|
44
|
-
BottomTabItem(
|
|
45
|
-
name: "Tab4",
|
|
46
|
-
label: "Option 4 also quite long here",
|
|
47
|
-
icon: "navigation_more_icon",
|
|
48
|
-
badgeLabel: "9999",
|
|
49
|
-
options: NavigationOptions(headerTitle: .default("Option 4")),
|
|
50
|
-
screen: { tabBody("Option 4", Colors.blue10) }
|
|
94
|
+
name: tab.name,
|
|
95
|
+
label: config.longLabels ? "\(tab.label) dài quá" : tab.label,
|
|
96
|
+
icon: tab.icon,
|
|
97
|
+
showDot: tab.showDot,
|
|
98
|
+
badgeLabel: tab.badgeLabel,
|
|
99
|
+
options: NavigationOptions(headerTitle: .default(tab.label)),
|
|
100
|
+
screen: { TabContent(name: tab.name, config: $config, focused: $focused) }
|
|
51
101
|
)
|
|
52
|
-
|
|
53
|
-
floatingButton:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
102
|
+
},
|
|
103
|
+
floatingButton: floatingButton,
|
|
104
|
+
compressionBehavior: config.compressionBehavior,
|
|
105
|
+
initialRouteName: initial,
|
|
106
|
+
onTabPress: { index, switchTab in
|
|
107
|
+
focused = tabs[index].name
|
|
108
|
+
switchTab()
|
|
109
|
+
},
|
|
110
|
+
backToInitialTab: config.backToInitialTab
|
|
58
111
|
)
|
|
112
|
+
.id(config)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private var floatingButton: BottomTabFloatingButton? {
|
|
116
|
+
guard config.special else { return nil }
|
|
117
|
+
guard config.ctaLottie else {
|
|
118
|
+
return BottomTabFloatingButton(icon: config.ctaIcon, label: config.ctaLabel, onPress: {})
|
|
119
|
+
}
|
|
120
|
+
return BottomTabFloatingButton(
|
|
121
|
+
label: config.ctaLabel,
|
|
122
|
+
onPress: {},
|
|
123
|
+
iconContent: { ctaLottie(ctaLottieButton, offset: ctaLottieButtonOffset) },
|
|
124
|
+
labelContent: { ctaLottie(ctaLottieLabel, offset: -ctaLottieLabelOffset) }
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// Content of every tab: this tab's own props, the bar props, then the center action. The tab's
|
|
130
|
+
/// StackScreen scrolls it under the floating bar and keeps its end clear of it.
|
|
131
|
+
private struct TabContent: View {
|
|
132
|
+
let name: String
|
|
133
|
+
@Binding var config: DemoConfig
|
|
134
|
+
@Binding var focused: String
|
|
135
|
+
|
|
136
|
+
private var tab: TabConfig { config.tabs.first { $0.name == name }! }
|
|
137
|
+
|
|
138
|
+
private func updateTab(_ change: (inout TabConfig) -> Void) {
|
|
139
|
+
guard let index = config.tabs.firstIndex(where: { $0.name == name }) else { return }
|
|
140
|
+
change(&config.tabs[index])
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private func yesNo(_ value: Bool, _ onChange: @escaping (Bool) -> Void) -> [Option] {
|
|
144
|
+
[Option(title: "Có", selected: value) { onChange(true) },
|
|
145
|
+
Option(title: "Không", selected: !value) { onChange(false) }]
|
|
59
146
|
}
|
|
60
147
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
VStack {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
148
|
+
var body: some View {
|
|
149
|
+
let ctaHidden = config.special && config.tabCount % 2 != 0
|
|
150
|
+
VStack(alignment: .leading, spacing: Spacing.M) {
|
|
151
|
+
MomoText("Chạm các tab bên dưới để xem indicator chạy qua lại. Mỗi thay đổi áp dụng ngay lên thanh tab.",
|
|
152
|
+
typography: .bodyDefaultRegular)
|
|
153
|
+
|
|
154
|
+
Section(title: "Tab đang mở · \(name)") {
|
|
155
|
+
IconOptions(title: "icon", icons: icons, value: tab.icon) { icon in updateTab { $0.icon = icon } }
|
|
156
|
+
Options(title: "badgeLabel",
|
|
157
|
+
hint: "\"\" là dot, \"0\" ẩn badge, số > 99 hiện 99+, chữ dài bị cắt ở 58",
|
|
158
|
+
options: badges.map { title, value in
|
|
159
|
+
Option(title: title, selected: tab.badgeLabel == value) { updateTab { $0.badgeLabel = value } }
|
|
160
|
+
})
|
|
161
|
+
Options(title: "showDot",
|
|
162
|
+
hint: "Hiện dot khi không có badgeLabel hoặc badgeLabel là \"0\"",
|
|
163
|
+
options: yesNo(tab.showDot) { value in updateTab { $0.showDot = value } })
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
Section(title: "Thanh tab") {
|
|
167
|
+
Options(title: "Số tab (items)", options: (2...5).map { count in
|
|
168
|
+
Option(title: "\(count)", selected: config.tabCount == count) { config.tabCount = count }
|
|
169
|
+
})
|
|
170
|
+
Options(title: "label", options: [
|
|
171
|
+
Option(title: "Ngắn", selected: !config.longLabels) { config.longLabels = false },
|
|
172
|
+
Option(title: "Dài", selected: config.longLabels) { config.longLabels = true },
|
|
173
|
+
])
|
|
174
|
+
Options(title: "initialRouteName", hint: "Tab được chọn khi BottomTab mở",
|
|
175
|
+
options: config.visibleTabs.map { item in
|
|
176
|
+
Option(title: item.name, selected: config.initialRouteName == item.name) {
|
|
177
|
+
focused = item.name
|
|
178
|
+
config.initialRouteName = item.name
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
Options(title: "compressionBehavior",
|
|
182
|
+
hint: "iPhone Duo: bar nào thu gọn trước khi side bar không đủ chỗ",
|
|
183
|
+
options: [
|
|
184
|
+
Option(title: "toolbar", selected: config.compressionBehavior == .toolbar) {
|
|
185
|
+
config.compressionBehavior = .toolbar
|
|
186
|
+
},
|
|
187
|
+
Option(title: "tabBar", selected: config.compressionBehavior == .tabBar) {
|
|
188
|
+
config.compressionBehavior = .tabBar
|
|
189
|
+
},
|
|
190
|
+
])
|
|
191
|
+
Options(title: "backToInitialTab", hint: "Back ở tab khác quay về tab đầu trước khi rời màn",
|
|
192
|
+
options: yesNo(config.backToInitialTab) { config.backToInitialTab = $0 })
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
Section(title: "Nút giữa (floatingButton)") {
|
|
196
|
+
Options(title: "floatingButton",
|
|
197
|
+
hint: ctaHidden
|
|
198
|
+
? "Đang ẩn: nút giữa chỉ hiện khi có 2 hoặc 4 tab"
|
|
199
|
+
: "Có = Special (nút giữa trong notch), Không = Default",
|
|
200
|
+
options: yesNo(config.special) { config.special = $0 })
|
|
201
|
+
if config.special {
|
|
202
|
+
Options(title: "label", options: ["Quét mọi QR", "Quét mã thanh toán"].map { label in
|
|
203
|
+
Option(title: label, selected: config.ctaLabel == label) { config.ctaLabel = label }
|
|
204
|
+
})
|
|
205
|
+
Options(title: "icon dạng", hint: "Lottie: animation Quét mọi QR của Home, 2 phần nút và chữ", options: [
|
|
206
|
+
Option(title: "Icon", selected: !config.ctaLottie) { config.ctaLottie = false },
|
|
207
|
+
Option(title: "Lottie", selected: config.ctaLottie) { config.ctaLottie = true },
|
|
208
|
+
])
|
|
209
|
+
if !config.ctaLottie {
|
|
210
|
+
IconOptions(title: "icon", icons: ctaIcons, value: config.ctaIcon) { config.ctaIcon = $0 }
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
MoMoUIKits.Button(title: "Khôi phục mặc định", action: { config = DemoConfig() }, type: .outline)
|
|
216
|
+
}
|
|
217
|
+
.padding(Spacing.M)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private struct Option: Identifiable {
|
|
222
|
+
var id: String { title }
|
|
223
|
+
let title: String
|
|
224
|
+
let selected: Bool
|
|
225
|
+
let onPress: () -> Void
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private struct Section<Content: View>: View {
|
|
229
|
+
let title: String
|
|
230
|
+
@ViewBuilder let content: () -> Content
|
|
231
|
+
|
|
232
|
+
@Environment(\.appTheme) private var theme
|
|
233
|
+
|
|
234
|
+
var body: some View {
|
|
235
|
+
VStack(alignment: .leading, spacing: Spacing.M) {
|
|
236
|
+
MomoText(title, typography: .headerSSemibold)
|
|
237
|
+
content()
|
|
67
238
|
}
|
|
68
|
-
.
|
|
69
|
-
.
|
|
239
|
+
.padding(Spacing.M)
|
|
240
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
241
|
+
.background(RoundedRectangle(cornerRadius: Radius.M).fill(theme.colors.background.surface))
|
|
70
242
|
}
|
|
243
|
+
}
|
|
71
244
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
245
|
+
private struct Options: View {
|
|
246
|
+
let title: String
|
|
247
|
+
var hint: String? = nil
|
|
248
|
+
let options: [Option]
|
|
249
|
+
|
|
250
|
+
var body: some View {
|
|
251
|
+
VStack(alignment: .leading, spacing: Spacing.XS) {
|
|
252
|
+
MomoText(title, typography: .labelDefaultMedium)
|
|
253
|
+
if let hint {
|
|
254
|
+
MomoText(hint, typography: .descriptionXsRegular)
|
|
255
|
+
}
|
|
256
|
+
LazyVGrid(columns: [GridItem(.adaptive(minimum: 88), spacing: Spacing.S, alignment: .leading)],
|
|
257
|
+
alignment: .leading, spacing: Spacing.S) {
|
|
258
|
+
ForEach(options) { option in
|
|
259
|
+
MoMoUIKits.Button(title: option.title, action: option.onPress,
|
|
260
|
+
type: option.selected ? .primary : .outline, size: .small, isFull: false)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private struct IconOptions: View {
|
|
268
|
+
let title: String
|
|
269
|
+
let icons: [String]
|
|
270
|
+
let value: String
|
|
271
|
+
let onChange: (String) -> Void
|
|
272
|
+
|
|
273
|
+
@Environment(\.appTheme) private var theme
|
|
274
|
+
|
|
275
|
+
var body: some View {
|
|
276
|
+
VStack(alignment: .leading, spacing: Spacing.XS) {
|
|
277
|
+
MomoText(title, typography: .labelDefaultMedium)
|
|
278
|
+
HStack(spacing: Spacing.S) {
|
|
279
|
+
ForEach(icons, id: \.self) { icon in
|
|
280
|
+
let selected = icon == value
|
|
281
|
+
SwiftUI.Button { onChange(icon) } label: {
|
|
282
|
+
Icon(source: icon, size: 24, color: selected ? theme.colors.primary : theme.colors.text.default)
|
|
283
|
+
.frame(width: 40, height: 40)
|
|
284
|
+
.overlay(
|
|
285
|
+
RoundedRectangle(cornerRadius: Radius.S)
|
|
286
|
+
.stroke(selected ? theme.colors.primary : theme.colors.border.default, lineWidth: 1)
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
.buttonStyle(.plain)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
76
293
|
}
|
|
77
294
|
}
|
|
78
295
|
|
|
@@ -80,10 +297,6 @@ struct BottomTabDemoContent: View {
|
|
|
80
297
|
|
|
81
298
|
struct BottomTabDemo: View {
|
|
82
299
|
var body: some View {
|
|
83
|
-
|
|
84
|
-
BottomTabDemoContent()
|
|
85
|
-
} else {
|
|
86
|
-
Text("Bottom tab demo requires iOS 16+").padding()
|
|
87
|
-
}
|
|
300
|
+
BottomTabDemoContent()
|
|
88
301
|
}
|
|
89
302
|
}
|
|
@@ -202,13 +202,6 @@ private struct NavigationDemoContent: View {
|
|
|
202
202
|
)
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
row("Header Types") {
|
|
206
|
-
navigator.push(
|
|
207
|
-
{ HeaderTypesScreen() },
|
|
208
|
-
options: NavigationOptions(title: "Header Types")
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
205
|
row("Bottom Tabs") {
|
|
213
206
|
navigator.push(
|
|
214
207
|
{ BottomTabDemoContent() },
|
|
@@ -260,102 +253,6 @@ private struct UpdateOptionsScreen: View {
|
|
|
260
253
|
}
|
|
261
254
|
}
|
|
262
255
|
|
|
263
|
-
/// Header options switched at runtime (Compose `HeaderTypeUsage`).
|
|
264
|
-
@available(iOS 16.0, *)
|
|
265
|
-
private struct HeaderTypesScreen: View {
|
|
266
|
-
private enum Kind: String, CaseIterable {
|
|
267
|
-
case none = "None", `default` = "Default", extended = "Extended", transparent = "Transparent"
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
private enum HeaderRightOption: String, CaseIterable {
|
|
271
|
-
case toolkit = "Toolkit", homeOnly = "Home only", none = "None"
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
@EnvironmentObject private var navigation: Navigation
|
|
275
|
-
@Environment(\.applicationEnvironment) private var applicationEnvironment
|
|
276
|
-
@State private var kind: AnyHashable = Kind.default
|
|
277
|
-
@State private var titlePosition: AnyHashable = TitlePosition.left
|
|
278
|
-
@State private var showBack = true
|
|
279
|
-
@State private var headerRight: AnyHashable = HeaderRightOption.toolkit
|
|
280
|
-
@State private var isAnimated = false
|
|
281
|
-
@State private var isHeader = false
|
|
282
|
-
@State private var isFullScreenContent = false
|
|
283
|
-
@State private var searchText = ""
|
|
284
|
-
|
|
285
|
-
var body: some View {
|
|
286
|
-
VStack(alignment: .leading, spacing: Spacing.M) {
|
|
287
|
-
ForEach(Kind.allCases, id: \.self) { item in
|
|
288
|
-
Radio(value: item, groupValue: $kind, onChange: applyHeader, label: item.rawValue)
|
|
289
|
-
}
|
|
290
|
-
Divider()
|
|
291
|
-
MomoText("Title Position")
|
|
292
|
-
ForEach([TitlePosition.left, TitlePosition.center], id: \.self) { position in
|
|
293
|
-
Radio(value: position, groupValue: $titlePosition, onChange: {
|
|
294
|
-
navigation.setOptions { $0.titlePosition = position }
|
|
295
|
-
}, label: position == .left ? "LEFT" : "CENTER")
|
|
296
|
-
}
|
|
297
|
-
Divider()
|
|
298
|
-
Checkbox($showBack, onChange: { checked in
|
|
299
|
-
navigation.setOptions { $0.hiddenBack = !checked }
|
|
300
|
-
}, title: "Show Back")
|
|
301
|
-
MomoText("Header Right")
|
|
302
|
-
ForEach(HeaderRightOption.allCases, id: \.self) { option in
|
|
303
|
-
Radio(value: option, groupValue: $headerRight, onChange: { applyHeaderRight(option) }, label: option.rawValue)
|
|
304
|
-
}
|
|
305
|
-
Divider()
|
|
306
|
-
Checkbox($isAnimated, onChange: { checked in
|
|
307
|
-
if checked { isHeader = false }
|
|
308
|
-
applyHeader()
|
|
309
|
-
}, title: "Search Animated")
|
|
310
|
-
Checkbox($isHeader, onChange: { checked in
|
|
311
|
-
if checked { isAnimated = false }
|
|
312
|
-
applyHeader()
|
|
313
|
-
}, title: "Search Header")
|
|
314
|
-
if kind == AnyHashable(Kind.transparent) {
|
|
315
|
-
Checkbox($isFullScreenContent, onChange: { _ in applyHeader() }, title: "Is Full Screen Content")
|
|
316
|
-
}
|
|
317
|
-
Color.clear.frame(height: 1600)
|
|
318
|
-
}
|
|
319
|
-
.padding(Spacing.M)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
private func applyHeaderRight(_ option: HeaderRightOption) {
|
|
323
|
-
let maxApi = applicationEnvironment.maxApi
|
|
324
|
-
navigation.setOptions {
|
|
325
|
-
$0.headerRightData = option == .toolkit ? HeaderRightData() : nil
|
|
326
|
-
$0.headerRight = option == .homeOnly ? {
|
|
327
|
-
NavigationButton(icon: "16_basic_home") { maxApi?.dismissAll(completion: nil) }
|
|
328
|
-
} : nil
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
private func applyHeader() {
|
|
333
|
-
let selected = kind.base as? Kind ?? .default
|
|
334
|
-
var search: InputSearchProps?
|
|
335
|
-
if isAnimated {
|
|
336
|
-
search = InputSearchProps(text: $searchText, placeholder: "Search input")
|
|
337
|
-
} else if isHeader {
|
|
338
|
-
search = InputSearchProps(text: $searchText, buttonText: "Huỷ", showButtonText: true, placeholder: "Search input")
|
|
339
|
-
}
|
|
340
|
-
navigation.setOptions {
|
|
341
|
-
switch selected {
|
|
342
|
-
case .none:
|
|
343
|
-
$0.headerType = .none
|
|
344
|
-
case .default, .extended:
|
|
345
|
-
$0.headerType = selected == .default ? .default : .extended
|
|
346
|
-
$0.useAnimated = isAnimated
|
|
347
|
-
$0.inputSearchProps = search
|
|
348
|
-
case .transparent:
|
|
349
|
-
$0.headerType = .default
|
|
350
|
-
$0.useAnimated = false
|
|
351
|
-
$0.inputSearchProps = nil
|
|
352
|
-
}
|
|
353
|
-
$0.headerTransparent = selected == .transparent
|
|
354
|
-
$0.fullScreenContent = selected == .transparent && isFullScreenContent
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
256
|
@available(iOS 16.0, *)
|
|
360
257
|
private struct DemoLeafScreen: View {
|
|
361
258
|
@EnvironmentObject private var navigator: Navigator
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.platform
|
|
2
|
-
|
|
3
|
-
import android.provider.Settings
|
|
4
|
-
import androidx.compose.runtime.Composable
|
|
5
|
-
import androidx.compose.runtime.remember
|
|
6
|
-
import androidx.compose.ui.platform.LocalConfiguration
|
|
7
|
-
import androidx.compose.ui.platform.LocalContext
|
|
8
|
-
|
|
9
|
-
@Composable
|
|
10
|
-
actual fun rememberReduceMotion(): Boolean {
|
|
11
|
-
val context = LocalContext.current
|
|
12
|
-
// re-read on configuration changes; the setting has no observer of its own
|
|
13
|
-
val configuration = LocalConfiguration.current
|
|
14
|
-
return remember(context, configuration) {
|
|
15
|
-
Settings.Global.getFloat(context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) == 0f
|
|
16
|
-
}
|
|
17
|
-
}
|