@momo-kits/native-kits 0.167.1-duo.3 → 0.167.1-duo.4
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/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/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -1
- package/package.json +1 -1
- package/scripts/gen-ios-icons.mjs +36 -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?()
|