@momo-kits/native-kits 0.113.3-webview.2 → 0.114.2-beta.1
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/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +24 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +1 -1
- package/ios/Swipeable/SwipeCell.swift +39 -31
- package/local.properties +2 -2
- package/package.json +1 -1
|
@@ -57,8 +57,8 @@ data class MiniAppContext(
|
|
|
57
57
|
|
|
58
58
|
val PlatformApi = staticCompositionLocalOf<Any?> { null }
|
|
59
59
|
|
|
60
|
-
val AppNavigator = staticCompositionLocalOf<Navigator
|
|
61
|
-
|
|
60
|
+
val AppNavigator = staticCompositionLocalOf<Navigator?> {
|
|
61
|
+
null
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
|
|
@@ -161,7 +161,7 @@ fun Screen(
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
if (useAnimationSearch && inputSearchProps != null && headerType == HeaderType.EXTENDED) {
|
|
164
|
-
Spacer(modifier = Modifier.padding(top = (HEADER_HEIGHT.dp + Spacing.
|
|
164
|
+
Spacer(modifier = Modifier.padding(top = (HEADER_HEIGHT.dp + Spacing.S)))
|
|
165
165
|
}
|
|
166
166
|
content()
|
|
167
167
|
}
|
|
@@ -21,6 +21,7 @@ import androidx.compose.foundation.text.KeyboardOptions
|
|
|
21
21
|
import androidx.compose.material3.CircularProgressIndicator
|
|
22
22
|
import androidx.compose.runtime.Composable
|
|
23
23
|
import androidx.compose.runtime.MutableState
|
|
24
|
+
import androidx.compose.runtime.SideEffect
|
|
24
25
|
import androidx.compose.runtime.getValue
|
|
25
26
|
import androidx.compose.runtime.mutableStateOf
|
|
26
27
|
import androidx.compose.runtime.remember
|
|
@@ -36,6 +37,7 @@ import androidx.compose.ui.text.TextStyle
|
|
|
36
37
|
import androidx.compose.ui.text.font.FontWeight
|
|
37
38
|
import androidx.compose.ui.text.input.KeyboardType
|
|
38
39
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
40
|
+
import androidx.compose.ui.text.input.TextFieldValue
|
|
39
41
|
import androidx.compose.ui.text.input.VisualTransformation
|
|
40
42
|
import androidx.compose.ui.unit.Dp
|
|
41
43
|
import androidx.compose.ui.unit.dp
|
|
@@ -154,7 +156,7 @@ fun ErrorView(errorMessage: String, errorSpacing: Boolean, hintText: String) {
|
|
|
154
156
|
|
|
155
157
|
@Composable
|
|
156
158
|
fun Input(
|
|
157
|
-
text:
|
|
159
|
+
text: String = "",
|
|
158
160
|
floatingValue: String = "",
|
|
159
161
|
floatingValueColor: Color = AppTheme.current.colors.text.hint,
|
|
160
162
|
floatingIcon: String = "",
|
|
@@ -181,6 +183,11 @@ fun Input(
|
|
|
181
183
|
keyboardType: KeyboardType = KeyboardType.Text,
|
|
182
184
|
modifier: Modifier = Modifier,
|
|
183
185
|
) {
|
|
186
|
+
// Handling state based on the `BasicTextField` concept
|
|
187
|
+
var textFieldValueState by remember { mutableStateOf(TextFieldValue(text = text)) }
|
|
188
|
+
val textFieldValue = textFieldValueState.copy(text = text)
|
|
189
|
+
var lastTextValue by remember(text) { mutableStateOf(text) }
|
|
190
|
+
|
|
184
191
|
var isFocused by remember { mutableStateOf(false) }
|
|
185
192
|
var passHidden by remember { mutableStateOf(false) }
|
|
186
193
|
var isBlurred = false
|
|
@@ -209,10 +216,10 @@ fun Input(
|
|
|
209
216
|
setAutomationId(testId)
|
|
210
217
|
) {
|
|
211
218
|
BasicTextField(
|
|
219
|
+
value = text,
|
|
212
220
|
enabled = !disabled,
|
|
213
221
|
readOnly = readOnly,
|
|
214
222
|
singleLine = true,
|
|
215
|
-
value = text.value,
|
|
216
223
|
textStyle = TextStyle(
|
|
217
224
|
color = textColor,
|
|
218
225
|
fontSize = 16.sp,
|
|
@@ -229,7 +236,15 @@ fun Input(
|
|
|
229
236
|
if (!it.isFocused && isBlurred) onBlur()
|
|
230
237
|
if (it.isFocused && !isBlurred) isBlurred = true
|
|
231
238
|
},
|
|
232
|
-
onValueChange =
|
|
239
|
+
onValueChange = { newValue ->
|
|
240
|
+
textFieldValueState.copy(text = newValue)
|
|
241
|
+
val stringChangedSinceLastInvocation = lastTextValue != newValue
|
|
242
|
+
lastTextValue = newValue
|
|
243
|
+
|
|
244
|
+
if (stringChangedSinceLastInvocation) {
|
|
245
|
+
onChangeText(newValue)
|
|
246
|
+
}
|
|
247
|
+
},
|
|
233
248
|
decorationBox = { innerTextField ->
|
|
234
249
|
// Floating Icon
|
|
235
250
|
if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
|
|
@@ -291,7 +306,7 @@ fun Input(
|
|
|
291
306
|
)
|
|
292
307
|
}
|
|
293
308
|
Box(Modifier.weight(1f)) {
|
|
294
|
-
if (text.
|
|
309
|
+
if (textFieldValue.text.isEmpty()) {
|
|
295
310
|
Text(
|
|
296
311
|
text = placeholder,
|
|
297
312
|
style = TextStyle(
|
|
@@ -304,7 +319,7 @@ fun Input(
|
|
|
304
319
|
}
|
|
305
320
|
innerTextField()
|
|
306
321
|
}
|
|
307
|
-
if (isFocused && text.
|
|
322
|
+
if (isFocused && textFieldValue.text.isNotEmpty()) {
|
|
308
323
|
Row {
|
|
309
324
|
Spacer(Modifier.width(Spacing.XS))
|
|
310
325
|
Icon(
|
|
@@ -312,7 +327,10 @@ fun Input(
|
|
|
312
327
|
size = 16.dp,
|
|
313
328
|
color = AppTheme.current.colors.text.hint,
|
|
314
329
|
modifier = Modifier.clickable(
|
|
315
|
-
onClick = {
|
|
330
|
+
onClick = {
|
|
331
|
+
onChangeText("")
|
|
332
|
+
textFieldValueState = TextFieldValue(text = "")
|
|
333
|
+
},
|
|
316
334
|
interactionSource = remember { MutableInteractionSource() },
|
|
317
335
|
indication = null
|
|
318
336
|
)
|
|
@@ -143,7 +143,7 @@ fun PopupNotify(
|
|
|
143
143
|
Modifier
|
|
144
144
|
.width(22.dp)
|
|
145
145
|
.height(22.dp)
|
|
146
|
-
.offset(x =
|
|
146
|
+
.offset(x = -(4).dp, y = (-10).dp)
|
|
147
147
|
.background(
|
|
148
148
|
color = AppTheme.current.colors.text.default,
|
|
149
149
|
shape = RoundedCornerShape(Radius.M)
|
|
@@ -10,9 +10,9 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
10
10
|
var trailingSideGroup: [SwipeCellActionItem] = []
|
|
11
11
|
@Binding var currentUserInteractionCellID: String?
|
|
12
12
|
var settings: SwipeCellSettings = .init()
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
@State private var offsetX: CGFloat = 0
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
let generator = UINotificationFeedbackGenerator()
|
|
17
17
|
@State private var hapticFeedbackOccurred: Bool = false
|
|
18
18
|
@State private var openSideLock: SwipeGroupSide?
|
|
@@ -22,15 +22,23 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
22
22
|
if self.leadingSideGroup.isEmpty == false && self.offsetX != 0 {
|
|
23
23
|
self.swipeToRevealArea(swipeItemGroup: self.leadingSideGroup, side: .leading)
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
if self.trailingSideGroup.isEmpty == false && self.offsetX != 0 {
|
|
27
27
|
self.swipeToRevealArea(swipeItemGroup: self.trailingSideGroup, side: .trailing)
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
content
|
|
31
31
|
.offset(x: self.offsetX)
|
|
32
|
-
.
|
|
33
|
-
|
|
32
|
+
.simultaneousGesture(
|
|
33
|
+
DragGesture(minimumDistance: 30, coordinateSpace: .local)
|
|
34
|
+
.onChanged { value in
|
|
35
|
+
self.dragOnChanged(value: value)
|
|
36
|
+
}
|
|
37
|
+
.onEnded { value in
|
|
38
|
+
self.dragOnEnded(value: value)
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
34
42
|
}.frame(width: cellWidth)
|
|
35
43
|
.edgesIgnoringSafeArea(.horizontal)
|
|
36
44
|
.clipped()
|
|
@@ -43,7 +51,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
|
-
|
|
54
|
+
|
|
47
55
|
internal func swipeToRevealArea(swipeItemGroup: [SwipeCellActionItem], side: SwipeGroupSide)->some View {
|
|
48
56
|
HStack {
|
|
49
57
|
if side == .trailing {
|
|
@@ -63,17 +71,17 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
}.opacity(self.swipeRevealAreaOpacity(side: side))
|
|
66
|
-
|
|
74
|
+
|
|
67
75
|
if side == .leading {
|
|
68
76
|
Spacer()
|
|
69
77
|
}
|
|
70
78
|
}
|
|
71
79
|
}
|
|
72
|
-
|
|
80
|
+
|
|
73
81
|
internal func buttonContentView(item: SwipeCellActionItem, group: [SwipeCellActionItem], side: SwipeGroupSide)->some View {
|
|
74
82
|
ZStack {
|
|
75
83
|
item.backgroundColor
|
|
76
|
-
|
|
84
|
+
|
|
77
85
|
HStack {
|
|
78
86
|
if self.warnSwipeOutCondition(side: side, hasSwipeOut: item.swipeOutAction) && item.swipeOutButtonView != nil {
|
|
79
87
|
item.swipeOutButtonView!()
|
|
@@ -81,28 +89,28 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
81
89
|
item.buttonView()
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
|
-
|
|
92
|
+
|
|
85
93
|
}.frame(width: self.itemButtonWidth(item: item, itemGroup: group, side: side))
|
|
86
94
|
}
|
|
87
|
-
|
|
95
|
+
|
|
88
96
|
internal func menuWidth(side: SwipeGroupSide)->CGFloat {
|
|
89
97
|
switch side {
|
|
90
98
|
case .leading:
|
|
91
99
|
return self.leadingSideGroup.map { $0.buttonWidth }.reduce(0, +)
|
|
92
|
-
|
|
100
|
+
|
|
93
101
|
case .trailing:
|
|
94
102
|
return self.trailingSideGroup.map { $0.buttonWidth }.reduce(0, +)
|
|
95
103
|
}
|
|
96
104
|
}
|
|
97
|
-
|
|
105
|
+
|
|
98
106
|
// MARK: drag gesture
|
|
99
|
-
|
|
107
|
+
|
|
100
108
|
internal func dragOnChanged(value: DragGesture.Value) {
|
|
101
109
|
let horizontalTranslation = value.translation.width
|
|
102
110
|
if self.nonDraggableCondition(horizontalTranslation: horizontalTranslation) {
|
|
103
111
|
return
|
|
104
112
|
}
|
|
105
|
-
|
|
113
|
+
|
|
106
114
|
if self.openSideLock != nil {
|
|
107
115
|
// if one side is open, we need to add the menu width!
|
|
108
116
|
let menuWidth = self.openSideLock == .leading ? self.menuWidth(side: .leading) : self.menuWidth(side: .trailing)
|
|
@@ -110,9 +118,9 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
110
118
|
self.triggerHapticFeedbackIfNeeded(horizontalTranslation: horizontalTranslation)
|
|
111
119
|
return
|
|
112
120
|
}
|
|
113
|
-
|
|
121
|
+
|
|
114
122
|
self.triggerHapticFeedbackIfNeeded(horizontalTranslation: horizontalTranslation)
|
|
115
|
-
|
|
123
|
+
|
|
116
124
|
if horizontalTranslation > 8 || horizontalTranslation < -8 { // makes sure the swipe cell doesn't open too easily
|
|
117
125
|
self.currentUserInteractionCellID = self.id
|
|
118
126
|
self.offsetX = horizontalTranslation
|
|
@@ -120,11 +128,11 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
120
128
|
self.offsetX = 0
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
|
-
|
|
131
|
+
|
|
124
132
|
internal func nonDraggableCondition(horizontalTranslation: CGFloat)->Bool {
|
|
125
133
|
return self.offsetX == 0 && (self.leadingSideGroup.isEmpty && horizontalTranslation > 0 || self.trailingSideGroup.isEmpty && horizontalTranslation < 0)
|
|
126
134
|
}
|
|
127
|
-
|
|
135
|
+
|
|
128
136
|
internal func dragOnEnded(value: DragGesture.Value) {
|
|
129
137
|
let swipeOutTriggerValue = self.cellWidth * self.settings.swipeOutTriggerRatio
|
|
130
138
|
|
|
@@ -139,7 +147,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
139
147
|
} else {
|
|
140
148
|
self.lockSideMenu(side: .leading)
|
|
141
149
|
}
|
|
142
|
-
|
|
150
|
+
|
|
143
151
|
} else {
|
|
144
152
|
// leading group emtpy
|
|
145
153
|
self.setOffsetX(value: 0)
|
|
@@ -160,7 +168,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
160
168
|
}
|
|
161
169
|
}
|
|
162
170
|
}
|
|
163
|
-
|
|
171
|
+
|
|
164
172
|
internal func triggerHapticFeedbackIfNeeded(horizontalTranslation: CGFloat) {
|
|
165
173
|
let side: SwipeGroupSide = horizontalTranslation > 0 ? .leading : .trailing
|
|
166
174
|
let group = side == .leading ? self.leadingSideGroup : self.trailingSideGroup
|
|
@@ -170,7 +178,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
170
178
|
self.hapticFeedbackOccurred = true
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
|
-
|
|
181
|
+
|
|
174
182
|
internal func swipeOutItemWithHapticFeedback(group: [SwipeCellActionItem])->SwipeCellActionItem? {
|
|
175
183
|
if let item = group.filter({ $0.swipeOutAction == true }).first {
|
|
176
184
|
if item.swipeOutHapticFeedbackType != nil {
|
|
@@ -179,7 +187,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
179
187
|
}
|
|
180
188
|
return nil
|
|
181
189
|
}
|
|
182
|
-
|
|
190
|
+
|
|
183
191
|
internal func swipeOutAction(item: SwipeCellActionItem, sideFactor: CGFloat) {
|
|
184
192
|
if item.swipeOutIsDestructive {
|
|
185
193
|
let swipeOutWidth = cellWidth + 10
|
|
@@ -188,12 +196,12 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
188
196
|
} else {
|
|
189
197
|
self.setOffsetX(value: 0) // open side lock set in function!
|
|
190
198
|
}
|
|
191
|
-
|
|
199
|
+
|
|
192
200
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
|
193
201
|
item.actionCallback()
|
|
194
202
|
}
|
|
195
203
|
}
|
|
196
|
-
|
|
204
|
+
|
|
197
205
|
internal func lockSideMenu(side: SwipeGroupSide) {
|
|
198
206
|
self.setOffsetX(value: side.sideFactor * self.menuWidth(side: side))
|
|
199
207
|
self.openSideLock = side
|
|
@@ -214,7 +222,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
214
222
|
let dynamicButtonWidth = self.dynamicButtonWidth(item: item, itemCount: itemGroup.count, side: side)
|
|
215
223
|
let triggerValue = self.cellWidth * settings.swipeOutTriggerRatio
|
|
216
224
|
let swipeOutActionCondition = side == .leading ? self.offsetX > triggerValue : self.offsetX < -triggerValue
|
|
217
|
-
|
|
225
|
+
|
|
218
226
|
if item.swipeOutAction && swipeOutActionCondition {
|
|
219
227
|
return self.offsetX.magnitude + settings.addWidthMargin
|
|
220
228
|
} else if swipeOutActionCondition && item.swipeOutAction == false && itemGroup.contains(where: { $0.swipeOutAction == true }) {
|
|
@@ -223,12 +231,12 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
223
231
|
return dynamicButtonWidth
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
|
-
|
|
234
|
+
|
|
227
235
|
internal func dynamicButtonWidth(item: SwipeCellActionItem, itemCount: Int, side: SwipeGroupSide)->CGFloat {
|
|
228
236
|
let menuWidth = self.menuWidth(side: side)
|
|
229
237
|
return (self.offsetX.magnitude + settings.addWidthMargin) * (item.buttonWidth / menuWidth)
|
|
230
238
|
}
|
|
231
|
-
|
|
239
|
+
|
|
232
240
|
internal func warnSwipeOutCondition(side: SwipeGroupSide, hasSwipeOut: Bool)->Bool {
|
|
233
241
|
if hasSwipeOut == false {
|
|
234
242
|
return false
|
|
@@ -236,11 +244,11 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
236
244
|
let triggerValue = self.cellWidth * settings.swipeOutTriggerRatio
|
|
237
245
|
return (side == .trailing && self.offsetX < -triggerValue) || (side == .leading && self.offsetX > triggerValue)
|
|
238
246
|
}
|
|
239
|
-
|
|
247
|
+
|
|
240
248
|
internal func swipeRevealAreaOpacity(side: SwipeGroupSide)->Double {
|
|
241
249
|
switch side {
|
|
242
250
|
case .leading:
|
|
243
|
-
|
|
251
|
+
|
|
244
252
|
return self.offsetX > 5 ? 1 : 0
|
|
245
253
|
case .trailing:
|
|
246
254
|
return self.offsetX < -5 ? 1 : 0
|
package/local.properties
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
# Location of the SDK. This is only used by Gradle.
|
|
5
5
|
# For customization when using a Version Control System, please read the
|
|
6
6
|
# header note.
|
|
7
|
-
#
|
|
8
|
-
sdk.dir=/Users/
|
|
7
|
+
#Wed Aug 21 14:20:12 ICT 2024
|
|
8
|
+
sdk.dir=/Users/huynhdung/Library/Android/sdk
|