@momo-kits/native-kits 0.89.32-nav.2 → 0.89.33-beta.10
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/build.gradle.kts +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Components.kt +17 -42
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +3 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +12 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +3 -1
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
|
@@ -32,7 +32,6 @@ import androidx.compose.ui.graphics.Color
|
|
|
32
32
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
33
33
|
import androidx.compose.ui.layout.ContentScale
|
|
34
34
|
import androidx.compose.ui.platform.LocalDensity
|
|
35
|
-
import androidx.compose.ui.semantics.contentDescription
|
|
36
35
|
import androidx.compose.ui.semantics.semantics
|
|
37
36
|
import androidx.compose.ui.semantics.testTag
|
|
38
37
|
import androidx.compose.ui.text.style.TextAlign
|
|
@@ -51,7 +50,6 @@ import vn.momo.kits.const.AppTheme
|
|
|
51
50
|
import vn.momo.kits.const.Colors
|
|
52
51
|
import vn.momo.kits.const.Spacing
|
|
53
52
|
import vn.momo.kits.const.Typography
|
|
54
|
-
import vn.momo.kits.modifier.shadow
|
|
55
53
|
import vn.momo.kits.platform.getStatusBarHeight
|
|
56
54
|
import vn.momo.kits.utils.bottomBorder
|
|
57
55
|
|
|
@@ -68,7 +66,6 @@ data class AnimatedHeader(
|
|
|
68
66
|
@Composable
|
|
69
67
|
fun HeaderBackground(
|
|
70
68
|
headerType: HeaderType = HeaderType.DEFAULT,
|
|
71
|
-
useShadow: Boolean? = true,
|
|
72
69
|
scrollState: Int
|
|
73
70
|
) {
|
|
74
71
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
@@ -90,6 +87,7 @@ fun HeaderBackground(
|
|
|
90
87
|
modifier = Modifier
|
|
91
88
|
.height(height)
|
|
92
89
|
.fillMaxWidth()
|
|
90
|
+
.alpha(opacityAni)
|
|
93
91
|
.background(
|
|
94
92
|
Brush.linearGradient(
|
|
95
93
|
colors = listOf(
|
|
@@ -121,8 +119,8 @@ fun HeaderBackground(
|
|
|
121
119
|
.background(
|
|
122
120
|
Brush.linearGradient(
|
|
123
121
|
colors = listOf(
|
|
124
|
-
Color(
|
|
125
|
-
Color(
|
|
122
|
+
Color(0xFFFDCADE),
|
|
123
|
+
Color(0x00FDCADE)
|
|
126
124
|
),
|
|
127
125
|
start = Offset(0f, 0f),
|
|
128
126
|
end = Offset(0f, with(LocalDensity.current) { 154.dp.toPx() })
|
|
@@ -139,23 +137,13 @@ fun HeaderBackground(
|
|
|
139
137
|
)
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
|
-
Box(
|
|
143
|
-
modifier = Modifier.fillMaxWidth().height(statusBarHeight + 52.dp)
|
|
144
|
-
.alpha(1 - opacityAni)
|
|
145
|
-
.background(Colors.black_01)
|
|
146
|
-
.then(
|
|
147
|
-
if (useShadow == true) Modifier.shadow() else Modifier.bottomBorder(
|
|
148
|
-
1.dp,
|
|
149
|
-
Colors.black_04
|
|
150
|
-
)
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
140
|
}
|
|
154
141
|
|
|
155
142
|
else -> {
|
|
156
143
|
Box(modifier = Modifier.fillMaxWidth())
|
|
157
144
|
}
|
|
158
145
|
}
|
|
146
|
+
|
|
159
147
|
}
|
|
160
148
|
|
|
161
149
|
@Composable
|
|
@@ -163,12 +151,10 @@ fun Header(
|
|
|
163
151
|
headerType: HeaderType = HeaderType.DEFAULT,
|
|
164
152
|
titlePosition: TitlePosition,
|
|
165
153
|
title: String,
|
|
166
|
-
isBack: Boolean,
|
|
167
154
|
headerRight: @Composable (() -> Unit)? = null,
|
|
168
|
-
goBack: (() -> Unit) =
|
|
155
|
+
goBack: (() -> Unit)? = null,
|
|
169
156
|
opacity: Float? = null,
|
|
170
157
|
animatedHeader: AnimatedHeader? = null,
|
|
171
|
-
useSearchInput: Boolean? = false,
|
|
172
158
|
scrollState: Int = 0,
|
|
173
159
|
inputSearchProps: InputSearchProps?
|
|
174
160
|
) {
|
|
@@ -185,14 +171,6 @@ fun Header(
|
|
|
185
171
|
.collect { fraction -> colorFraction = fraction }
|
|
186
172
|
}
|
|
187
173
|
|
|
188
|
-
val tintIconColorAnim by animateColorAsState(
|
|
189
|
-
targetValue = animateColor(
|
|
190
|
-
Colors.black_01,
|
|
191
|
-
AppTheme.current.colors.text.default,
|
|
192
|
-
colorFraction
|
|
193
|
-
)
|
|
194
|
-
)
|
|
195
|
-
|
|
196
174
|
val backgroundSearch by animateColorAsState(
|
|
197
175
|
targetValue = animateColor(
|
|
198
176
|
Colors.black_01,
|
|
@@ -216,7 +194,7 @@ fun Header(
|
|
|
216
194
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
217
195
|
) {
|
|
218
196
|
Box {
|
|
219
|
-
if (
|
|
197
|
+
if (goBack != null) {
|
|
220
198
|
Box(
|
|
221
199
|
modifier = Modifier
|
|
222
200
|
.size(28.dp)
|
|
@@ -242,18 +220,17 @@ fun Header(
|
|
|
242
220
|
) {
|
|
243
221
|
Icon(
|
|
244
222
|
source = "arrow-back",
|
|
245
|
-
color =
|
|
223
|
+
color = Colors.black_20,
|
|
246
224
|
size = 20.dp,
|
|
247
225
|
)
|
|
248
226
|
}
|
|
249
227
|
}
|
|
250
228
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
229
|
+
|
|
230
|
+
Box(Modifier.graphicsLayer {
|
|
231
|
+
alpha = if (animatedHeader !== null) opacity ?: 1f else 1f
|
|
232
|
+
}) {
|
|
233
|
+
headerRight?.invoke()
|
|
257
234
|
}
|
|
258
235
|
}
|
|
259
236
|
|
|
@@ -264,13 +241,12 @@ fun Header(
|
|
|
264
241
|
.padding(horizontal = Spacing.M),
|
|
265
242
|
verticalAlignment = Alignment.CenterVertically,
|
|
266
243
|
) {
|
|
267
|
-
if (
|
|
244
|
+
if (goBack != null && titlePosition == TitlePosition.LEFT) {
|
|
268
245
|
Spacer(Modifier.width(40.dp))
|
|
269
246
|
}
|
|
270
|
-
if (
|
|
247
|
+
if (inputSearchProps != null) {
|
|
271
248
|
InputSearch(inputSearchProps = inputSearchProps.copy(backgroundColor = backgroundSearch))
|
|
272
|
-
}
|
|
273
|
-
else{
|
|
249
|
+
} else{
|
|
274
250
|
Box(
|
|
275
251
|
Modifier.weight(1f).graphicsLayer {
|
|
276
252
|
alpha = if (animatedHeader !== null) opacity ?: 1f else 1f
|
|
@@ -279,9 +255,8 @@ fun Header(
|
|
|
279
255
|
) {
|
|
280
256
|
HeaderTitle(
|
|
281
257
|
title = title,
|
|
282
|
-
color =
|
|
258
|
+
color = tintIconColor,
|
|
283
259
|
modifier = Modifier.semantics {
|
|
284
|
-
contentDescription = title
|
|
285
260
|
testTag = "title_navigation_header"
|
|
286
261
|
}
|
|
287
262
|
)
|
|
@@ -303,7 +278,7 @@ fun HeaderTitle(
|
|
|
303
278
|
modifier = Modifier.then(modifier).zIndex(1f),
|
|
304
279
|
text = title,
|
|
305
280
|
textAlign = textAlign,
|
|
306
|
-
style = Typography.
|
|
281
|
+
style = Typography.actionS,
|
|
307
282
|
color = color,
|
|
308
283
|
maxLines = 1
|
|
309
284
|
)
|
|
@@ -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
|
) {
|
|
@@ -56,7 +56,7 @@ fun Screen(
|
|
|
56
56
|
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
|
|
57
57
|
title: String = "Stack",
|
|
58
58
|
titlePosition: TitlePosition = TitlePosition.LEFT,
|
|
59
|
-
goBack: (() -> Unit) =
|
|
59
|
+
goBack: (() -> Unit)? = null,
|
|
60
60
|
scrollable: Boolean = true,
|
|
61
61
|
scrollState: ScrollState = rememberScrollState(),
|
|
62
62
|
onContentLayout: ((LayoutCoordinates) -> Unit)? = null,
|
|
@@ -66,12 +66,11 @@ fun Screen(
|
|
|
66
66
|
fabProps: FabProps? = null,
|
|
67
67
|
animatedHeader: AnimatedHeader? = null,
|
|
68
68
|
layoutOffset: Dp = 56.dp,
|
|
69
|
-
useShadow: Boolean? = true,
|
|
70
|
-
useSearchInput: Boolean? = false,
|
|
71
69
|
inputSearchProps: InputSearchProps? = null,
|
|
72
70
|
content: @Composable () -> Unit,
|
|
73
71
|
) {
|
|
74
72
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
73
|
+
val platformApi = PlatformApi.current
|
|
75
74
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
76
75
|
val keyboardHeight = WindowInsets.ime.asPaddingValues().calculateBottomPadding()
|
|
77
76
|
val keyboardSize = when {
|
|
@@ -100,13 +99,12 @@ fun Screen(
|
|
|
100
99
|
HeaderBackground(headerType = headerType, scrollState = scrollState.value)
|
|
101
100
|
} else {
|
|
102
101
|
Box(
|
|
103
|
-
Modifier.zIndex(
|
|
102
|
+
Modifier.zIndex(2f)
|
|
104
103
|
.background(Color.White.copy(alpha = opacity))
|
|
105
104
|
.graphicsLayer { alpha = opacity }
|
|
106
105
|
) {
|
|
107
106
|
HeaderBackground(
|
|
108
107
|
headerType = headerType,
|
|
109
|
-
useShadow = useShadow,
|
|
110
108
|
scrollState = scrollState.value
|
|
111
109
|
)
|
|
112
110
|
}
|
|
@@ -117,11 +115,9 @@ fun Screen(
|
|
|
117
115
|
title = title,
|
|
118
116
|
titlePosition = titlePosition,
|
|
119
117
|
headerRight = headerRight,
|
|
120
|
-
isBack = isBack,
|
|
121
118
|
goBack = goBack,
|
|
122
119
|
opacity = opacity,
|
|
123
120
|
animatedHeader = animatedHeader,
|
|
124
|
-
useSearchInput = useSearchInput,
|
|
125
121
|
inputSearchProps = inputSearchProps,
|
|
126
122
|
scrollState = scrollState.value
|
|
127
123
|
)
|
|
@@ -18,9 +18,6 @@ import androidx.compose.ui.Alignment
|
|
|
18
18
|
import androidx.compose.ui.Modifier
|
|
19
19
|
import androidx.compose.ui.draw.clip
|
|
20
20
|
import androidx.compose.ui.graphics.Color
|
|
21
|
-
import androidx.compose.ui.semantics.contentDescription
|
|
22
|
-
import androidx.compose.ui.semantics.semantics
|
|
23
|
-
import androidx.compose.ui.semantics.testTag
|
|
24
21
|
import androidx.compose.ui.text.TextStyle
|
|
25
22
|
import androidx.compose.ui.text.style.TextOverflow
|
|
26
23
|
import androidx.compose.ui.unit.Dp
|
|
@@ -236,7 +233,6 @@ fun Button(
|
|
|
236
233
|
isFull: Boolean = true,
|
|
237
234
|
modifier: Modifier = Modifier,
|
|
238
235
|
) {
|
|
239
|
-
val testId = "btn_${type.toString().lowercase()}_$title"
|
|
240
236
|
val customModifier = if (isFull) {
|
|
241
237
|
modifier
|
|
242
238
|
.fillMaxWidth()
|
|
@@ -258,10 +254,7 @@ fun Button(
|
|
|
258
254
|
.padding(horizontal = size.value.padding)
|
|
259
255
|
.defaultMinSize(
|
|
260
256
|
minWidth = size.value.width
|
|
261
|
-
).height(size.value.height)
|
|
262
|
-
.semantics {
|
|
263
|
-
contentDescription = title; testTag = testId
|
|
264
|
-
},
|
|
257
|
+
).height(size.value.height),
|
|
265
258
|
horizontalArrangement = Arrangement.Center,
|
|
266
259
|
verticalAlignment = Alignment.CenterVertically,
|
|
267
260
|
) {
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
package vn.momo.kits.components
|
|
2
2
|
|
|
3
|
+
import androidx.compose.foundation.layout.Box
|
|
3
4
|
import androidx.compose.foundation.layout.size
|
|
4
5
|
import androidx.compose.runtime.Composable
|
|
5
6
|
import androidx.compose.ui.Modifier
|
|
6
7
|
import androidx.compose.ui.graphics.Color
|
|
7
8
|
import androidx.compose.ui.graphics.ColorFilter
|
|
8
9
|
import androidx.compose.ui.layout.ContentScale
|
|
10
|
+
import androidx.compose.ui.semantics.contentDescription
|
|
11
|
+
import androidx.compose.ui.semantics.semantics
|
|
9
12
|
import androidx.compose.ui.unit.Dp
|
|
10
13
|
import androidx.compose.ui.unit.dp
|
|
14
|
+
import coil3.compose.AsyncImage
|
|
11
15
|
import vn.momo.kits.const.AppTheme
|
|
12
16
|
import vn.momo.kits.utils.Icons
|
|
13
17
|
|
|
@@ -23,14 +27,14 @@ fun Icon(
|
|
|
23
27
|
} else {
|
|
24
28
|
Icons[source] ?: ""
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
Box(modifier = modifier.size(size).semantics {contentDescription = "img|$icon"}) {
|
|
31
|
+
AsyncImage(
|
|
32
|
+
modifier = Modifier.matchParentSize(),
|
|
33
|
+
model = icon,
|
|
34
|
+
contentDescription = null,
|
|
31
35
|
contentScale = ContentScale.Fit,
|
|
32
|
-
colorFilter = color?.let { ColorFilter.tint(it) }
|
|
33
|
-
)
|
|
34
|
-
|
|
36
|
+
colorFilter = color?.let { ColorFilter.tint(it) },
|
|
37
|
+
)
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -14,7 +14,6 @@ import androidx.compose.ui.graphics.painter.Painter
|
|
|
14
14
|
import androidx.compose.ui.layout.ContentScale
|
|
15
15
|
import androidx.compose.ui.semantics.contentDescription
|
|
16
16
|
import androidx.compose.ui.semantics.semantics
|
|
17
|
-
import androidx.compose.ui.semantics.testTag
|
|
18
17
|
import coil3.compose.AsyncImage
|
|
19
18
|
import vn.momo.kits.const.AppTheme
|
|
20
19
|
|
|
@@ -48,9 +47,9 @@ fun Image(
|
|
|
48
47
|
)
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
Box(modifier = modifier) {
|
|
50
|
+
Box(modifier = modifier.semantics {contentDescription = "img|$source"}) {
|
|
52
51
|
AsyncImage(
|
|
53
|
-
modifier = Modifier.matchParentSize()
|
|
52
|
+
modifier = Modifier.matchParentSize(),
|
|
54
53
|
model = source,
|
|
55
54
|
contentDescription = null,
|
|
56
55
|
contentScale = imageOptions.contentScale,
|
|
@@ -27,7 +27,6 @@ import androidx.compose.runtime.setValue
|
|
|
27
27
|
import androidx.compose.ui.Alignment
|
|
28
28
|
import androidx.compose.ui.Modifier
|
|
29
29
|
import androidx.compose.ui.draw.clip
|
|
30
|
-
import androidx.compose.ui.semantics.contentDescription
|
|
31
30
|
import androidx.compose.ui.semantics.semantics
|
|
32
31
|
import androidx.compose.ui.semantics.testTag
|
|
33
32
|
import androidx.compose.ui.text.TextLayoutResult
|
|
@@ -97,7 +96,7 @@ fun PopupNotify(
|
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
Box(Modifier.semantics {
|
|
100
|
-
|
|
99
|
+
testTag = "popup_notify"
|
|
101
100
|
}, contentAlignment = Alignment.TopEnd) {
|
|
102
101
|
Column(
|
|
103
102
|
modifier = Modifier
|
|
@@ -235,7 +234,7 @@ fun renderRow(
|
|
|
235
234
|
title = it.title,
|
|
236
235
|
type = ButtonType.TEXT,
|
|
237
236
|
modifier = Modifier.semantics {
|
|
238
|
-
|
|
237
|
+
testTag = "btn_popup_cancel"
|
|
239
238
|
}
|
|
240
239
|
)
|
|
241
240
|
}
|
|
@@ -250,7 +249,7 @@ fun renderRow(
|
|
|
250
249
|
},
|
|
251
250
|
title = primary?.title ?: "",
|
|
252
251
|
modifier = Modifier.semantics {
|
|
253
|
-
|
|
252
|
+
testTag = "btn_popup_allow"
|
|
254
253
|
}
|
|
255
254
|
)
|
|
256
255
|
}
|
|
@@ -273,7 +272,7 @@ fun renderColumn(
|
|
|
273
272
|
},
|
|
274
273
|
title = primary?.title ?: "",
|
|
275
274
|
modifier = Modifier.semantics {
|
|
276
|
-
|
|
275
|
+
testTag = "btn_popup_allow"
|
|
277
276
|
}
|
|
278
277
|
)
|
|
279
278
|
secondary?.let {
|
|
@@ -288,7 +287,7 @@ fun renderColumn(
|
|
|
288
287
|
title = it.title,
|
|
289
288
|
type = ButtonType.TEXT,
|
|
290
289
|
modifier = Modifier.semantics {
|
|
291
|
-
|
|
290
|
+
testTag = "btn_popup_cancel"
|
|
292
291
|
}
|
|
293
292
|
)
|
|
294
293
|
}
|
|
@@ -3,6 +3,8 @@ package vn.momo.kits.components
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
import androidx.compose.ui.Modifier
|
|
5
5
|
import androidx.compose.ui.graphics.Color
|
|
6
|
+
import androidx.compose.ui.semantics.contentDescription
|
|
7
|
+
import androidx.compose.ui.semantics.semantics
|
|
6
8
|
import androidx.compose.ui.text.TextLayoutResult
|
|
7
9
|
import androidx.compose.ui.text.TextStyle
|
|
8
10
|
import androidx.compose.ui.text.style.TextAlign
|
|
@@ -31,7 +33,7 @@ fun Text(
|
|
|
31
33
|
val font = getFontFamily(fontFamily, style.fontWeight)
|
|
32
34
|
|
|
33
35
|
androidx.compose.material3.Text(
|
|
34
|
-
modifier = modifier,
|
|
36
|
+
modifier = modifier.semantics { contentDescription = text },
|
|
35
37
|
text = text,
|
|
36
38
|
color = color ?: AppTheme.current.colors.text.default,
|
|
37
39
|
style = style,
|