@momo-kits/native-kits 0.113.1-beta.3 → 0.113.1-beta.5
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.
|
@@ -40,8 +40,6 @@ import vn.momo.kits.utils.ifNotNull
|
|
|
40
40
|
data class PopupAction(
|
|
41
41
|
val title: String,
|
|
42
42
|
val onPress: (() -> Unit)?,
|
|
43
|
-
val onPressMiniapp: ((Int) -> Unit)? = null,
|
|
44
|
-
val typePopupDisplay: String? = null
|
|
45
43
|
)
|
|
46
44
|
|
|
47
45
|
enum class PopupActionDirection {
|
|
@@ -60,7 +58,6 @@ fun PopupNotify(
|
|
|
60
58
|
secondary: PopupAction? = null,
|
|
61
59
|
buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
|
|
62
60
|
onIconClose: () -> Unit,
|
|
63
|
-
buttons: List<String>? = emptyList()
|
|
64
61
|
) {
|
|
65
62
|
var isScroll by remember { mutableStateOf(false) }
|
|
66
63
|
val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }
|
|
@@ -98,10 +95,6 @@ fun PopupNotify(
|
|
|
98
95
|
callback?.invoke()
|
|
99
96
|
}
|
|
100
97
|
|
|
101
|
-
fun onCloseMiniapp(callback: ((Int) -> Unit)?) {
|
|
102
|
-
callback?.invoke(buttons?.indexOf(buttons.first()) ?: -1)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
98
|
Box(Modifier.semantics {
|
|
106
99
|
testTag = "popup_notify"
|
|
107
100
|
}, contentAlignment = Alignment.TopEnd) {
|
|
@@ -129,7 +122,7 @@ fun PopupNotify(
|
|
|
129
122
|
text = error,
|
|
130
123
|
style = Typography.descriptionXs,
|
|
131
124
|
color = AppTheme.current.colors.text.hint,
|
|
132
|
-
maxLines =
|
|
125
|
+
maxLines = 1,
|
|
133
126
|
modifier = Modifier.padding(top = Spacing.S)
|
|
134
127
|
)
|
|
135
128
|
}
|
|
@@ -141,7 +134,7 @@ fun PopupNotify(
|
|
|
141
134
|
) {
|
|
142
135
|
BuildAction(primary, secondary, buttonDirection, onAction = { callback ->
|
|
143
136
|
onClose(callback)
|
|
144
|
-
}
|
|
137
|
+
})
|
|
145
138
|
}
|
|
146
139
|
}
|
|
147
140
|
|
|
@@ -185,7 +178,6 @@ fun BuildAction(
|
|
|
185
178
|
secondary: PopupAction?,
|
|
186
179
|
buttonDirection: PopupActionDirection = PopupActionDirection.ROW,
|
|
187
180
|
onAction: (onPress: (() -> Unit)?) -> Unit,
|
|
188
|
-
onActionMiniapp: (onPress: ((Int) -> Unit)?) -> Unit,
|
|
189
181
|
) {
|
|
190
182
|
val closeAction = remember { mutableStateOf("button_action") }
|
|
191
183
|
when (buttonDirection) {
|
|
@@ -202,8 +194,7 @@ fun BuildAction(
|
|
|
202
194
|
secondary = secondary,
|
|
203
195
|
onAction = onAction,
|
|
204
196
|
closeAction = closeAction,
|
|
205
|
-
primary = primary
|
|
206
|
-
onActionMiniapp = onActionMiniapp
|
|
197
|
+
primary = primary
|
|
207
198
|
)
|
|
208
199
|
}
|
|
209
200
|
}
|
|
@@ -212,8 +203,7 @@ fun BuildAction(
|
|
|
212
203
|
secondary = secondary,
|
|
213
204
|
onAction = onAction,
|
|
214
205
|
closeAction = closeAction,
|
|
215
|
-
primary = primary
|
|
216
|
-
onActionMiniapp = onActionMiniapp
|
|
206
|
+
primary = primary
|
|
217
207
|
)
|
|
218
208
|
|
|
219
209
|
else -> renderColumn(
|
|
@@ -231,7 +221,6 @@ fun renderRow(
|
|
|
231
221
|
closeAction: MutableState<String>,
|
|
232
222
|
primary: PopupAction?,
|
|
233
223
|
onAction: (onPress: (() -> Unit)?) -> Unit,
|
|
234
|
-
onActionMiniapp: ((onPress: ((Int) -> Unit)?) -> Unit)? = null,
|
|
235
224
|
) {
|
|
236
225
|
Row(horizontalArrangement = Arrangement.Center) {
|
|
237
226
|
secondary?.let {
|
|
@@ -256,10 +245,7 @@ fun renderRow(
|
|
|
256
245
|
size = Size.MEDIUM,
|
|
257
246
|
onClick = {
|
|
258
247
|
closeAction.value = "button_action"
|
|
259
|
-
|
|
260
|
-
onActionMiniapp?.invoke(primary.onPressMiniapp)
|
|
261
|
-
else
|
|
262
|
-
onAction( primary?.onPress)
|
|
248
|
+
onAction(primary?.onPress)
|
|
263
249
|
},
|
|
264
250
|
title = primary?.title ?: "",
|
|
265
251
|
modifier = Modifier.semantics {
|
|
@@ -276,17 +262,13 @@ fun renderColumn(
|
|
|
276
262
|
closeAction: MutableState<String>,
|
|
277
263
|
primary: PopupAction?,
|
|
278
264
|
onAction: (onPress: (() -> Unit)?) -> Unit,
|
|
279
|
-
onActionMiniapp: ((onPress: ((Int) -> Unit)?) -> Unit)? = null,
|
|
280
265
|
) {
|
|
281
266
|
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
|
282
267
|
Button(
|
|
283
268
|
size = Size.MEDIUM,
|
|
284
269
|
onClick = {
|
|
285
270
|
closeAction.value = "button_action"
|
|
286
|
-
|
|
287
|
-
onActionMiniapp?.invoke(primary.onPressMiniapp)
|
|
288
|
-
else
|
|
289
|
-
onAction( primary?.onPress)
|
|
271
|
+
onAction(primary?.onPress)
|
|
290
272
|
},
|
|
291
273
|
title = primary?.title ?: "",
|
|
292
274
|
modifier = Modifier.semantics {
|
|
@@ -218,6 +218,69 @@ public struct Header: View {
|
|
|
218
218
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
public struct HeaderContainerView: View {
|
|
222
|
+
var headerType: HeaderType = .default
|
|
223
|
+
var titlePosition: TitlePosition
|
|
224
|
+
var title: String
|
|
225
|
+
var headerRight: (() -> AnyView)?
|
|
226
|
+
var goBack: (() -> Void)?
|
|
227
|
+
var opacity: CGFloat? = nil
|
|
228
|
+
var animatedHeader: AnimatedHeader? = nil
|
|
229
|
+
var scrollState: CGFloat = 0
|
|
230
|
+
var inputSearchProps: InputSearchProps? = nil
|
|
231
|
+
|
|
232
|
+
@State private var colorFraction: CGFloat = 0
|
|
233
|
+
|
|
234
|
+
public init(
|
|
235
|
+
headerType: HeaderType = .default,
|
|
236
|
+
titlePosition: TitlePosition,
|
|
237
|
+
title: String,
|
|
238
|
+
headerRight: (() -> AnyView)? = nil,
|
|
239
|
+
goBack: (() -> Void)? = nil,
|
|
240
|
+
opacity: CGFloat? = nil,
|
|
241
|
+
animatedHeader: AnimatedHeader? = nil,
|
|
242
|
+
scrollState: CGFloat = 0,
|
|
243
|
+
inputSearchProps: InputSearchProps? = nil
|
|
244
|
+
) {
|
|
245
|
+
self.headerType = headerType
|
|
246
|
+
self.titlePosition = titlePosition
|
|
247
|
+
self.title = title
|
|
248
|
+
self.headerRight = headerRight
|
|
249
|
+
self.goBack = goBack
|
|
250
|
+
self.opacity = opacity
|
|
251
|
+
self.animatedHeader = animatedHeader
|
|
252
|
+
self.scrollState = scrollState
|
|
253
|
+
self.inputSearchProps = inputSearchProps
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@State private var scrollOffset: CGFloat = 0
|
|
257
|
+
|
|
258
|
+
public var body: some View {
|
|
259
|
+
ZStack {
|
|
260
|
+
if animatedHeader == nil {
|
|
261
|
+
HeaderBackground(headerType: headerType, scrollState: scrollOffset)
|
|
262
|
+
} else {
|
|
263
|
+
Color.white.opacity(Double(min(scrollOffset / 114, 1)))
|
|
264
|
+
.overlay(HeaderBackground(headerType: headerType, scrollState: scrollOffset))
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
Header(
|
|
269
|
+
headerType: headerType,
|
|
270
|
+
titlePosition: titlePosition,
|
|
271
|
+
title: title,
|
|
272
|
+
headerRight: headerRight,
|
|
273
|
+
goBack: goBack,
|
|
274
|
+
opacity: min(scrollOffset / 114, 1),
|
|
275
|
+
animatedHeader: animatedHeader,
|
|
276
|
+
scrollState: scrollOffset,
|
|
277
|
+
inputSearchProps: inputSearchProps
|
|
278
|
+
).padding(.bottom, headerType == .extended ? 0 : -safeAreaTopInset())
|
|
279
|
+
}.padding(.top, -safeAreaTopInset())
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
221
284
|
|
|
222
285
|
|
|
223
286
|
|
|
@@ -76,6 +76,17 @@ public struct Screen<Content: View>: View {
|
|
|
76
76
|
let keyboardHeight: CGFloat = 0
|
|
77
77
|
let keyboardSize: CGFloat = useAvoidKeyboard ? max(keyboardHeight, 0) : 0
|
|
78
78
|
|
|
79
|
+
var headerHeight: CGFloat {
|
|
80
|
+
switch headerType {
|
|
81
|
+
case .default:
|
|
82
|
+
return 52
|
|
83
|
+
case .extended:
|
|
84
|
+
return 154
|
|
85
|
+
case .none:
|
|
86
|
+
return 0
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
79
90
|
ZStack {
|
|
80
91
|
(backgroundColor ?? Color.white).edgesIgnoringSafeArea(.all)
|
|
81
92
|
|
|
@@ -113,6 +124,7 @@ public struct Screen<Content: View>: View {
|
|
|
113
124
|
VStack {
|
|
114
125
|
content()
|
|
115
126
|
}
|
|
127
|
+
// .frame(width: geometry.size.width, height: geometry.size.height + 600)
|
|
116
128
|
.background(GeometryReader { geo -> Color in
|
|
117
129
|
DispatchQueue.main.async {
|
|
118
130
|
self.scrollOffset = -geo.frame(in: .global).origin.y
|
|
@@ -122,6 +134,7 @@ public struct Screen<Content: View>: View {
|
|
|
122
134
|
}
|
|
123
135
|
} else {
|
|
124
136
|
content()
|
|
137
|
+
// .frame(width: geometry.size.width, height: geometry.size.height + 104)
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
140
|
.padding(.bottom, keyboardSize)
|
|
@@ -20,7 +20,7 @@ public enum PopupButtonType {
|
|
|
20
20
|
public struct PopupDisplay: View {
|
|
21
21
|
// MARK: Lifecycle
|
|
22
22
|
|
|
23
|
-
public init(isPresented: Binding<Bool>, title: String = "", description: String = "", url: String = "", buttonDirection: PopupButtonDirection = .column, buttonType: PopupButtonType = .button, actionButtonTitle: String = "", closeButtonTitle: String = "", onPressAction: @escaping () -> Void = {}, onPressCloseButton: @escaping () -> Void = {}, onClose: @escaping () -> Void = {}
|
|
23
|
+
public init(isPresented: Binding<Bool>, title: String = "", description: String = "", url: String = "", buttonDirection: PopupButtonDirection = .column, buttonType: PopupButtonType = .button, actionButtonTitle: String = "", closeButtonTitle: String = "", onPressAction: @escaping () -> Void = {}, onPressCloseButton: @escaping () -> Void = {}, onClose: @escaping () -> Void = {}) {
|
|
24
24
|
self._isPresented = isPresented
|
|
25
25
|
self.title = title
|
|
26
26
|
self.description = description
|
|
@@ -32,9 +32,6 @@ public struct PopupDisplay: View {
|
|
|
32
32
|
self.onClose = onClose
|
|
33
33
|
self.closeButtonTitle = closeButtonTitle
|
|
34
34
|
self.actionButtonTitle = actionButtonTitle
|
|
35
|
-
self.onPressMiniapp = onPressMiniapp
|
|
36
|
-
self.typePopupDisplay = typePopupDisplay
|
|
37
|
-
self.buttons = buttons
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
// MARK: Public
|
|
@@ -110,10 +107,7 @@ public struct PopupDisplay: View {
|
|
|
110
107
|
var onClose: () -> Void
|
|
111
108
|
var actionButtonTitle: String
|
|
112
109
|
var closeButtonTitle: String
|
|
113
|
-
|
|
114
|
-
var onPressMiniapp: ((_ index: Int)->Void)?
|
|
115
|
-
var buttons: [String]?
|
|
116
|
-
|
|
110
|
+
|
|
117
111
|
var RowTextButtons: some View {
|
|
118
112
|
HStack {
|
|
119
113
|
SwiftUI.Button(action: onPressCloseButton) {
|
|
@@ -151,15 +145,7 @@ public struct PopupDisplay: View {
|
|
|
151
145
|
var RowButtons: some View {
|
|
152
146
|
HStack {
|
|
153
147
|
Button(title: closeButtonTitle, action: onPressCloseButton, type: .secondary)
|
|
154
|
-
Button(
|
|
155
|
-
title: actionButtonTitle,
|
|
156
|
-
action: {if(typePopupDisplay == "miniapp") {
|
|
157
|
-
onPressMiniapp?(buttons?.startIndex ?? -1)
|
|
158
|
-
} else {
|
|
159
|
-
onPressAction()
|
|
160
|
-
} }
|
|
161
|
-
)
|
|
162
|
-
|
|
148
|
+
Button(title: actionButtonTitle, action: onPressAction)
|
|
163
149
|
}
|
|
164
150
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
165
151
|
.padding(.horizontal, 24)
|
|
@@ -170,11 +156,7 @@ public struct PopupDisplay: View {
|
|
|
170
156
|
VStack(alignment: .trailing) {
|
|
171
157
|
Button(
|
|
172
158
|
title: actionButtonTitle,
|
|
173
|
-
action:
|
|
174
|
-
onPressMiniapp?(buttons?.startIndex ?? -1)
|
|
175
|
-
} else {
|
|
176
|
-
onPressAction()
|
|
177
|
-
} }
|
|
159
|
+
action: onPressAction
|
|
178
160
|
)
|
|
179
161
|
Button(title: closeButtonTitle, action: onPressCloseButton, type: .secondary)
|
|
180
162
|
}
|