@momo-kits/native-kits 0.89.33-beta.26 → 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,11 +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
93
|
)
|
|
102
94
|
|
|
103
95
|
@Composable
|
|
@@ -106,6 +98,7 @@ fun InputSearch(
|
|
|
106
98
|
text = remember { mutableStateOf("") },
|
|
107
99
|
iconColor = AppTheme.current.colors.text.default
|
|
108
100
|
),
|
|
101
|
+
|
|
109
102
|
) {
|
|
110
103
|
var isFocused by remember { mutableStateOf(false) }
|
|
111
104
|
var isBlurred = false
|
|
@@ -131,9 +124,8 @@ fun InputSearch(
|
|
|
131
124
|
lineHeight = 20.sp,
|
|
132
125
|
fontWeight = inputSearchProps.fontWeight.value
|
|
133
126
|
),
|
|
134
|
-
keyboardOptions =
|
|
135
|
-
|
|
136
|
-
modifier = inputSearchProps.modifier.height(36.dp).onFocusChanged {
|
|
127
|
+
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = inputSearchProps.keyboardType),
|
|
128
|
+
modifier = Modifier.height(36.dp).onFocusChanged {
|
|
137
129
|
isFocused = it.isFocused
|
|
138
130
|
if (it.isFocused) {
|
|
139
131
|
inputSearchProps.onFocus()
|
|
@@ -145,12 +137,7 @@ fun InputSearch(
|
|
|
145
137
|
decorationBox = { innerTextField ->
|
|
146
138
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
147
139
|
Row(
|
|
148
|
-
modifier = Modifier.weight(
|
|
149
|
-
inputSearchProps.showButtonText.ifTrue(
|
|
150
|
-
8f,
|
|
151
|
-
1f
|
|
152
|
-
)
|
|
153
|
-
)
|
|
140
|
+
modifier = Modifier.weight(inputSearchProps.showButtonText.ifTrue(8f, 1f))
|
|
154
141
|
.background(
|
|
155
142
|
inputSearchProps.backgroundColor,
|
|
156
143
|
RoundedCornerShape(Radius.XL)
|
|
@@ -165,6 +152,7 @@ fun InputSearch(
|
|
|
165
152
|
),
|
|
166
153
|
verticalAlignment = Alignment.CenterVertically
|
|
167
154
|
) {
|
|
155
|
+
//leading icon
|
|
168
156
|
Icon(
|
|
169
157
|
source = "navigation_search",
|
|
170
158
|
modifier = Modifier.padding(end = Spacing.XS),
|
|
@@ -180,14 +168,12 @@ fun InputSearch(
|
|
|
180
168
|
lineHeight = 24.sp,
|
|
181
169
|
fontWeight = inputSearchProps.fontWeight.value
|
|
182
170
|
),
|
|
183
|
-
|
|
184
|
-
color = placeholderColor,
|
|
185
|
-
overflow = TextOverflow.Ellipsis
|
|
171
|
+
color = placeholderColor
|
|
186
172
|
)
|
|
187
173
|
}
|
|
188
174
|
innerTextField()
|
|
189
175
|
}
|
|
190
|
-
if (
|
|
176
|
+
if (isFocused && inputSearchProps.text.value.isNotEmpty()) {
|
|
191
177
|
Row {
|
|
192
178
|
Spacer(Modifier.width(Spacing.XS))
|
|
193
179
|
Icon(
|
|
@@ -206,8 +192,7 @@ fun InputSearch(
|
|
|
206
192
|
inputSearchProps.loading,
|
|
207
193
|
inputSearchProps.icon,
|
|
208
194
|
iconTintColor,
|
|
209
|
-
inputSearchProps.onRightIconPressed
|
|
210
|
-
iconModifier = inputSearchProps.iconModifier
|
|
195
|
+
inputSearchProps.onRightIconPressed
|
|
211
196
|
)
|
|
212
197
|
}
|
|
213
198
|
}
|