@momo-kits/native-kits 0.168.1-beta.4-debug → 0.168.1-beta.40-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 +15 -10
- package/README.md +2 -10
- package/build.gradle.kts +1 -3
- package/compose/build.gradle.kts +20 -19
- package/compose/build.gradle.kts.backup +19 -18
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +4 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +14 -23
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +21 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +84 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +18 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +20 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +117 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +22 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +54 -36
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +1 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +35 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +321 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +89 -198
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +30 -44
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +32 -40
- 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/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +12 -3
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +3 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -10
- 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 +60 -10
- package/gradle/libs.versions.toml +4 -11
- package/gradle/wrapper/gradle-wrapper.properties +1 -3
- package/gradle.properties +3 -3
- package/ios/Application/ApplicationEnvironment.swift +7 -6
- package/ios/Application/DesignSystemKits.swift +163 -0
- package/ios/Application/DesignSystemKitsPayload.swift +68 -0
- package/ios/Badge/BadgeRibbon.swift +8 -1
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Input/Input.swift +16 -4
- package/ios/Input/InputPhoneNumber.swift +1 -3
- package/ios/Input/InputSearch.swift +1 -2
- package/ios/Input/InputTextArea.swift +8 -4
- package/ios/InputMoney/InputMoney.swift +6 -7
- package/ios/Layout/ModalLayout.swift +152 -0
- package/ios/Layout/ScreenLayout.swift +77 -18
- package/ios/Navigation/BottomSheet.swift +56 -53
- package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
- package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
- package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +64 -172
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
- package/ios/Navigation/Component/HeaderBackground.swift +22 -1
- package/ios/Navigation/Component/HeaderRight.swift +1 -1
- package/ios/Navigation/Component/SnackBar.swift +4 -0
- package/ios/Navigation/ModalScreen.swift +20 -5
- package/ios/Navigation/StackScreen.swift +6 -8
- package/ios/Popup/PopupDisplay.swift +6 -4
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -11
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/Stepper/Stepper.swift +1 -2
- package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
- package/ios/Typography/FontScale.swift +29 -15
- package/ios/Typography/Text.swift +88 -14
- package/ios/Typography/Typography.swift +2 -2
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- 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 +103 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/package.json +1 -1
- package/publish.sh +2 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
- package/ios/Typography/FontScaleStore.swift +0 -58
- package/ios/Typography/KitDesignSystem.swift +0 -17
|
@@ -24,9 +24,11 @@ struct ModalScreen<Content: View>: View {
|
|
|
24
24
|
@State private var didAppear = false
|
|
25
25
|
|
|
26
26
|
var body: some View {
|
|
27
|
+
let modal = layout.modalLayout
|
|
28
|
+
let placement = modal.placement
|
|
27
29
|
ZStack {
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
+
// full screen on foldables too, over the iPhone Duo control column
|
|
31
|
+
Colors.black20.opacity(modal.scrimOpacity * scrimOpacity)
|
|
30
32
|
.ignoresSafeArea()
|
|
31
33
|
.contentShape(Rectangle())
|
|
32
34
|
.onTapGesture {
|
|
@@ -34,11 +36,24 @@ struct ModalScreen<Content: View>: View {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
content()
|
|
39
|
+
// foldables: capped by the spec; nil leaves the size alone
|
|
40
|
+
.frame(
|
|
41
|
+
maxWidth: modal.isFoldable ? modal.popup.maxWidth : nil,
|
|
42
|
+
maxHeight: modal.isFoldable ? (modal.popup.maxHeight ?? placement.height) : nil
|
|
43
|
+
)
|
|
37
44
|
.scaleEffect(contentScale)
|
|
38
45
|
.opacity(contentOpacity)
|
|
39
|
-
//
|
|
40
|
-
.padding(
|
|
41
|
-
|
|
46
|
+
// center in the placement: the safe area, or the right half of a half-folded iPhone Duo
|
|
47
|
+
.padding(
|
|
48
|
+
modal.isFoldable
|
|
49
|
+
? EdgeInsets(
|
|
50
|
+
top: placement.minY,
|
|
51
|
+
leading: placement.minX,
|
|
52
|
+
bottom: layout.height - placement.maxY,
|
|
53
|
+
trailing: layout.width - placement.maxX
|
|
54
|
+
)
|
|
55
|
+
: EdgeInsets()
|
|
56
|
+
)
|
|
42
57
|
}
|
|
43
58
|
// Full screen like RN's Modal, so asymmetric landscape insets don't shift the content sideways.
|
|
44
59
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
@@ -403,11 +403,8 @@ public struct StackScreen<Content: View>: View {
|
|
|
403
403
|
.background(alignment: .top) {
|
|
404
404
|
Group {
|
|
405
405
|
if layout.sideBar != nil {
|
|
406
|
-
//
|
|
407
|
-
|
|
408
|
-
shape: Rectangle(),
|
|
409
|
-
visible: scrollOffset > heroGlassStart(animatedHeader)
|
|
410
|
-
))
|
|
406
|
+
// the bar shows once the banner has scrolled under the header
|
|
407
|
+
DuoHeaderBar(scrollOffset: scrollOffset, fadeStart: heroGlassStart(animatedHeader))
|
|
411
408
|
} else {
|
|
412
409
|
HeaderBarBackground(opacity: opacity)
|
|
413
410
|
}
|
|
@@ -457,8 +454,7 @@ public struct StackScreen<Content: View>: View {
|
|
|
457
454
|
|
|
458
455
|
header
|
|
459
456
|
.background(
|
|
460
|
-
|
|
461
|
-
.modifier(DuoBarMaterial(shape: Rectangle(), visible: scrollOffset > 0))
|
|
457
|
+
DuoHeaderBar(scrollOffset: scrollOffset)
|
|
462
458
|
.edgesIgnoringSafeArea([.top, .horizontal])
|
|
463
459
|
)
|
|
464
460
|
.offset(y: -headerHide)
|
|
@@ -577,7 +573,8 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
577
573
|
var animatedSearchInset: CGFloat = 0
|
|
578
574
|
/// Room for a header the content scrolls under (iPhone Duo glass header).
|
|
579
575
|
var topInset: CGFloat = 0
|
|
580
|
-
/// Room for
|
|
576
|
+
/// Room for the floating tab bar that overlays the content: scrolling content runs under it and
|
|
577
|
+
/// ends clear of it, static content stays above it.
|
|
581
578
|
var bottomInset: CGFloat = 0
|
|
582
579
|
/// Compose's animated-search snap: a scroll that comes to rest part way through this distance
|
|
583
580
|
/// finishes the move, up or back down.
|
|
@@ -648,6 +645,7 @@ private struct StackScreenContent<Content: View>: View {
|
|
|
648
645
|
}
|
|
649
646
|
}
|
|
650
647
|
} else {
|
|
648
|
+
// static tab content stays above the floating tab bar
|
|
651
649
|
content()
|
|
652
650
|
.padding(.top, topInset)
|
|
653
651
|
.padding(.bottom, bottomInset)
|
|
@@ -70,6 +70,7 @@ public struct PopupDisplay: View {
|
|
|
70
70
|
}
|
|
71
71
|
VStack(alignment: .leading, spacing: 0) {
|
|
72
72
|
MomoText(title, typography: .headerDefaultBold, maxLines: 2, accessibilityId: "title_popup_permission")
|
|
73
|
+
.padding(.trailing, isShowCloseIcon && url.isEmpty ? ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL : 0)
|
|
73
74
|
.padding(.top, 24)
|
|
74
75
|
.padding(.bottom, 8)
|
|
75
76
|
|
|
@@ -107,15 +108,16 @@ public struct PopupDisplay: View {
|
|
|
107
108
|
}
|
|
108
109
|
.fixedSize(horizontal: false, vertical: true)
|
|
109
110
|
.background(theme.colors.background.surface)
|
|
110
|
-
.clipShape(RoundedRectangle(cornerRadius:
|
|
111
|
+
.clipShape(RoundedRectangle(cornerRadius: layout.popupRadius()))
|
|
111
112
|
|
|
112
113
|
if isShowCloseIcon {
|
|
113
|
-
|
|
114
|
-
.
|
|
114
|
+
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onClose)
|
|
115
|
+
.padding(.top, Spacing.M)
|
|
116
|
+
.padding(.trailing, Spacing.M)
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
.frame(maxWidth: layout.popupMaxWidth)
|
|
118
|
-
.padding(.horizontal, 12)
|
|
120
|
+
.padding(.horizontal, layout.popupHorizontalPadding(12))
|
|
119
121
|
.accessibilityElement(children: .contain)
|
|
120
122
|
.accessibilityIdentifier("popup_notify")
|
|
121
123
|
}
|
|
@@ -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,15 +56,16 @@ 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
|
-
.background(theme.colors.background.surface.cornerRadius(8))
|
|
64
|
+
.background(theme.colors.background.surface.cornerRadius(layout.popupRadius(8)))
|
|
63
65
|
.shadow(color: .black.opacity(0.08), radius: 2, x: 0, y: 0)
|
|
64
66
|
.shadow(color: .black.opacity(0.16), radius: 24, x: 0, y: 0)
|
|
65
67
|
.frame(maxWidth: layout.popupMaxWidth)
|
|
66
|
-
.padding(.horizontal, 40)
|
|
68
|
+
.padding(.horizontal, layout.popupHorizontalPadding(40))
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
// MARK: Internal
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import SDWebImageSwiftUI
|
|
2
2
|
import SwiftUI
|
|
3
3
|
|
|
4
|
-
// Width of a system alert on the iPhone Duo inner display, in both orientations (RN Popup/utils.ts).
|
|
5
|
-
private let duoPopupMaxWidth: CGFloat = 440
|
|
6
|
-
|
|
7
4
|
extension ScreenLayout {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/// Card width cap (Compose `popupMaxWidth`); unbounded off iPhone Duo, where the popup's own padding sets the width.
|
|
5
|
+
/// Card width on foldables (`modalLayout`, Compose `popupMaxWidth`); unbounded on phones,
|
|
6
|
+
/// where the popup's own padding sets the width.
|
|
11
7
|
var popupMaxWidth: CGFloat {
|
|
12
|
-
|
|
8
|
+
let modal = modalLayout
|
|
9
|
+
return modal.isFoldable ? modal.popup.maxWidth : .infinity
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/// The placement already keeps foldable popups off the edges, so their own side padding goes.
|
|
13
|
+
func popupHorizontalPadding(_ padding: CGFloat) -> CGFloat {
|
|
14
|
+
modalLayout.isFoldable ? 0 : padding
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
///
|
|
17
|
+
/// Tallest a popup gets on foldables; nil on phones.
|
|
16
18
|
var popupMaxHeight: CGFloat? {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
modalLayout.popup.maxHeight
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func popupRadius(_ regular: CGFloat = Radius.L) -> CGFloat {
|
|
23
|
+
let modal = modalLayout
|
|
24
|
+
return modal.isFoldable ? modal.popup.radius : regular
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
|
|
@@ -82,7 +88,7 @@ extension View {
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
/// 22pt round close button
|
|
91
|
+
/// 22pt round close button under `PopupPromotion`'s image (Compose `PopupPromotion`).
|
|
86
92
|
struct PopupCloseButton: View {
|
|
87
93
|
@Environment(\.appTheme) private var theme
|
|
88
94
|
var tapSize: CGFloat = 22
|
|
@@ -22,6 +22,7 @@ public struct PopupNotifyProps {
|
|
|
22
22
|
public var buttonDirection: PopupActionDirection
|
|
23
23
|
public var onIconClose: () -> Void
|
|
24
24
|
public var isShowCloseIcon: Bool
|
|
25
|
+
public var highlightText: [String]
|
|
25
26
|
|
|
26
27
|
public init(
|
|
27
28
|
image: String = "",
|
|
@@ -32,7 +33,8 @@ public struct PopupNotifyProps {
|
|
|
32
33
|
secondary: PopupAction? = nil,
|
|
33
34
|
buttonDirection: PopupActionDirection = .row,
|
|
34
35
|
onIconClose: @escaping () -> Void,
|
|
35
|
-
isShowCloseIcon: Bool = true
|
|
36
|
+
isShowCloseIcon: Bool = true,
|
|
37
|
+
highlightText: [String] = []
|
|
36
38
|
) {
|
|
37
39
|
self.image = image
|
|
38
40
|
self.title = title
|
|
@@ -43,6 +45,7 @@ public struct PopupNotifyProps {
|
|
|
43
45
|
self.buttonDirection = buttonDirection
|
|
44
46
|
self.onIconClose = onIconClose
|
|
45
47
|
self.isShowCloseIcon = isShowCloseIcon
|
|
48
|
+
self.highlightText = highlightText
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -55,7 +58,8 @@ public struct PopupNotify: View {
|
|
|
55
58
|
public let props: PopupNotifyProps
|
|
56
59
|
|
|
57
60
|
@State private var descriptionHeight: CGFloat = 0
|
|
58
|
-
@State private var
|
|
61
|
+
@State private var descriptionFrameHeight: CGFloat = 0
|
|
62
|
+
@State private var cardHeight: CGFloat = 0
|
|
59
63
|
@State private var oneLineHeight: CGFloat = 0
|
|
60
64
|
@State private var twoLinesHeight: CGFloat = 0
|
|
61
65
|
|
|
@@ -63,10 +67,13 @@ public struct PopupNotify: View {
|
|
|
63
67
|
localize.translate("errorCode")
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
// ~8.5 lines as laid out (Compose measures the real lines); nominal line height until measured
|
|
70
|
+
// ~8.5 lines as laid out (Compose measures the real lines); nominal line height until measured.
|
|
71
|
+
// With a max height (foldables) only the description gives way: image, title and actions stay.
|
|
67
72
|
private var maxDescriptionHeight: CGFloat {
|
|
68
|
-
popupLinesHeight(8.5, oneLine: oneLineHeight, twoLines: twoLinesHeight)
|
|
73
|
+
let lines = popupLinesHeight(8.5, oneLine: oneLineHeight, twoLines: twoLinesHeight)
|
|
69
74
|
?? fontScale(TypographyStyle.bodyDefaultRegular.lineHeight) * 8.5
|
|
75
|
+
guard let maxHeight = layout.modalLayout.popup.maxHeight else { return lines }
|
|
76
|
+
return max(min(lines, maxHeight - (cardHeight - descriptionFrameHeight)), 0)
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
private var shouldUseColumnButtons: Bool {
|
|
@@ -87,33 +94,29 @@ public struct PopupNotify: View {
|
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
public var body: some View {
|
|
97
|
+
let modal = layout.modalLayout
|
|
90
98
|
ZStack(alignment: .topTrailing) {
|
|
91
99
|
VStack(spacing: 0) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
VStack(spacing: 0) {
|
|
95
|
-
if !props.image.isEmpty {
|
|
96
|
-
PopupHeaderImage(url: props.image)
|
|
97
|
-
}
|
|
98
|
-
textContent
|
|
99
|
-
}
|
|
100
|
+
if !props.image.isEmpty {
|
|
101
|
+
PopupHeaderImage(url: props.image)
|
|
100
102
|
}
|
|
103
|
+
textContent
|
|
101
104
|
|
|
102
105
|
actionButtons
|
|
103
106
|
.padding(.horizontal, Spacing.XL)
|
|
104
107
|
.padding(.bottom, Spacing.XL)
|
|
105
|
-
.popupReadHeight($actionsHeight)
|
|
106
108
|
}
|
|
107
109
|
.background(theme.colors.background.surface)
|
|
108
|
-
.clipShape(RoundedRectangle(cornerRadius:
|
|
110
|
+
.clipShape(RoundedRectangle(cornerRadius: modal.popup.radius))
|
|
111
|
+
.popupReadHeight($cardHeight)
|
|
109
112
|
|
|
110
113
|
if props.isShowCloseIcon {
|
|
111
|
-
|
|
112
|
-
.
|
|
114
|
+
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: props.onIconClose)
|
|
115
|
+
.padding(.top, Spacing.M)
|
|
116
|
+
.padding(.trailing, Spacing.M)
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
|
-
.frame(maxWidth:
|
|
116
|
-
.padding(.horizontal, Spacing.M)
|
|
119
|
+
.frame(minWidth: modal.popup.minWidth, maxWidth: modal.popup.maxWidth)
|
|
117
120
|
.accessibilityElement(children: .contain)
|
|
118
121
|
.accessibilityIdentifier("popup_notify")
|
|
119
122
|
}
|
|
@@ -126,6 +129,7 @@ public struct PopupNotify: View {
|
|
|
126
129
|
maxLines: 2,
|
|
127
130
|
accessibilityId: "title_popup_permission"
|
|
128
131
|
)
|
|
132
|
+
.padding(.trailing, props.isShowCloseIcon && props.image.isEmpty ? ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL : 0)
|
|
129
133
|
.padding(.bottom, Spacing.S)
|
|
130
134
|
|
|
131
135
|
descriptionContent
|
|
@@ -145,23 +149,26 @@ public struct PopupNotify: View {
|
|
|
145
149
|
.measureLineHeights(typography: .bodyDefaultRegular, oneLine: $oneLineHeight, twoLines: $twoLinesHeight)
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
@ViewBuilder
|
|
149
152
|
private var descriptionContent: some View {
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
Group {
|
|
154
|
+
if descriptionHeight > maxDescriptionHeight {
|
|
155
|
+
ScrollView(.vertical, showsIndicators: false) {
|
|
156
|
+
descriptionText
|
|
157
|
+
}
|
|
158
|
+
.frame(height: maxDescriptionHeight)
|
|
159
|
+
} else {
|
|
152
160
|
descriptionText
|
|
153
161
|
}
|
|
154
|
-
.frame(height: maxDescriptionHeight)
|
|
155
|
-
} else {
|
|
156
|
-
descriptionText
|
|
157
162
|
}
|
|
163
|
+
.popupReadHeight($descriptionFrameHeight)
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
private var descriptionText: some View {
|
|
161
167
|
MomoText(
|
|
162
168
|
props.description,
|
|
163
169
|
typography: .bodyDefaultRegular,
|
|
164
|
-
accessibilityId: "description_popup_permission"
|
|
170
|
+
accessibilityId: "description_popup_permission",
|
|
171
|
+
highlightText: props.highlightText
|
|
165
172
|
)
|
|
166
173
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
167
174
|
.popupReadHeight($descriptionHeight)
|
|
@@ -84,7 +84,6 @@ private struct StepperButton: View {
|
|
|
84
84
|
|
|
85
85
|
private struct StepperNumberView: View {
|
|
86
86
|
@Environment(\.appTheme) private var theme
|
|
87
|
-
@Environment(\.momoFontScale) private var fontScale
|
|
88
87
|
|
|
89
88
|
@Binding var text: String
|
|
90
89
|
var size: StepperSize
|
|
@@ -106,7 +105,7 @@ private struct StepperNumberView: View {
|
|
|
106
105
|
MomoText(text, typography: .descriptionDefaultRegular, color: textColor)
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
|
-
.
|
|
108
|
+
.kitFont(size: 12)
|
|
110
109
|
.ignoreBoldTextSetting()
|
|
111
110
|
.foregroundColor(textColor)
|
|
112
111
|
// Compose's min width includes the horizontal padding.
|
|
@@ -11,7 +11,7 @@ import SDWebImageSwiftUI
|
|
|
11
11
|
|
|
12
12
|
let jsonUrl = "https://static.momocdn.net/app/json/component-kits/design_system.json"
|
|
13
13
|
|
|
14
|
-
public struct TrustBannerData: Decodable {
|
|
14
|
+
public struct TrustBannerData: Decodable, Equatable {
|
|
15
15
|
public let content: [String: String]
|
|
16
16
|
public let subContent: [String: String]
|
|
17
17
|
public let pciImage: String?
|
|
@@ -85,6 +85,7 @@ let defaultBanner = TrustBannerData(
|
|
|
85
85
|
public struct TrustBanner: View {
|
|
86
86
|
@Environment(\.applicationEnvironment) var applicationEnvironment
|
|
87
87
|
@Environment(\.localize) private var localize
|
|
88
|
+
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
88
89
|
|
|
89
90
|
var onPress: ((String)->Void)?
|
|
90
91
|
private let serviceName: String
|
|
@@ -104,7 +105,8 @@ public struct TrustBanner: View {
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
private var banner: TrustBannerData {
|
|
107
|
-
|
|
108
|
+
// Container config wins, else the host-pushed DesignSystemKits config (Compose parity).
|
|
109
|
+
(applicationEnvironment.config ?? designSystemKitsConfigs.designSystemConfig)?.trustBanner ?? defaultBanner
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
func onPressSecurity() {
|
|
@@ -19,11 +19,19 @@ public struct FontScale: Equatable {
|
|
|
19
19
|
public let useOSScaleRate: Bool
|
|
20
20
|
/// OS Dynamic Type factor at the time the snapshot was taken.
|
|
21
21
|
public let osFontScale: CGFloat
|
|
22
|
+
// AI-GENERATED START: device scale from the app window, not UIScreen.main (fixed to one display on iPhone Duo)
|
|
23
|
+
public let windowShortSide: CGFloat
|
|
22
24
|
|
|
23
|
-
public init(
|
|
25
|
+
public init(
|
|
26
|
+
userScaleRate: CGFloat = 1,
|
|
27
|
+
useOSScaleRate: Bool = true,
|
|
28
|
+
osFontScale: CGFloat = 1,
|
|
29
|
+
windowShortSide: CGFloat? = nil
|
|
30
|
+
) {
|
|
24
31
|
self.userScaleRate = userScaleRate
|
|
25
32
|
self.useOSScaleRate = useOSScaleRate
|
|
26
33
|
self.osFontScale = osFontScale
|
|
34
|
+
self.windowShortSide = windowShortSide ?? DesignSystemKits.currentWindowShortSide()
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
/// `callAsFunction` so call sites keep reading like Compose's `scaleSize(16)`.
|
|
@@ -31,8 +39,8 @@ public struct FontScale: Equatable {
|
|
|
31
39
|
guard useOSScaleRate else { return size * userScaleRate }
|
|
32
40
|
|
|
33
41
|
// Short side, not width: landscape must not inflate every font (and so every popup's height).
|
|
34
|
-
let
|
|
35
|
-
|
|
42
|
+
let deviceScale = windowShortSide / Self.defaultScreenSize
|
|
43
|
+
// AI-GENERATED END: device scale from the app window, not UIScreen.main (fixed to one display on iPhone Duo)
|
|
36
44
|
|
|
37
45
|
var deviceScaled = size
|
|
38
46
|
var osScaled = size
|
|
@@ -52,13 +60,16 @@ public struct FontScale: Equatable {
|
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
/// A host-pushed mini-app context wins per field, matching Compose's
|
|
55
|
-
/// `context?.useOSScaleRate ?:
|
|
63
|
+
/// `context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate`.
|
|
56
64
|
public func overriding(userScaleRate: CGFloat?, useOSScaleRate: Bool?) -> FontScale {
|
|
57
65
|
guard userScaleRate != nil || useOSScaleRate != nil else { return self }
|
|
58
66
|
return FontScale(
|
|
59
67
|
userScaleRate: userScaleRate ?? self.userScaleRate,
|
|
60
68
|
useOSScaleRate: useOSScaleRate ?? self.useOSScaleRate,
|
|
61
|
-
osFontScale: osFontScale
|
|
69
|
+
osFontScale: osFontScale,
|
|
70
|
+
// AI-GENERATED START: keep the window size through context overrides
|
|
71
|
+
windowShortSide: windowShortSide
|
|
72
|
+
// AI-GENERATED END: keep the window size through context overrides
|
|
62
73
|
)
|
|
63
74
|
}
|
|
64
75
|
}
|
|
@@ -66,7 +77,7 @@ public struct FontScale: Equatable {
|
|
|
66
77
|
private struct FontScaleKey: EnvironmentKey {
|
|
67
78
|
/// Computed, never stored: a bare `UIHostingController` root that never got `.momoFontScale()`
|
|
68
79
|
/// still reads the live store instead of a value frozen at first access.
|
|
69
|
-
static var defaultValue: FontScale {
|
|
80
|
+
static var defaultValue: FontScale { DesignSystemKits.shared.fontScale }
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
public extension EnvironmentValues {
|
|
@@ -77,9 +88,10 @@ public extension EnvironmentValues {
|
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
public extension View {
|
|
80
|
-
/// Injects a Dynamic-Type-observing font scale
|
|
91
|
+
/// Injects a Dynamic-Type-observing font scale plus `\.designSystemKitsConfigs` (whitelist, remote config)
|
|
92
|
+
/// and re-renders this subtree on change.
|
|
81
93
|
/// Use at every `UIHostingController` root that is not inside a `NavigationContainer`.
|
|
82
|
-
func momoFontScale(_ store:
|
|
94
|
+
func momoFontScale(_ store: DesignSystemKits = .shared, context: MiniAppContext? = nil) -> some View {
|
|
83
95
|
modifier(MomoFontScaleModifier(store: store, context: context))
|
|
84
96
|
}
|
|
85
97
|
}
|
|
@@ -87,17 +99,19 @@ public extension View {
|
|
|
87
99
|
/// `@ObservedObject` is load-bearing, same as `MomoLocalizeModifier`: `@Environment(\.momoFontScale)`
|
|
88
100
|
/// only invalidates when the boxed snapshot changes, which requires *this* body to re-run on publish.
|
|
89
101
|
private struct MomoFontScaleModifier: ViewModifier {
|
|
90
|
-
@ObservedObject var store:
|
|
102
|
+
@ObservedObject var store: DesignSystemKits
|
|
91
103
|
let context: MiniAppContext?
|
|
92
104
|
|
|
93
105
|
func body(content: Content) -> some View {
|
|
94
|
-
content
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
content
|
|
107
|
+
.environment(
|
|
108
|
+
\.momoFontScale,
|
|
109
|
+
store.fontScale.overriding(
|
|
110
|
+
userScaleRate: context?.userScaleRate,
|
|
111
|
+
useOSScaleRate: context?.useOSScaleRate
|
|
112
|
+
)
|
|
99
113
|
)
|
|
100
|
-
|
|
114
|
+
.environment(\.designSystemKitsConfigs, store.getConfigs())
|
|
101
115
|
}
|
|
102
116
|
}
|
|
103
117
|
// AI-GENERATED END: reactive font-scale snapshot injected through the environment
|
|
@@ -4,7 +4,7 @@ import SwiftUI
|
|
|
4
4
|
/// free functions). Inside a SwiftUI view prefer `@Environment(\.momoFontScale)` so the view
|
|
5
5
|
/// re-renders when Dynamic Type or the host preference changes.
|
|
6
6
|
public func scaleSize(_ size: CGFloat) -> CGFloat {
|
|
7
|
-
|
|
7
|
+
DesignSystemKits.shared.fontScale(size)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
@available(*, deprecated, message: "Max font scale is fixed at 1.5; this override is no longer applied. Drop the second argument.")
|
|
@@ -105,10 +105,10 @@ private enum MomoFontFace {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
/// Port of Compose `getFontFamily`; SF Pro Text is the iOS system font, so the legacy family is `.system`.
|
|
108
|
-
private func momoFontFace(family: String, weight: Font.Weight) -> MomoFontFace? {
|
|
108
|
+
private func momoFontFace(family: String, weight: Font.Weight, isWhiteList: Bool) -> MomoFontFace? {
|
|
109
109
|
let isNewFamily = family == "MomoTrustSans" || family == headerFontFamily
|
|
110
110
|
// Outside the whitelist the new DS families drop to the legacy font, as before DS-791.
|
|
111
|
-
if family == "SFProText" || (isNewFamily && !
|
|
111
|
+
if family == "SFProText" || (isNewFamily && !isWhiteList) { return .system }
|
|
112
112
|
// single-file families (Compose maps every weight to the same .otf)
|
|
113
113
|
if family == headerFontFamily || family == "MoMoSignature" { return .named(family) }
|
|
114
114
|
guard family == "MomoTrustSans" else { return nil }
|
|
@@ -127,8 +127,14 @@ private func momoFontFace(family: String, weight: Font.Weight) -> MomoFontFace?
|
|
|
127
127
|
/// Header title family (Compose `HEADER_FONT_FAMILY`), whitelist only like the default font.
|
|
128
128
|
let headerFontFamily = "MoMoTrustDisplay"
|
|
129
129
|
|
|
130
|
-
private func momoFont(
|
|
131
|
-
|
|
130
|
+
private func momoFont(
|
|
131
|
+
size: CGFloat,
|
|
132
|
+
weight: Font.Weight,
|
|
133
|
+
family: String,
|
|
134
|
+
fallbackFamily: String? = nil,
|
|
135
|
+
isWhiteList: Bool
|
|
136
|
+
) -> Font {
|
|
137
|
+
switch momoFontFace(family: family, weight: weight, isWhiteList: isWhiteList) {
|
|
132
138
|
case .system:
|
|
133
139
|
return .system(size: size, weight: weight)
|
|
134
140
|
case .named(let name) where UIFont(name: name, size: size) != nil:
|
|
@@ -136,15 +142,15 @@ private func momoFont(size: CGFloat, weight: Font.Weight, family: String, fallba
|
|
|
136
142
|
default:
|
|
137
143
|
// Compose falls back to the default font file when a family is missing
|
|
138
144
|
if let fallbackFamily, fallbackFamily != family {
|
|
139
|
-
return momoFont(size: size, weight: weight, family: fallbackFamily)
|
|
145
|
+
return momoFont(size: size, weight: weight, family: fallbackFamily, isWhiteList: isWhiteList)
|
|
140
146
|
}
|
|
141
147
|
return .system(size: size, weight: weight)
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
// lineHeight is identical across weights of a family, so the regular face is enough.
|
|
146
|
-
private func momoLineHeight(size: CGFloat, family: String, fallbackFamily: String? = nil) -> CGFloat {
|
|
147
|
-
switch momoFontFace(family: family, weight: .regular) {
|
|
152
|
+
private func momoLineHeight(size: CGFloat, family: String, fallbackFamily: String? = nil, isWhiteList: Bool) -> CGFloat {
|
|
153
|
+
switch momoFontFace(family: family, weight: .regular, isWhiteList: isWhiteList) {
|
|
148
154
|
case .system:
|
|
149
155
|
break
|
|
150
156
|
case .named(let name):
|
|
@@ -152,15 +158,71 @@ private func momoLineHeight(size: CGFloat, family: String, fallbackFamily: Strin
|
|
|
152
158
|
fallthrough
|
|
153
159
|
case nil:
|
|
154
160
|
if let fallbackFamily, fallbackFamily != family {
|
|
155
|
-
return momoLineHeight(size: size, family: fallbackFamily)
|
|
161
|
+
return momoLineHeight(size: size, family: fallbackFamily, isWhiteList: isWhiteList)
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
return UIFont.systemFont(ofSize: size).lineHeight
|
|
159
165
|
}
|
|
160
166
|
|
|
167
|
+
/// UIKit counterpart of `momoFont`, for text that is not a `MomoText` (UITextField/UITextView, text measuring).
|
|
168
|
+
func momoUIFont(size: CGFloat, weight: UIFont.Weight, family: String, isWhiteList: Bool) -> UIFont {
|
|
169
|
+
guard case .named(let name) = momoFontFace(family: family, weight: Font.Weight(weight), isWhiteList: isWhiteList),
|
|
170
|
+
let font = UIFont(name: name, size: size) else {
|
|
171
|
+
return .systemFont(ofSize: size, weight: weight)
|
|
172
|
+
}
|
|
173
|
+
return font
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private extension Font.Weight {
|
|
177
|
+
init(_ weight: UIFont.Weight) {
|
|
178
|
+
switch weight {
|
|
179
|
+
case .ultraLight: self = .ultraLight
|
|
180
|
+
case .thin: self = .thin
|
|
181
|
+
case .light: self = .light
|
|
182
|
+
case .medium: self = .medium
|
|
183
|
+
case .semibold: self = .semibold
|
|
184
|
+
case .bold: self = .bold
|
|
185
|
+
case .heavy: self = .heavy
|
|
186
|
+
case .black: self = .black
|
|
187
|
+
default: self = .regular
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/// Gives input text the same family as `MomoText` (Compose's `getFontFamily`), e.g. a TextField
|
|
193
|
+
/// next to a `MomoText` placeholder. `size` is unscaled; the environment font scale is applied here.
|
|
194
|
+
private struct KitFontModifier: ViewModifier {
|
|
195
|
+
@Environment(\.appTheme) private var theme
|
|
196
|
+
@Environment(\.momoFontScale) private var fontScale
|
|
197
|
+
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
198
|
+
let size: CGFloat
|
|
199
|
+
let weight: Font.Weight
|
|
200
|
+
|
|
201
|
+
func body(content: Content) -> some View {
|
|
202
|
+
content.font(momoFont(
|
|
203
|
+
size: fontScale(size),
|
|
204
|
+
weight: weight,
|
|
205
|
+
family: theme.font,
|
|
206
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
207
|
+
))
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
extension View {
|
|
212
|
+
func kitFont(_ typography: TypographyStyle) -> some View {
|
|
213
|
+
modifier(KitFontModifier(size: typography.fontSize, weight: typography.fontWeight))
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
func kitFont(size: CGFloat, weight: Font.Weight = .regular) -> some View {
|
|
217
|
+
modifier(KitFontModifier(size: size, weight: weight))
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
161
221
|
public struct MomoText: View {
|
|
162
222
|
@Environment(\.appTheme) private var theme
|
|
163
223
|
@Environment(\.momoFontScale) private var fontScale
|
|
224
|
+
// From the environment, not DesignSystemKits.shared, so a whitelist flip re-renders the text.
|
|
225
|
+
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
164
226
|
private let content: String
|
|
165
227
|
private let typography: TypographyStyle
|
|
166
228
|
private let color: Color?
|
|
@@ -219,8 +281,8 @@ public struct MomoText: View {
|
|
|
219
281
|
self.fontFamily = fontFamily
|
|
220
282
|
}
|
|
221
283
|
|
|
222
|
-
init(_ content: String, typography: TypographyStyle, highlightText: [String]) {
|
|
223
|
-
self.init(content, typography: typography)
|
|
284
|
+
init(_ content: String, typography: TypographyStyle, accessibilityId: String? = nil, highlightText: [String]) {
|
|
285
|
+
self.init(content, typography: typography, accessibilityId: accessibilityId)
|
|
224
286
|
self.highlightText = highlightText
|
|
225
287
|
}
|
|
226
288
|
|
|
@@ -236,7 +298,8 @@ public struct MomoText: View {
|
|
|
236
298
|
size: fontScale(fontSize),
|
|
237
299
|
weight: typography.fontWeight,
|
|
238
300
|
family: fontFamily ?? theme.font,
|
|
239
|
-
fallbackFamily: theme.font
|
|
301
|
+
fallbackFamily: theme.font,
|
|
302
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
240
303
|
)
|
|
241
304
|
}
|
|
242
305
|
|
|
@@ -244,7 +307,13 @@ public struct MomoText: View {
|
|
|
244
307
|
private var baseText: SwiftUI.Text {
|
|
245
308
|
let keywords = highlightText.filter { !$0.isEmpty }.sorted { $0.count > $1.count }
|
|
246
309
|
guard !keywords.isEmpty else { return SwiftUI.Text(content) }
|
|
247
|
-
let highlightFont = momoFont(
|
|
310
|
+
let highlightFont = momoFont(
|
|
311
|
+
size: fontScale(fontSize),
|
|
312
|
+
weight: TypographyStyle.headerXsSemibold.fontWeight,
|
|
313
|
+
family: fontFamily ?? theme.font,
|
|
314
|
+
fallbackFamily: theme.font,
|
|
315
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
316
|
+
)
|
|
248
317
|
func isWordChar(_ character: Character?) -> Bool {
|
|
249
318
|
guard let character else { return false }
|
|
250
319
|
return character.isLetter || character.isNumber || character == "_"
|
|
@@ -282,7 +351,12 @@ public struct MomoText: View {
|
|
|
282
351
|
|
|
283
352
|
// lineSpacing is added on top of the font's natural line height, not on top of fontSize.
|
|
284
353
|
let lineSpacing = max(0, fontScale(lineHeight)
|
|
285
|
-
- momoLineHeight(
|
|
354
|
+
- momoLineHeight(
|
|
355
|
+
size: fontScale(fontSize),
|
|
356
|
+
family: fontFamily ?? theme.font,
|
|
357
|
+
fallbackFamily: theme.font,
|
|
358
|
+
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
359
|
+
))
|
|
286
360
|
|
|
287
361
|
var text = baseText
|
|
288
362
|
.font(font)
|