@momo-kits/native-kits 0.89.33-beta.27 → 0.89.33-beta.30
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.
|
@@ -17,6 +17,10 @@ val AppNavigator = staticCompositionLocalOf<Navigator> {
|
|
|
17
17
|
error("no navigator provided!")
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
val PlatformApi = staticCompositionLocalOf<ComposeApi> {
|
|
21
|
+
error("no api provided!")
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
class Navigator {
|
|
21
25
|
fun push(content: @Composable () -> Unit) {
|
|
22
26
|
}
|
|
@@ -49,14 +53,23 @@ class Navigator {
|
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
interface ComposeApi {
|
|
57
|
+
fun request(funcName: String, params: String?): String
|
|
58
|
+
fun request(funcName: String, params: String?, onResponse: ((String) -> Unit)?): String
|
|
59
|
+
fun requestCallback(funcName: String, params: String?, onResponse: ((String) -> Unit)?)
|
|
60
|
+
fun removeCallback(id: String)
|
|
61
|
+
}
|
|
62
|
+
|
|
52
63
|
@Composable
|
|
53
64
|
fun ApplicationContainer(
|
|
54
65
|
theme: Theme = defaultTheme,
|
|
66
|
+
composeApi: ComposeApi,
|
|
55
67
|
content: @Composable () -> Unit,
|
|
56
68
|
) {
|
|
57
69
|
disableOverscroll()
|
|
58
70
|
CompositionLocalProvider(
|
|
59
71
|
AppTheme provides theme,
|
|
72
|
+
PlatformApi provides composeApi,
|
|
60
73
|
AppNavigator provides Navigator(),
|
|
61
74
|
AppStatusBar provides getStatusBarHeight(),
|
|
62
75
|
) {
|
|
@@ -70,6 +70,7 @@ fun Screen(
|
|
|
70
70
|
content: @Composable () -> Unit,
|
|
71
71
|
) {
|
|
72
72
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
73
|
+
val platformApi = PlatformApi.current
|
|
73
74
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
74
75
|
val keyboardHeight = WindowInsets.ime.asPaddingValues().calculateBottomPadding()
|
|
75
76
|
val keyboardSize = when {
|
|
@@ -15,7 +15,6 @@ import androidx.compose.foundation.layout.size
|
|
|
15
15
|
import androidx.compose.foundation.layout.width
|
|
16
16
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
17
17
|
import androidx.compose.foundation.text.BasicTextField
|
|
18
|
-
import androidx.compose.foundation.text.KeyboardActions
|
|
19
18
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
20
19
|
import androidx.compose.material3.CircularProgressIndicator
|
|
21
20
|
import androidx.compose.runtime.Composable
|
|
@@ -30,7 +29,6 @@ import androidx.compose.ui.focus.onFocusChanged
|
|
|
30
29
|
import androidx.compose.ui.graphics.Color
|
|
31
30
|
import androidx.compose.ui.text.TextStyle
|
|
32
31
|
import androidx.compose.ui.text.input.KeyboardType
|
|
33
|
-
import androidx.compose.ui.text.style.TextOverflow
|
|
34
32
|
import androidx.compose.ui.unit.dp
|
|
35
33
|
import androidx.compose.ui.unit.sp
|
|
36
34
|
import vn.momo.kits.const.AppTheme
|
|
@@ -46,7 +44,6 @@ fun RenderRightIconSearch(
|
|
|
46
44
|
icon: String,
|
|
47
45
|
color: Color,
|
|
48
46
|
onClick: () -> Unit,
|
|
49
|
-
iconModifier: Modifier = Modifier
|
|
50
47
|
) {
|
|
51
48
|
if (loading) {
|
|
52
49
|
Box(Modifier.padding(horizontal = Spacing.S)) {
|
|
@@ -67,7 +64,7 @@ fun RenderRightIconSearch(
|
|
|
67
64
|
source = icon,
|
|
68
65
|
color = color,
|
|
69
66
|
size = 24.dp,
|
|
70
|
-
modifier =
|
|
67
|
+
modifier = Modifier.padding(start = Spacing.S, end = 0.dp).clickable(
|
|
71
68
|
onClick = onClick,
|
|
72
69
|
interactionSource = remember { MutableInteractionSource() },
|
|
73
70
|
indication = null
|
|
@@ -93,12 +90,6 @@ data class InputSearchProps(
|
|
|
93
90
|
val fontWeight: InputFontWeight = InputFontWeight.REGULAR,
|
|
94
91
|
val keyboardType: KeyboardType = KeyboardType.Text,
|
|
95
92
|
val backgroundColor: Color = Colors.black_01,
|
|
96
|
-
val clearCondition: (() -> Boolean)? = null,
|
|
97
|
-
val keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
|
|
98
|
-
val keyboardActions: KeyboardActions = KeyboardActions.Default,
|
|
99
|
-
val modifier: Modifier = Modifier,
|
|
100
|
-
val iconModifier: Modifier = Modifier,
|
|
101
|
-
val onClearPress: () -> Unit = {}
|
|
102
93
|
)
|
|
103
94
|
|
|
104
95
|
@Composable
|
|
@@ -107,6 +98,7 @@ fun InputSearch(
|
|
|
107
98
|
text = remember { mutableStateOf("") },
|
|
108
99
|
iconColor = AppTheme.current.colors.text.default
|
|
109
100
|
),
|
|
101
|
+
|
|
110
102
|
) {
|
|
111
103
|
var isFocused by remember { mutableStateOf(false) }
|
|
112
104
|
var isBlurred = false
|
|
@@ -132,9 +124,8 @@ fun InputSearch(
|
|
|
132
124
|
lineHeight = 20.sp,
|
|
133
125
|
fontWeight = inputSearchProps.fontWeight.value
|
|
134
126
|
),
|
|
135
|
-
keyboardOptions =
|
|
136
|
-
|
|
137
|
-
modifier = inputSearchProps.modifier.height(36.dp).onFocusChanged {
|
|
127
|
+
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = inputSearchProps.keyboardType),
|
|
128
|
+
modifier = Modifier.height(36.dp).onFocusChanged {
|
|
138
129
|
isFocused = it.isFocused
|
|
139
130
|
if (it.isFocused) {
|
|
140
131
|
inputSearchProps.onFocus()
|
|
@@ -146,12 +137,7 @@ fun InputSearch(
|
|
|
146
137
|
decorationBox = { innerTextField ->
|
|
147
138
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
148
139
|
Row(
|
|
149
|
-
modifier = Modifier.weight(
|
|
150
|
-
inputSearchProps.showButtonText.ifTrue(
|
|
151
|
-
8f,
|
|
152
|
-
1f
|
|
153
|
-
)
|
|
154
|
-
)
|
|
140
|
+
modifier = Modifier.weight(inputSearchProps.showButtonText.ifTrue(8f, 1f))
|
|
155
141
|
.background(
|
|
156
142
|
inputSearchProps.backgroundColor,
|
|
157
143
|
RoundedCornerShape(Radius.XL)
|
|
@@ -166,6 +152,7 @@ fun InputSearch(
|
|
|
166
152
|
),
|
|
167
153
|
verticalAlignment = Alignment.CenterVertically
|
|
168
154
|
) {
|
|
155
|
+
//leading icon
|
|
169
156
|
Icon(
|
|
170
157
|
source = "navigation_search",
|
|
171
158
|
modifier = Modifier.padding(end = Spacing.XS),
|
|
@@ -181,14 +168,12 @@ fun InputSearch(
|
|
|
181
168
|
lineHeight = 24.sp,
|
|
182
169
|
fontWeight = inputSearchProps.fontWeight.value
|
|
183
170
|
),
|
|
184
|
-
|
|
185
|
-
color = placeholderColor,
|
|
186
|
-
overflow = TextOverflow.Ellipsis
|
|
171
|
+
color = placeholderColor
|
|
187
172
|
)
|
|
188
173
|
}
|
|
189
174
|
innerTextField()
|
|
190
175
|
}
|
|
191
|
-
if (
|
|
176
|
+
if (isFocused && inputSearchProps.text.value.isNotEmpty()) {
|
|
192
177
|
Row {
|
|
193
178
|
Spacer(Modifier.width(Spacing.XS))
|
|
194
179
|
Icon(
|
|
@@ -196,10 +181,7 @@ fun InputSearch(
|
|
|
196
181
|
size = 16.dp,
|
|
197
182
|
color = AppTheme.current.colors.text.hint,
|
|
198
183
|
modifier = Modifier.clickable(
|
|
199
|
-
onClick = {
|
|
200
|
-
inputSearchProps.text.value = ""
|
|
201
|
-
inputSearchProps.onClearPress.invoke()
|
|
202
|
-
},
|
|
184
|
+
onClick = { inputSearchProps.text.value = "" },
|
|
203
185
|
interactionSource = remember { MutableInteractionSource() },
|
|
204
186
|
indication = null
|
|
205
187
|
)
|
|
@@ -210,8 +192,7 @@ fun InputSearch(
|
|
|
210
192
|
inputSearchProps.loading,
|
|
211
193
|
inputSearchProps.icon,
|
|
212
194
|
iconTintColor,
|
|
213
|
-
inputSearchProps.onRightIconPressed
|
|
214
|
-
iconModifier = inputSearchProps.iconModifier
|
|
195
|
+
inputSearchProps.onRightIconPressed
|
|
215
196
|
)
|
|
216
197
|
}
|
|
217
198
|
}
|