@momo-kits/native-kits 0.167.1-duo.3 → 0.167.1-duo.4-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 +17 -8
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +190 -0
- package/compose/build.gradle.kts.backup +190 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +151 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +124 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +293 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +831 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +378 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +82 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +356 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +475 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +266 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +240 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +264 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +334 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +310 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +323 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +199 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +552 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +234 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +297 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +299 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +129 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +393 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +622 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +232 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +381 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +83 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +105 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +347 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +37 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +40 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +213 -0
- package/gradle/libs.versions.toml +69 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Application/ApplicationEnvironment.swift +6 -0
- package/ios/Application/Components.swift +1 -3
- package/ios/Application/HeaderRight.swift +19 -27
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +9 -30
- package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +2 -5
- package/ios/Application/Navigation/HeaderUser.swift +1 -7
- package/ios/Application/Navigation/NavigationContainer.swift +45 -45
- package/ios/Application/Navigation/Navigator.swift +122 -29
- package/ios/Application/Navigation/NavigatorManager.swift +13 -6
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +4 -41
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +1 -5
- package/ios/Application/Navigation/component/Header.swift +4 -12
- package/ios/Application/Navigation/component/HeaderBackground.swift +2 -3
- package/ios/Application/Navigation/component/NavigationFooter.swift +1 -1
- package/ios/Application/Navigation/component/NavigationHeaderRight.swift +9 -61
- package/ios/Application/StackScreen.swift +18 -135
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +59 -5
- package/ios/Colors+Radius+Spacing/Colors.swift +1 -1
- package/ios/Extensions/Color++.swift +20 -9
- package/ios/Extensions/OptionalEnvironmentObject.swift +12 -0
- package/ios/Icon/Icon.swift +14 -22
- package/ios/Icon/Icons.swift +1329 -0
- package/ios/Image/Image.swift +16 -5
- package/ios/Lottie/LottieView.swift +4 -2
- package/ios/Popup/PopupDisplay.swift +68 -84
- package/ios/Popup/PopupNotify.swift +32 -43
- package/ios/Popup/PopupPromotion.swift +6 -18
- package/ios/Resources/dot_loading.json +558 -0
- package/ios/Resources/lottie_circle_loader.json +1 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +69 -31
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/README.md +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -1
- package/package.json +1 -1
- package/scripts/gen-ios-icons.mjs +36 -0
- package/settings.gradle.kts +64 -0
- package/.claude/scheduled_tasks.lock +0 -1
- package/.claude/settings.local.json +0 -185
- package/ios/Application/Layout/ScreenLayout.swift +0 -196
- package/ios/Application/Navigation/BottomTab/DuoTabBar.swift +0 -275
- package/ios/Application/Navigation/component/DuoScrollGradient.swift +0 -55
- package/ios/Application/Navigation/component/SideBar.swift +0 -155
- package/ios/Popup/PopupLayout.swift +0 -45
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DuoTabDemo.swift +0 -76
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IPhoneDuoDemo.swift +0 -170
package/ios/Image/Image.swift
CHANGED
|
@@ -41,11 +41,7 @@ public struct ImageView: View {
|
|
|
41
41
|
.placeholder {
|
|
42
42
|
VStack(alignment: .center, content: {
|
|
43
43
|
if error {
|
|
44
|
-
|
|
45
|
-
.resizable()
|
|
46
|
-
.renderingMode(.template)
|
|
47
|
-
.foregroundColor(theme.colors.text.disable)
|
|
48
|
-
.frame(width: 24, height: 24)
|
|
44
|
+
ImageErrorIcon(color: theme.colors.text.disable)
|
|
49
45
|
} else if placeholder != nil {
|
|
50
46
|
placeholder
|
|
51
47
|
}
|
|
@@ -74,6 +70,21 @@ public struct ImageView: View {
|
|
|
74
70
|
var url: String
|
|
75
71
|
}
|
|
76
72
|
|
|
73
|
+
// A bare WebImage on purpose: going through `Icon` nests another `ImageView`, whose own
|
|
74
|
+
// failure would render this placeholder again, without end while offline.
|
|
75
|
+
private struct ImageErrorIcon: View {
|
|
76
|
+
let color: Color
|
|
77
|
+
|
|
78
|
+
var body: some View {
|
|
79
|
+
WebImage(url: URL(string: iconSources["media_fail"] ?? ""))
|
|
80
|
+
.resizable()
|
|
81
|
+
.renderingMode(.template)
|
|
82
|
+
.scaledToFit()
|
|
83
|
+
.foregroundColor(color)
|
|
84
|
+
.frame(width: 24, height: 24)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
77
88
|
private struct ColorMultiplyModifier: ViewModifier {
|
|
78
89
|
let color: Color?
|
|
79
90
|
|
|
@@ -36,7 +36,8 @@ struct LottieView: UIViewRepresentable {
|
|
|
36
36
|
animationView.animation = cachedAnimation
|
|
37
37
|
setupAnimationView(animationView, view)
|
|
38
38
|
} else {
|
|
39
|
-
|
|
39
|
+
guard let animationURL = URL(string: url) else { return view }
|
|
40
|
+
LottieAnimation.loadedFrom(url: animationURL, closure: { animation in
|
|
40
41
|
if let animation = animation {
|
|
41
42
|
Self.animationCache.setObject(animation, forKey: url as NSString)
|
|
42
43
|
animationView.animation = animation
|
|
@@ -49,7 +50,8 @@ struct LottieView: UIViewRepresentable {
|
|
|
49
50
|
if let cachedAnimation = Self.animationCache.object(forKey: name as NSString) {
|
|
50
51
|
animationView.animation = cachedAnimation
|
|
51
52
|
setupAnimationView(animationView, view)
|
|
52
|
-
} else if let animation = LottieAnimation.named(name)
|
|
53
|
+
} else if let animation = LottieAnimation.named(name, bundle: MoMoUIKitsResources.bundle)
|
|
54
|
+
?? LottieAnimation.named(name) {
|
|
53
55
|
Self.animationCache.setObject(animation, forKey: name as NSString)
|
|
54
56
|
animationView.animation = animation
|
|
55
57
|
setupAnimationView(animationView, view)
|
|
@@ -55,7 +55,6 @@ extension View {
|
|
|
55
55
|
|
|
56
56
|
public struct PopupDisplay: View {
|
|
57
57
|
@Environment(\.localize) private var localize
|
|
58
|
-
@Environment(\.screenLayout) private var layout
|
|
59
58
|
|
|
60
59
|
// MARK: Lifecycle
|
|
61
60
|
|
|
@@ -92,7 +91,6 @@ public struct PopupDisplay: View {
|
|
|
92
91
|
|
|
93
92
|
@State private var textHeight: CGFloat = .zero
|
|
94
93
|
@State private var isScrollable = false
|
|
95
|
-
@State private var actionsHeight: CGFloat = 0
|
|
96
94
|
|
|
97
95
|
public var body: some View {
|
|
98
96
|
var shouldUseColumn: Bool {
|
|
@@ -116,103 +114,89 @@ public struct PopupDisplay: View {
|
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
VStack(spacing: 0) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.
|
|
125
|
-
.placeholder {
|
|
126
|
-
Rectangle()
|
|
127
|
-
.fill(Color.gray.opacity(0.3))
|
|
128
|
-
.aspectRatio(1.777, contentMode: .fit)
|
|
129
|
-
.frame(maxWidth: .infinity, maxHeight: 184)
|
|
130
|
-
}
|
|
117
|
+
if(!url.isEmpty) {
|
|
118
|
+
WebImage(url: URL(string: url), isAnimating: .constant(true))
|
|
119
|
+
.resizable()
|
|
120
|
+
.placeholder {
|
|
121
|
+
Rectangle()
|
|
122
|
+
.fill(Color.gray.opacity(0.3))
|
|
131
123
|
.aspectRatio(1.777, contentMode: .fit)
|
|
132
|
-
.frame(maxWidth: .infinity,
|
|
133
|
-
.clipShape(RoundedCorner(radius: 15, corners: [.topLeft, .topRight]))
|
|
134
|
-
.clipped()
|
|
124
|
+
.frame(maxWidth: .infinity, maxHeight: 184)
|
|
135
125
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
.multilineTextAlignment(.leading)
|
|
148
|
-
.background(GeometryReader { geo in
|
|
149
|
-
Color.clear.onAppear { textHeight = geo.size.height }
|
|
150
|
-
})
|
|
151
|
-
.measureLineHeights(font: .body_default_regular,
|
|
152
|
-
oneLine: $oneLineH,
|
|
153
|
-
twoLines: $twoLineH)
|
|
154
|
-
.accessibility(identifier: "description_popup_permission")
|
|
155
|
-
}
|
|
156
|
-
// Cap the visible height to ~8.5 lines
|
|
157
|
-
.frame(height: min(maxHeight8_5, textHeight))
|
|
158
|
-
} else {
|
|
159
|
-
MomoText(description, typography: .bodyDefaultRegular)
|
|
160
|
-
.multilineTextAlignment(.leading)
|
|
161
|
-
.background(GeometryReader { geo in
|
|
162
|
-
Color.clear.onAppear {
|
|
163
|
-
textHeight = geo.size.height
|
|
164
|
-
// Trigger scroll at ~8.5 lines
|
|
165
|
-
isScrollable = textHeight > maxHeight8_5
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
.measureLineHeights(font: .body_default_regular,
|
|
169
|
-
oneLine: $oneLineH,
|
|
170
|
-
twoLines: $twoLineH)
|
|
171
|
-
.accessibility(identifier: "description_popup_permission")
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
.padding(.bottom, 8)
|
|
126
|
+
.aspectRatio(1.777, contentMode: .fit)
|
|
127
|
+
.frame(maxWidth: .infinity, alignment: .center)
|
|
128
|
+
.clipShape(RoundedCorner(radius: 15, corners: [.topLeft, .topRight]))
|
|
129
|
+
.clipped()
|
|
130
|
+
}
|
|
131
|
+
VStack(alignment: .leading, spacing: 0) {
|
|
132
|
+
MomoText(title, typography: .headerDefaultBold)
|
|
133
|
+
.padding(.top, 24)
|
|
134
|
+
.padding(.bottom, 8)
|
|
135
|
+
.lineLimit(2)
|
|
136
|
+
.accessibility(identifier: "title_popup_permission")
|
|
175
137
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
138
|
+
Group {
|
|
139
|
+
if isScrollable {
|
|
140
|
+
ScrollView(showsIndicators: false) {
|
|
141
|
+
MomoText(description, typography: .bodyDefaultRegular)
|
|
142
|
+
.multilineTextAlignment(.leading)
|
|
143
|
+
.background(GeometryReader { geo in
|
|
144
|
+
Color.clear.onAppear { textHeight = geo.size.height }
|
|
145
|
+
})
|
|
146
|
+
.measureLineHeights(font: .body_default_regular,
|
|
147
|
+
oneLine: $oneLineH,
|
|
148
|
+
twoLines: $twoLineH)
|
|
149
|
+
.accessibility(identifier: "description_popup_permission")
|
|
180
150
|
}
|
|
151
|
+
// Cap the visible height to ~8.5 lines
|
|
152
|
+
.frame(height: min(maxHeight8_5, textHeight))
|
|
153
|
+
} else {
|
|
154
|
+
MomoText(description, typography: .bodyDefaultRegular)
|
|
155
|
+
.multilineTextAlignment(.leading)
|
|
156
|
+
.background(GeometryReader { geo in
|
|
157
|
+
Color.clear.onAppear {
|
|
158
|
+
textHeight = geo.size.height
|
|
159
|
+
// Trigger scroll at ~8.5 lines
|
|
160
|
+
isScrollable = textHeight > maxHeight8_5
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
.measureLineHeights(font: .body_default_regular,
|
|
164
|
+
oneLine: $oneLineH,
|
|
165
|
+
twoLines: $twoLineH)
|
|
166
|
+
.accessibility(identifier: "description_popup_permission")
|
|
181
167
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
168
|
+
}
|
|
169
|
+
.padding(.bottom, 8)
|
|
170
|
+
|
|
171
|
+
if(!errorCode.isEmpty) {
|
|
172
|
+
MomoText(localize.translate("errorCode") + errorCode, typography: .descriptionXsRegular, color: Colors.black12)
|
|
173
|
+
.lineLimit(1)
|
|
174
|
+
.padding(.bottom, 8)
|
|
185
175
|
}
|
|
186
176
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
177
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
178
|
+
.padding(.horizontal, 24)
|
|
179
|
+
.padding(.bottom, 16)
|
|
180
|
+
|
|
181
|
+
if shouldUseColumn {
|
|
182
|
+
if buttonType == .text {
|
|
183
|
+
ColumnTextButtons
|
|
195
184
|
} else {
|
|
196
|
-
|
|
197
|
-
RowTextButtons
|
|
198
|
-
} else {
|
|
199
|
-
RowButtons
|
|
200
|
-
}
|
|
185
|
+
ColumnButtons
|
|
201
186
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
.onChange(of: proxy.size.height) { actionsHeight = $0 }
|
|
187
|
+
} else {
|
|
188
|
+
if buttonType == .text {
|
|
189
|
+
RowTextButtons
|
|
190
|
+
} else {
|
|
191
|
+
RowButtons
|
|
208
192
|
}
|
|
209
|
-
|
|
193
|
+
}
|
|
210
194
|
}
|
|
211
195
|
.fixedSize(horizontal: false, vertical: true)
|
|
212
196
|
}
|
|
213
197
|
}
|
|
214
198
|
.background(Color.white.cornerRadius(15))
|
|
215
|
-
.frame(maxWidth:
|
|
199
|
+
.frame(maxWidth: popupMaxWidth - 24)
|
|
216
200
|
.padding(.horizontal, 12)
|
|
217
201
|
.accessibilityElement(children: .ignore)
|
|
218
202
|
.accessibility(identifier: "popup_notify")
|
|
@@ -3,6 +3,12 @@ import SwiftUI
|
|
|
3
3
|
|
|
4
4
|
public typealias PopupActionDirection = PopupButtonDirection
|
|
5
5
|
|
|
6
|
+
// Portrait width in landscape too, so aspect-ratio images don't push popups past the screen height.
|
|
7
|
+
var popupMaxWidth: CGFloat {
|
|
8
|
+
let size = UIScreen.main.bounds.size
|
|
9
|
+
return min(size.width, size.height)
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
public struct PopupNotifyProps {
|
|
7
13
|
public var image: String
|
|
8
14
|
public var title: String
|
|
@@ -40,12 +46,10 @@ public struct PopupNotifyProps {
|
|
|
40
46
|
public struct PopupNotify: View {
|
|
41
47
|
@Environment(\.localize) private var localize
|
|
42
48
|
@Environment(\.momoFontScale) private var fontScale
|
|
43
|
-
@Environment(\.screenLayout) private var layout
|
|
44
49
|
|
|
45
50
|
public let props: PopupNotifyProps
|
|
46
51
|
|
|
47
52
|
@State private var descriptionHeight: CGFloat = 0
|
|
48
|
-
@State private var actionsHeight: CGFloat = 0
|
|
49
53
|
|
|
50
54
|
private var errorCodePrefix: String {
|
|
51
55
|
localize.translate("errorCode")
|
|
@@ -73,26 +77,37 @@ public struct PopupNotify: View {
|
|
|
73
77
|
public var body: some View {
|
|
74
78
|
ZStack(alignment: .topTrailing) {
|
|
75
79
|
VStack(spacing: 0) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
if !props.image.isEmpty {
|
|
81
|
+
popupImage
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
VStack(alignment: .leading, spacing: 0) {
|
|
85
|
+
MomoText(
|
|
86
|
+
props.title,
|
|
87
|
+
typography: .headerDefaultBold,
|
|
88
|
+
maxLines: 2,
|
|
89
|
+
accessibilityId: "title_popup_permission"
|
|
90
|
+
)
|
|
91
|
+
.padding(.bottom, Spacing.S)
|
|
92
|
+
|
|
93
|
+
descriptionContent
|
|
94
|
+
|
|
95
|
+
if !props.error.isEmpty {
|
|
96
|
+
MomoText(
|
|
97
|
+
errorCodePrefix + props.error,
|
|
98
|
+
typography: .descriptionXsRegular,
|
|
99
|
+
color: Colors.black12,
|
|
100
|
+
maxLines: 1
|
|
101
|
+
)
|
|
102
|
+
.padding(.top, Spacing.S)
|
|
83
103
|
}
|
|
84
104
|
}
|
|
105
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
106
|
+
.padding(Spacing.XL)
|
|
85
107
|
|
|
86
108
|
actionButtons
|
|
87
109
|
.padding(.horizontal, Spacing.XL)
|
|
88
110
|
.padding(.bottom, Spacing.XL)
|
|
89
|
-
.background(
|
|
90
|
-
GeometryReader { proxy in
|
|
91
|
-
Color.clear
|
|
92
|
-
.onAppear { actionsHeight = proxy.size.height }
|
|
93
|
-
.onChange(of: proxy.size.height) { actionsHeight = $0 }
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
111
|
}
|
|
97
112
|
.background(Colors.black01)
|
|
98
113
|
.clipShape(RoundedRectangle(cornerRadius: Radius.L))
|
|
@@ -102,38 +117,12 @@ public struct PopupNotify: View {
|
|
|
102
117
|
.offset(x: 11, y: -11)
|
|
103
118
|
}
|
|
104
119
|
}
|
|
105
|
-
.frame(maxWidth:
|
|
120
|
+
.frame(maxWidth: popupMaxWidth - Spacing.M * 2)
|
|
106
121
|
.padding(.horizontal, Spacing.M)
|
|
107
122
|
.accessibilityElement(children: .ignore)
|
|
108
123
|
.accessibilityIdentifier("popup_notify")
|
|
109
124
|
}
|
|
110
125
|
|
|
111
|
-
private var textContent: some View {
|
|
112
|
-
VStack(alignment: .leading, spacing: 0) {
|
|
113
|
-
MomoText(
|
|
114
|
-
props.title,
|
|
115
|
-
typography: .headerDefaultBold,
|
|
116
|
-
maxLines: 2,
|
|
117
|
-
accessibilityId: "title_popup_permission"
|
|
118
|
-
)
|
|
119
|
-
.padding(.bottom, Spacing.S)
|
|
120
|
-
|
|
121
|
-
descriptionContent
|
|
122
|
-
|
|
123
|
-
if !props.error.isEmpty {
|
|
124
|
-
MomoText(
|
|
125
|
-
errorCodePrefix + props.error,
|
|
126
|
-
typography: .descriptionXsRegular,
|
|
127
|
-
color: Colors.black12,
|
|
128
|
-
maxLines: 1
|
|
129
|
-
)
|
|
130
|
-
.padding(.top, Spacing.S)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
.frame(maxWidth: .infinity, alignment: .leading)
|
|
134
|
-
.padding(Spacing.XL)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
126
|
private var popupImage: some View {
|
|
138
127
|
WebImage(url: URL(string: props.image), isAnimating: .constant(true))
|
|
139
128
|
.resizable()
|
|
@@ -3,7 +3,6 @@ import SDWebImageSwiftUI
|
|
|
3
3
|
|
|
4
4
|
public struct PopupPromotion: View {
|
|
5
5
|
@Environment(\.appTheme) private var theme
|
|
6
|
-
@Environment(\.screenLayout) private var layout
|
|
7
6
|
|
|
8
7
|
var imageUrl: String
|
|
9
8
|
var onIconClose: (() -> Void)?
|
|
@@ -20,33 +19,22 @@ public struct PopupPromotion: View {
|
|
|
20
19
|
self.onAction = onAction
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
private static let aspectRatio: CGFloat = 0.72
|
|
24
|
-
// close button row under the image: stack spacing + padded 40pt button
|
|
25
|
-
private static let closeRowHeight: CGFloat = 8 + 40 + Spacing.S * 2
|
|
26
|
-
|
|
27
|
-
// fit the portrait image by height when iPhone Duo leaves too little room
|
|
28
|
-
private var imageWidth: CGFloat {
|
|
29
|
-
let width = min(layout.width - Spacing.XL * 2, layout.popupMaxWidth)
|
|
30
|
-
guard let maxHeight = layout.popupMaxHeight else { return width }
|
|
31
|
-
return min(width, (maxHeight - Self.closeRowHeight) * Self.aspectRatio)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
22
|
public var body: some View {
|
|
35
23
|
VStack(spacing: 8) {
|
|
36
24
|
if(imageUrl.isEmpty) {
|
|
37
|
-
Icon(source: "media_fail", size:
|
|
25
|
+
Icon(source: "media_fail", size: popupMaxWidth - Spacing.XL * 2)
|
|
38
26
|
}
|
|
39
27
|
else {
|
|
40
|
-
WebImage(url: URL(string: imageUrl)
|
|
28
|
+
WebImage(url: URL(string: imageUrl))
|
|
41
29
|
.resizable()
|
|
42
30
|
.placeholder {
|
|
43
31
|
Color.gray
|
|
44
|
-
.aspectRatio(
|
|
45
|
-
.frame(maxWidth:
|
|
32
|
+
.aspectRatio(0.72, contentMode: .fit)
|
|
33
|
+
.frame(maxWidth: popupMaxWidth - Spacing.XL * 2)
|
|
46
34
|
.clipped()
|
|
47
35
|
}
|
|
48
|
-
.aspectRatio(
|
|
49
|
-
.frame(maxWidth:
|
|
36
|
+
.aspectRatio(0.72, contentMode: .fit)
|
|
37
|
+
.frame(maxWidth: popupMaxWidth - Spacing.XL * 2, alignment: .center)
|
|
50
38
|
.clipped()
|
|
51
39
|
.onTapGesture {
|
|
52
40
|
onAction?()
|