@momo-kits/native-kits 0.168.1-beta.38-debug → 0.168.1-beta.39-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 +3 -2
- package/compose/build.gradle.kts +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +72 -81
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +8 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +54 -163
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +17 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +2 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +9 -3
- package/ios/Input/Input.swift +3 -1
- package/ios/Input/InputTextArea.swift +3 -1
- package/ios/Layout/ModalLayout.swift +152 -0
- package/ios/Layout/ScreenLayout.swift +28 -24
- package/ios/Navigation/BottomSheet.swift +29 -157
- package/ios/Navigation/Component/HeaderRight.swift +1 -1
- package/ios/Navigation/ModalScreen.swift +18 -7
- package/ios/Popup/PopupDisplay.swift +4 -2
- package/ios/Popup/PopupInput.swift +4 -2
- package/ios/Popup/PopupLayout.swift +10 -9
- package/ios/Popup/PopupNotify.swift +26 -23
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
- package/package.json +1 -1
|
@@ -29,6 +29,7 @@ public struct PopupInput: View {
|
|
|
29
29
|
VStack {
|
|
30
30
|
VStack(alignment: .leading) {
|
|
31
31
|
MomoText(title, typography: .headerDefaultBold)
|
|
32
|
+
.padding(.trailing, ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL)
|
|
32
33
|
.padding(.top, 12)
|
|
33
34
|
.padding(.bottom, 24)
|
|
34
35
|
|
|
@@ -55,8 +56,9 @@ public struct PopupInput: View {
|
|
|
55
56
|
|
|
56
57
|
}.clipped()
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
.
|
|
59
|
+
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onPressClose)
|
|
60
|
+
.padding(.top, Spacing.M)
|
|
61
|
+
.padding(.trailing, Spacing.M)
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
.background(theme.colors.background.surface.cornerRadius(layout.popupRadius(8)))
|
|
@@ -2,25 +2,26 @@ import SDWebImageSwiftUI
|
|
|
2
2
|
import SwiftUI
|
|
3
3
|
|
|
4
4
|
extension ScreenLayout {
|
|
5
|
-
/// Card width
|
|
5
|
+
/// Card width on foldables (`modalLayout`, Compose `popupMaxWidth`); unbounded on phones,
|
|
6
6
|
/// where the popup's own padding sets the width.
|
|
7
7
|
var popupMaxWidth: CGFloat {
|
|
8
|
-
|
|
8
|
+
let modal = modalLayout
|
|
9
|
+
return modal.isFoldable ? modal.popup.maxWidth : .infinity
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
/// The
|
|
12
|
+
/// The placement already keeps foldable popups off the edges, so their own side padding goes.
|
|
12
13
|
func popupHorizontalPadding(_ padding: CGFloat) -> CGFloat {
|
|
13
|
-
|
|
14
|
+
modalLayout.isFoldable ? 0 : padding
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
/// Tallest a popup gets on
|
|
17
|
+
/// Tallest a popup gets on foldables; nil on phones.
|
|
17
18
|
var popupMaxHeight: CGFloat? {
|
|
18
|
-
|
|
19
|
+
modalLayout.popup.maxHeight
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
/// Rounder on iPhone Duo, closer to its system alerts.
|
|
22
22
|
func popupRadius(_ regular: CGFloat = Radius.L) -> CGFloat {
|
|
23
|
-
|
|
23
|
+
let modal = modalLayout
|
|
24
|
+
return modal.isFoldable ? modal.popup.radius : regular
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -87,7 +88,7 @@ extension View {
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
/// 22pt round close button
|
|
91
|
+
/// 22pt round close button under `PopupPromotion`'s image (Compose `PopupPromotion`).
|
|
91
92
|
struct PopupCloseButton: View {
|
|
92
93
|
@Environment(\.appTheme) private var theme
|
|
93
94
|
var tapSize: CGFloat = 22
|
|
@@ -55,7 +55,8 @@ public struct PopupNotify: View {
|
|
|
55
55
|
public let props: PopupNotifyProps
|
|
56
56
|
|
|
57
57
|
@State private var descriptionHeight: CGFloat = 0
|
|
58
|
-
@State private var
|
|
58
|
+
@State private var descriptionFrameHeight: CGFloat = 0
|
|
59
|
+
@State private var cardHeight: CGFloat = 0
|
|
59
60
|
@State private var oneLineHeight: CGFloat = 0
|
|
60
61
|
@State private var twoLinesHeight: CGFloat = 0
|
|
61
62
|
|
|
@@ -63,10 +64,13 @@ public struct PopupNotify: View {
|
|
|
63
64
|
localize.translate("errorCode")
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
// ~8.5 lines as laid out (Compose measures the real lines); nominal line height until measured
|
|
67
|
+
// ~8.5 lines as laid out (Compose measures the real lines); nominal line height until measured.
|
|
68
|
+
// With a max height (foldables) only the description gives way: image, title and actions stay.
|
|
67
69
|
private var maxDescriptionHeight: CGFloat {
|
|
68
|
-
popupLinesHeight(8.5, oneLine: oneLineHeight, twoLines: twoLinesHeight)
|
|
70
|
+
let lines = popupLinesHeight(8.5, oneLine: oneLineHeight, twoLines: twoLinesHeight)
|
|
69
71
|
?? fontScale(TypographyStyle.bodyDefaultRegular.lineHeight) * 8.5
|
|
72
|
+
guard let maxHeight = layout.modalLayout.popup.maxHeight else { return lines }
|
|
73
|
+
return max(min(lines, maxHeight - (cardHeight - descriptionFrameHeight)), 0)
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
private var shouldUseColumnButtons: Bool {
|
|
@@ -87,33 +91,29 @@ public struct PopupNotify: View {
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
public var body: some View {
|
|
94
|
+
let modal = layout.modalLayout
|
|
90
95
|
ZStack(alignment: .topTrailing) {
|
|
91
96
|
VStack(spacing: 0) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
VStack(spacing: 0) {
|
|
95
|
-
if !props.image.isEmpty {
|
|
96
|
-
PopupHeaderImage(url: props.image)
|
|
97
|
-
}
|
|
98
|
-
textContent
|
|
99
|
-
}
|
|
97
|
+
if !props.image.isEmpty {
|
|
98
|
+
PopupHeaderImage(url: props.image)
|
|
100
99
|
}
|
|
100
|
+
textContent
|
|
101
101
|
|
|
102
102
|
actionButtons
|
|
103
103
|
.padding(.horizontal, Spacing.XL)
|
|
104
104
|
.padding(.bottom, Spacing.XL)
|
|
105
|
-
.popupReadHeight($actionsHeight)
|
|
106
105
|
}
|
|
107
106
|
.background(theme.colors.background.surface)
|
|
108
|
-
.clipShape(RoundedRectangle(cornerRadius:
|
|
107
|
+
.clipShape(RoundedRectangle(cornerRadius: modal.popup.radius))
|
|
108
|
+
.popupReadHeight($cardHeight)
|
|
109
109
|
|
|
110
110
|
if props.isShowCloseIcon {
|
|
111
|
-
|
|
112
|
-
.
|
|
111
|
+
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: props.onIconClose)
|
|
112
|
+
.padding(.top, Spacing.M)
|
|
113
|
+
.padding(.trailing, Spacing.M)
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
.frame(maxWidth:
|
|
116
|
-
.padding(.horizontal, layout.popupHorizontalPadding(Spacing.M))
|
|
116
|
+
.frame(minWidth: modal.popup.minWidth, maxWidth: modal.popup.maxWidth)
|
|
117
117
|
.accessibilityElement(children: .contain)
|
|
118
118
|
.accessibilityIdentifier("popup_notify")
|
|
119
119
|
}
|
|
@@ -126,6 +126,7 @@ public struct PopupNotify: View {
|
|
|
126
126
|
maxLines: 2,
|
|
127
127
|
accessibilityId: "title_popup_permission"
|
|
128
128
|
)
|
|
129
|
+
.padding(.trailing, props.isShowCloseIcon && props.image.isEmpty ? ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL : 0)
|
|
129
130
|
.padding(.bottom, Spacing.S)
|
|
130
131
|
|
|
131
132
|
descriptionContent
|
|
@@ -145,16 +146,18 @@ public struct PopupNotify: View {
|
|
|
145
146
|
.measureLineHeights(typography: .bodyDefaultRegular, oneLine: $oneLineHeight, twoLines: $twoLinesHeight)
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
@ViewBuilder
|
|
149
149
|
private var descriptionContent: some View {
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
Group {
|
|
151
|
+
if descriptionHeight > maxDescriptionHeight {
|
|
152
|
+
ScrollView(.vertical, showsIndicators: false) {
|
|
153
|
+
descriptionText
|
|
154
|
+
}
|
|
155
|
+
.frame(height: maxDescriptionHeight)
|
|
156
|
+
} else {
|
|
152
157
|
descriptionText
|
|
153
158
|
}
|
|
154
|
-
.frame(height: maxDescriptionHeight)
|
|
155
|
-
} else {
|
|
156
|
-
descriptionText
|
|
157
159
|
}
|
|
160
|
+
.popupReadHeight($descriptionFrameHeight)
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
private var descriptionText: some View {
|
|
@@ -202,6 +202,13 @@ 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
|
+
|
|
205
212
|
row("Bottom Tabs") {
|
|
206
213
|
navigator.push(
|
|
207
214
|
{ BottomTabDemoContent() },
|
|
@@ -253,6 +260,102 @@ private struct UpdateOptionsScreen: View {
|
|
|
253
260
|
}
|
|
254
261
|
}
|
|
255
262
|
|
|
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
|
+
|
|
256
359
|
@available(iOS 16.0, *)
|
|
257
360
|
private struct DemoLeafScreen: View {
|
|
258
361
|
@EnvironmentObject private var navigator: Navigator
|