@momo-kits/native-kits 0.89.30-rc.9 → 0.89.31-beta.20
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/Components.kt +126 -70
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +30 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +58 -47
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/local.properties +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package vn.momo.kits.application
|
|
2
2
|
|
|
3
3
|
import androidx.compose.animation.animateColorAsState
|
|
4
|
+
import androidx.compose.animation.core.animateFloatAsState
|
|
4
5
|
import androidx.compose.foundation.background
|
|
5
6
|
import androidx.compose.foundation.border
|
|
6
7
|
import androidx.compose.foundation.clickable
|
|
@@ -9,7 +10,6 @@ import androidx.compose.foundation.layout.Box
|
|
|
9
10
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
10
11
|
import androidx.compose.foundation.layout.Row
|
|
11
12
|
import androidx.compose.foundation.layout.Spacer
|
|
12
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
13
13
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
14
14
|
import androidx.compose.foundation.layout.height
|
|
15
15
|
import androidx.compose.foundation.layout.padding
|
|
@@ -25,9 +25,13 @@ import androidx.compose.runtime.setValue
|
|
|
25
25
|
import androidx.compose.runtime.snapshotFlow
|
|
26
26
|
import androidx.compose.ui.Alignment
|
|
27
27
|
import androidx.compose.ui.Modifier
|
|
28
|
+
import androidx.compose.ui.draw.alpha
|
|
29
|
+
import androidx.compose.ui.geometry.Offset
|
|
30
|
+
import androidx.compose.ui.graphics.Brush
|
|
28
31
|
import androidx.compose.ui.graphics.Color
|
|
29
32
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
30
33
|
import androidx.compose.ui.layout.ContentScale
|
|
34
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
31
35
|
import androidx.compose.ui.semantics.contentDescription
|
|
32
36
|
import androidx.compose.ui.semantics.semantics
|
|
33
37
|
import androidx.compose.ui.semantics.testTag
|
|
@@ -38,6 +42,8 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
|
|
38
42
|
import kotlinx.coroutines.flow.map
|
|
39
43
|
import vn.momo.kits.components.Icon
|
|
40
44
|
import vn.momo.kits.components.Image
|
|
45
|
+
import vn.momo.kits.components.InputSearch
|
|
46
|
+
import vn.momo.kits.components.InputSearchProps
|
|
41
47
|
import vn.momo.kits.components.Options
|
|
42
48
|
import vn.momo.kits.components.Text
|
|
43
49
|
import vn.momo.kits.const.AppStatusBar
|
|
@@ -45,6 +51,7 @@ import vn.momo.kits.const.AppTheme
|
|
|
45
51
|
import vn.momo.kits.const.Colors
|
|
46
52
|
import vn.momo.kits.const.Spacing
|
|
47
53
|
import vn.momo.kits.const.Typography
|
|
54
|
+
import vn.momo.kits.modifier.shadow
|
|
48
55
|
import vn.momo.kits.platform.getStatusBarHeight
|
|
49
56
|
import vn.momo.kits.utils.bottomBorder
|
|
50
57
|
|
|
@@ -59,43 +66,88 @@ data class AnimatedHeader(
|
|
|
59
66
|
)
|
|
60
67
|
|
|
61
68
|
@Composable
|
|
62
|
-
fun
|
|
69
|
+
fun HeaderBackground(
|
|
63
70
|
headerType: HeaderType = HeaderType.DEFAULT,
|
|
64
|
-
|
|
71
|
+
useShadow: Boolean? = true,
|
|
72
|
+
scrollState: Int
|
|
65
73
|
) {
|
|
66
74
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
75
|
+
val opacityAni by animateFloatAsState(
|
|
76
|
+
targetValue = (1 - (scrollState / 200f)).coerceIn(0f, 1f),
|
|
77
|
+
)
|
|
78
|
+
|
|
67
79
|
when (headerType) {
|
|
68
80
|
HeaderType.DEFAULT -> {
|
|
69
81
|
val height = statusBarHeight + 52.dp
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
Box(
|
|
83
|
+
modifier = Modifier.fillMaxWidth().height(height)
|
|
84
|
+
.bottomBorder(
|
|
85
|
+
strokeWidth = 1.dp,
|
|
86
|
+
color = AppTheme.current.colors.border.default
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
89
|
+
Box(
|
|
90
|
+
modifier = Modifier
|
|
91
|
+
.height(height)
|
|
92
|
+
.fillMaxWidth()
|
|
93
|
+
.background(
|
|
94
|
+
Brush.linearGradient(
|
|
95
|
+
colors = listOf(
|
|
96
|
+
Color(0xFFFDCACE),
|
|
97
|
+
Color(0x00FDCACE)
|
|
98
|
+
),
|
|
99
|
+
start = Offset(0f, 0f),
|
|
100
|
+
end = Offset(0f, with(LocalDensity.current) { 154.dp.toPx() })
|
|
101
|
+
)
|
|
102
|
+
)
|
|
76
103
|
)
|
|
77
|
-
|
|
78
|
-
|
|
104
|
+
if (AppTheme.current.assets.headerBackground != null) {
|
|
105
|
+
Image(
|
|
106
|
+
source = AppTheme.current.assets.headerBackground!!,
|
|
107
|
+
modifier = Modifier.fillMaxWidth().height(height),
|
|
108
|
+
options = Options(
|
|
109
|
+
contentScale = ContentScale.FillWidth
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
79
114
|
|
|
80
|
-
HeaderType.EXTENDED -> {
|
|
81
|
-
Image(
|
|
82
|
-
source = headerBackground ?: "",
|
|
83
|
-
loading = false,
|
|
84
|
-
modifier = Modifier.fillMaxSize(),
|
|
85
|
-
options = Options(
|
|
86
|
-
contentScale = ContentScale.FillWidth
|
|
87
|
-
)
|
|
88
|
-
)
|
|
89
115
|
}
|
|
90
116
|
|
|
91
|
-
HeaderType.
|
|
92
|
-
val height = statusBarHeight + 52.dp
|
|
117
|
+
HeaderType.EXTENDED -> {
|
|
93
118
|
Box(
|
|
94
|
-
modifier = Modifier.fillMaxWidth().height(
|
|
95
|
-
.
|
|
96
|
-
.
|
|
97
|
-
|
|
98
|
-
|
|
119
|
+
modifier = Modifier.fillMaxWidth().height(154.dp)
|
|
120
|
+
.alpha(opacityAni)
|
|
121
|
+
.background(
|
|
122
|
+
Brush.linearGradient(
|
|
123
|
+
colors = listOf(
|
|
124
|
+
Color(0xFFFDCACE),
|
|
125
|
+
Color(0x00FDCACE)
|
|
126
|
+
),
|
|
127
|
+
start = Offset(0f, 0f),
|
|
128
|
+
end = Offset(0f, with(LocalDensity.current) { 154.dp.toPx() })
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
) {
|
|
132
|
+
if (AppTheme.current.assets.headerBackground != null) {
|
|
133
|
+
Image(
|
|
134
|
+
source = AppTheme.current.assets.headerBackground!!,
|
|
135
|
+
modifier = Modifier.fillMaxWidth().height(154.dp),
|
|
136
|
+
options = Options(
|
|
137
|
+
contentScale = ContentScale.FillWidth
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
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
|
+
)
|
|
99
151
|
)
|
|
100
152
|
)
|
|
101
153
|
}
|
|
@@ -116,25 +168,21 @@ fun Header(
|
|
|
116
168
|
goBack: (() -> Unit) = { },
|
|
117
169
|
opacity: Float? = null,
|
|
118
170
|
animatedHeader: AnimatedHeader? = null,
|
|
119
|
-
|
|
171
|
+
useSearchInput: Boolean? = false,
|
|
172
|
+
scrollState: Int = 0,
|
|
173
|
+
inputSearchProps: InputSearchProps?
|
|
120
174
|
) {
|
|
121
175
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (headerType == HeaderType.SURFACE) {
|
|
125
|
-
tintIconColor = AppTheme.current.colors.text.default
|
|
126
|
-
backgroundButton = Color.Transparent
|
|
127
|
-
}
|
|
176
|
+
val tintIconColor = AppTheme.current.colors.text.default
|
|
177
|
+
val backgroundButton = Colors.black_01.copy(alpha = 0.2f)
|
|
128
178
|
|
|
129
179
|
var colorFraction by remember { mutableStateOf(0f) }
|
|
130
180
|
|
|
131
181
|
LaunchedEffect(scrollState) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.collect { fraction -> colorFraction = fraction }
|
|
137
|
-
}
|
|
182
|
+
snapshotFlow { scrollState }
|
|
183
|
+
.map { (it / 50f).coerceIn(0f, 1f) }
|
|
184
|
+
.distinctUntilChanged()
|
|
185
|
+
.collect { fraction -> colorFraction = fraction }
|
|
138
186
|
}
|
|
139
187
|
|
|
140
188
|
val tintIconColorAnim by animateColorAsState(
|
|
@@ -145,6 +193,14 @@ fun Header(
|
|
|
145
193
|
)
|
|
146
194
|
)
|
|
147
195
|
|
|
196
|
+
val backgroundSearch by animateColorAsState(
|
|
197
|
+
targetValue = animateColor(
|
|
198
|
+
Colors.black_01,
|
|
199
|
+
AppTheme.current.colors.background.default,
|
|
200
|
+
colorFraction
|
|
201
|
+
)
|
|
202
|
+
)
|
|
203
|
+
|
|
148
204
|
if (headerType != HeaderType.NONE) {
|
|
149
205
|
BoxWithConstraints(
|
|
150
206
|
Modifier.height(statusBarHeight + 52.dp)
|
|
@@ -165,15 +221,11 @@ fun Header(
|
|
|
165
221
|
modifier = Modifier
|
|
166
222
|
.size(28.dp)
|
|
167
223
|
.then(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
)
|
|
174
|
-
} else {
|
|
175
|
-
Modifier
|
|
176
|
-
}
|
|
224
|
+
Modifier.border(
|
|
225
|
+
0.5.dp,
|
|
226
|
+
Colors.black_20.copy(alpha = 0.4f),
|
|
227
|
+
RoundedCornerShape(100)
|
|
228
|
+
)
|
|
177
229
|
)
|
|
178
230
|
.background(
|
|
179
231
|
backgroundButton,
|
|
@@ -190,16 +242,18 @@ fun Header(
|
|
|
190
242
|
) {
|
|
191
243
|
Icon(
|
|
192
244
|
source = "ic_back_ios",
|
|
193
|
-
color = if (
|
|
245
|
+
color = if (animatedHeader !== null) tintIconColorAnim else tintIconColor,
|
|
194
246
|
size = 20.dp,
|
|
195
247
|
)
|
|
196
248
|
}
|
|
197
249
|
}
|
|
198
250
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
251
|
+
if (useSearchInput == false) {
|
|
252
|
+
Box(Modifier.graphicsLayer {
|
|
253
|
+
alpha = if (animatedHeader !== null) opacity ?: 1f else 1f
|
|
254
|
+
}) {
|
|
255
|
+
headerRight?.invoke()
|
|
256
|
+
}
|
|
203
257
|
}
|
|
204
258
|
}
|
|
205
259
|
|
|
@@ -213,23 +267,25 @@ fun Header(
|
|
|
213
267
|
if (isBack) {
|
|
214
268
|
Spacer(Modifier.width(40.dp))
|
|
215
269
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
alpha = if (animatedHeader !== null) opacity ?: 1f else 1f
|
|
219
|
-
},
|
|
220
|
-
contentAlignment = if (titlePosition == TitlePosition.LEFT) Alignment.TopStart else Alignment.Center
|
|
221
|
-
) {
|
|
222
|
-
HeaderTitle(
|
|
223
|
-
title = title,
|
|
224
|
-
color = if (headerType == HeaderType.SURFACE && animatedHeader !== null) tintIconColorAnim else tintIconColor,
|
|
225
|
-
modifier = Modifier.semantics {
|
|
226
|
-
contentDescription = title
|
|
227
|
-
testTag = "title_navigation_header"
|
|
228
|
-
}
|
|
229
|
-
)
|
|
270
|
+
if (useSearchInput == true && inputSearchProps != null) {
|
|
271
|
+
InputSearch(inputSearchProps = inputSearchProps.copy(backgroundColor = backgroundSearch))
|
|
230
272
|
}
|
|
231
|
-
|
|
232
|
-
|
|
273
|
+
else{
|
|
274
|
+
Box(
|
|
275
|
+
Modifier.weight(1f).graphicsLayer {
|
|
276
|
+
alpha = if (animatedHeader !== null) opacity ?: 1f else 1f
|
|
277
|
+
},
|
|
278
|
+
contentAlignment = if (titlePosition == TitlePosition.LEFT) Alignment.TopStart else Alignment.Center
|
|
279
|
+
) {
|
|
280
|
+
HeaderTitle(
|
|
281
|
+
title = title,
|
|
282
|
+
color = if (animatedHeader !== null) tintIconColorAnim else tintIconColor,
|
|
283
|
+
modifier = Modifier.semantics {
|
|
284
|
+
contentDescription = title
|
|
285
|
+
testTag = "title_navigation_header"
|
|
286
|
+
}
|
|
287
|
+
)
|
|
288
|
+
}
|
|
233
289
|
}
|
|
234
290
|
}
|
|
235
291
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package vn.momo.kits.application
|
|
2
2
|
|
|
3
3
|
import androidx.compose.animation.core.animateFloatAsState
|
|
4
|
+
import androidx.compose.foundation.ScrollState
|
|
4
5
|
import androidx.compose.foundation.background
|
|
5
6
|
import androidx.compose.foundation.gestures.detectTapGestures
|
|
6
7
|
import androidx.compose.foundation.layout.Arrangement
|
|
@@ -24,21 +25,24 @@ import androidx.compose.ui.Modifier
|
|
|
24
25
|
import androidx.compose.ui.graphics.Color
|
|
25
26
|
import androidx.compose.ui.graphics.graphicsLayer
|
|
26
27
|
import androidx.compose.ui.input.pointer.pointerInput
|
|
28
|
+
import androidx.compose.ui.layout.LayoutCoordinates
|
|
29
|
+
import androidx.compose.ui.layout.onGloballyPositioned
|
|
27
30
|
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
|
28
31
|
import androidx.compose.ui.unit.Dp
|
|
29
32
|
import androidx.compose.ui.unit.dp
|
|
30
33
|
import androidx.compose.ui.unit.min
|
|
31
34
|
import androidx.compose.ui.zIndex
|
|
35
|
+
import vn.momo.kits.components.InputSearchProps
|
|
32
36
|
import vn.momo.kits.const.AppStatusBar
|
|
33
37
|
import vn.momo.kits.const.AppTheme
|
|
34
38
|
import vn.momo.kits.const.Colors
|
|
35
39
|
import vn.momo.kits.const.Spacing
|
|
40
|
+
import vn.momo.kits.modifier.conditional
|
|
36
41
|
import vn.momo.kits.modifier.shadow
|
|
37
42
|
import vn.momo.kits.platform.getStatusBarHeight
|
|
38
43
|
|
|
39
44
|
enum class HeaderType {
|
|
40
45
|
DEFAULT,
|
|
41
|
-
SURFACE,
|
|
42
46
|
EXTENDED,
|
|
43
47
|
NONE
|
|
44
48
|
}
|
|
@@ -46,7 +50,6 @@ enum class HeaderType {
|
|
|
46
50
|
@Composable
|
|
47
51
|
fun Screen(
|
|
48
52
|
backgroundColor: Color? = null,
|
|
49
|
-
headerBackground: String? = null,
|
|
50
53
|
isBack: Boolean = true,
|
|
51
54
|
headerType: HeaderType = HeaderType.DEFAULT,
|
|
52
55
|
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
|
|
@@ -55,12 +58,17 @@ fun Screen(
|
|
|
55
58
|
titlePosition: TitlePosition = TitlePosition.LEFT,
|
|
56
59
|
goBack: (() -> Unit) = { },
|
|
57
60
|
scrollable: Boolean = true,
|
|
61
|
+
scrollState: ScrollState = rememberScrollState(),
|
|
62
|
+
onContentLayout: ((LayoutCoordinates) -> Unit)? = null,
|
|
58
63
|
useAvoidKeyboard: Boolean = true,
|
|
59
64
|
footer: @Composable (() -> Unit)? = null,
|
|
60
65
|
headerRight: @Composable (() -> Unit)? = null,
|
|
61
66
|
fabProps: FabProps? = null,
|
|
62
67
|
animatedHeader: AnimatedHeader? = null,
|
|
63
68
|
layoutOffset: Dp = 56.dp,
|
|
69
|
+
useShadow: Boolean? = true,
|
|
70
|
+
useSearchInput: Boolean? = false,
|
|
71
|
+
inputSearchProps: InputSearchProps? = null,
|
|
64
72
|
content: @Composable () -> Unit,
|
|
65
73
|
) {
|
|
66
74
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
@@ -75,7 +83,6 @@ fun Screen(
|
|
|
75
83
|
|
|
76
84
|
val indicator = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
|
|
77
85
|
val bottomPadding = min(indicator, 21.dp)
|
|
78
|
-
val scrollState = rememberScrollState()
|
|
79
86
|
|
|
80
87
|
val opacity by animateFloatAsState(
|
|
81
88
|
targetValue = ((scrollState.value / 114f)).coerceIn(0f, 1f)
|
|
@@ -90,17 +97,17 @@ fun Screen(
|
|
|
90
97
|
) {
|
|
91
98
|
|
|
92
99
|
if (animatedHeader === null) {
|
|
93
|
-
|
|
94
|
-
headerType,
|
|
95
|
-
headerBackground ?: AppTheme.current.assets.headerBackground
|
|
96
|
-
)
|
|
100
|
+
HeaderBackground(headerType = headerType, scrollState = scrollState.value)
|
|
97
101
|
} else {
|
|
98
102
|
Box(
|
|
99
|
-
Modifier.zIndex(5f)
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
Modifier.zIndex(5f)
|
|
104
|
+
.background(Color.White.copy(alpha = opacity))
|
|
105
|
+
.graphicsLayer { alpha = opacity }
|
|
106
|
+
) {
|
|
107
|
+
HeaderBackground(
|
|
108
|
+
headerType = headerType,
|
|
109
|
+
useShadow = useShadow,
|
|
110
|
+
scrollState = scrollState.value
|
|
104
111
|
)
|
|
105
112
|
}
|
|
106
113
|
}
|
|
@@ -114,6 +121,8 @@ fun Screen(
|
|
|
114
121
|
goBack = goBack,
|
|
115
122
|
opacity = opacity,
|
|
116
123
|
animatedHeader = animatedHeader,
|
|
124
|
+
useSearchInput = useSearchInput,
|
|
125
|
+
inputSearchProps = inputSearchProps,
|
|
117
126
|
scrollState = scrollState.value
|
|
118
127
|
)
|
|
119
128
|
|
|
@@ -129,9 +138,13 @@ fun Screen(
|
|
|
129
138
|
) {
|
|
130
139
|
|
|
131
140
|
Column(
|
|
132
|
-
modifier =
|
|
133
|
-
.
|
|
134
|
-
|
|
141
|
+
modifier = Modifier
|
|
142
|
+
.conditional(scrollable) { weight(1f) }
|
|
143
|
+
.padding(bottom = keyboardSize)
|
|
144
|
+
.conditional(onContentLayout != null) {
|
|
145
|
+
onGloballyPositioned(onContentLayout ?: {})
|
|
146
|
+
}
|
|
147
|
+
.conditional(scrollable) { verticalScroll(scrollState) },
|
|
135
148
|
verticalArrangement = verticalArrangement,
|
|
136
149
|
horizontalAlignment = horizontalAlignment
|
|
137
150
|
) {
|
|
@@ -186,11 +199,8 @@ fun Footer(footer: @Composable (() -> Unit)? = null, keyboardSize: Dp = 0.dp, bo
|
|
|
186
199
|
.background(AppTheme.current.colors.background.surface)
|
|
187
200
|
) {
|
|
188
201
|
Box(
|
|
189
|
-
Modifier
|
|
190
|
-
|
|
191
|
-
.padding(vertical = Spacing.S, horizontal = Spacing.M)
|
|
192
|
-
)
|
|
193
|
-
{
|
|
202
|
+
Modifier.fillMaxWidth().padding(vertical = Spacing.S, horizontal = Spacing.M)
|
|
203
|
+
) {
|
|
194
204
|
footer?.invoke()
|
|
195
205
|
}
|
|
196
206
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package vn.momo.kits.components
|
|
2
2
|
|
|
3
3
|
import androidx.compose.foundation.background
|
|
4
|
-
import androidx.compose.foundation.border
|
|
5
4
|
import androidx.compose.foundation.clickable
|
|
6
5
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
7
6
|
import androidx.compose.foundation.layout.Arrangement
|
|
@@ -33,13 +32,19 @@ import androidx.compose.ui.text.input.KeyboardType
|
|
|
33
32
|
import androidx.compose.ui.unit.dp
|
|
34
33
|
import androidx.compose.ui.unit.sp
|
|
35
34
|
import vn.momo.kits.const.AppTheme
|
|
35
|
+
import vn.momo.kits.const.Colors
|
|
36
36
|
import vn.momo.kits.const.Radius
|
|
37
37
|
import vn.momo.kits.const.Spacing
|
|
38
38
|
import vn.momo.kits.const.Typography
|
|
39
39
|
import vn.momo.kits.utils.ifTrue
|
|
40
40
|
|
|
41
41
|
@Composable
|
|
42
|
-
fun RenderRightIconSearch(
|
|
42
|
+
fun RenderRightIconSearch(
|
|
43
|
+
loading: Boolean,
|
|
44
|
+
icon: String,
|
|
45
|
+
color: Color,
|
|
46
|
+
onClick: () -> Unit,
|
|
47
|
+
) {
|
|
43
48
|
if (loading) {
|
|
44
49
|
Box(Modifier.padding(horizontal = Spacing.S)) {
|
|
45
50
|
CircularProgressIndicator(
|
|
@@ -68,34 +73,41 @@ fun RenderRightIconSearch(loading: Boolean, icon: String, color: Color, onClick:
|
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
|
|
76
|
+
data class InputSearchProps(
|
|
77
|
+
val text: MutableState<String>,
|
|
78
|
+
val buttonText: String = "",
|
|
79
|
+
val showButtonText: Boolean = false,
|
|
80
|
+
val placeholder: String = "",
|
|
81
|
+
val onChangeText: (String) -> Unit = {},
|
|
82
|
+
val onPressButtonText: () -> Unit = {},
|
|
83
|
+
val disabled: Boolean = false,
|
|
84
|
+
val icon: String = "",
|
|
85
|
+
val iconColor: Color = Color(0xff),
|
|
86
|
+
val onRightIconPressed: () -> Unit = {},
|
|
87
|
+
val onFocus: () -> Unit = {},
|
|
88
|
+
val onBlur: () -> Unit = {},
|
|
89
|
+
val loading: Boolean = false,
|
|
90
|
+
val fontWeight: InputFontWeight = InputFontWeight.REGULAR,
|
|
91
|
+
val keyboardType: KeyboardType = KeyboardType.Text,
|
|
92
|
+
val backgroundColor: Color = Colors.black_01,
|
|
93
|
+
)
|
|
94
|
+
|
|
71
95
|
@Composable
|
|
72
96
|
fun InputSearch(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
onChangeText: (String) -> Unit = {},
|
|
79
|
-
onPressButtonText: () -> Unit = {},
|
|
80
|
-
error: String = "",
|
|
81
|
-
disabled: Boolean = false,
|
|
82
|
-
icon: String = "",
|
|
83
|
-
iconColor: Color = AppTheme.current.colors.text.default,
|
|
84
|
-
onRightIconPressed: () -> Unit = {},
|
|
85
|
-
onFocus: () -> Unit = {},
|
|
86
|
-
onBlur: () -> Unit = {},
|
|
87
|
-
loading: Boolean = false,
|
|
88
|
-
fontWeight: InputFontWeight = InputFontWeight.REGULAR,
|
|
89
|
-
keyboardType: KeyboardType = KeyboardType.Text,
|
|
97
|
+
inputSearchProps: InputSearchProps = InputSearchProps(
|
|
98
|
+
text = remember { mutableStateOf("") },
|
|
99
|
+
iconColor = AppTheme.current.colors.text.default
|
|
100
|
+
),
|
|
101
|
+
|
|
90
102
|
) {
|
|
91
103
|
var isFocused by remember { mutableStateOf(false) }
|
|
92
104
|
var isBlurred = false
|
|
93
105
|
val disabledColor = AppTheme.current.colors.text.disable
|
|
94
106
|
var textColor = AppTheme.current.colors.text.default
|
|
95
107
|
var placeholderColor = AppTheme.current.colors.text.hint
|
|
96
|
-
var iconTintColor = iconColor
|
|
108
|
+
var iconTintColor = inputSearchProps.iconColor
|
|
97
109
|
|
|
98
|
-
if (disabled) {
|
|
110
|
+
if (inputSearchProps.disabled) {
|
|
99
111
|
textColor = disabledColor
|
|
100
112
|
placeholderColor = disabledColor
|
|
101
113
|
iconTintColor = disabledColor
|
|
@@ -103,37 +115,31 @@ fun InputSearch(
|
|
|
103
115
|
|
|
104
116
|
Column {
|
|
105
117
|
BasicTextField(
|
|
106
|
-
enabled = !disabled,
|
|
118
|
+
enabled = !inputSearchProps.disabled,
|
|
107
119
|
singleLine = true,
|
|
108
|
-
value = text.value,
|
|
120
|
+
value = inputSearchProps.text.value,
|
|
109
121
|
textStyle = TextStyle(
|
|
110
122
|
color = textColor,
|
|
111
|
-
fontSize =
|
|
112
|
-
lineHeight =
|
|
113
|
-
fontWeight = fontWeight.value
|
|
123
|
+
fontSize = 14.sp,
|
|
124
|
+
lineHeight = 20.sp,
|
|
125
|
+
fontWeight = inputSearchProps.fontWeight.value
|
|
114
126
|
),
|
|
115
|
-
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType),
|
|
127
|
+
keyboardOptions = KeyboardOptions.Default.copy(keyboardType = inputSearchProps.keyboardType),
|
|
116
128
|
modifier = Modifier.height(36.dp).onFocusChanged {
|
|
117
129
|
isFocused = it.isFocused
|
|
118
130
|
if (it.isFocused) {
|
|
119
|
-
onFocus()
|
|
131
|
+
inputSearchProps.onFocus()
|
|
120
132
|
}
|
|
121
|
-
if (!it.isFocused && isBlurred) onBlur()
|
|
133
|
+
if (!it.isFocused && isBlurred) inputSearchProps.onBlur()
|
|
122
134
|
if (it.isFocused && !isBlurred) isBlurred = true
|
|
123
135
|
},
|
|
124
|
-
onValueChange = onChangeText,
|
|
136
|
+
onValueChange = inputSearchProps.onChangeText,
|
|
125
137
|
decorationBox = { innerTextField ->
|
|
126
|
-
//input box wrapper
|
|
127
138
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
128
139
|
Row(
|
|
129
|
-
modifier = Modifier.weight(showButtonText.ifTrue(8f, 1f))
|
|
140
|
+
modifier = Modifier.weight(inputSearchProps.showButtonText.ifTrue(8f, 1f))
|
|
130
141
|
.background(
|
|
131
|
-
|
|
132
|
-
RoundedCornerShape(Radius.XL)
|
|
133
|
-
)
|
|
134
|
-
.border(
|
|
135
|
-
showBorder.ifTrue(1.dp, 0.dp),
|
|
136
|
-
getBorderColor(isFocused, error, disabled),
|
|
142
|
+
inputSearchProps.backgroundColor,
|
|
137
143
|
RoundedCornerShape(Radius.XL)
|
|
138
144
|
),
|
|
139
145
|
horizontalArrangement = Arrangement.Start,
|
|
@@ -154,20 +160,20 @@ fun InputSearch(
|
|
|
154
160
|
color = AppTheme.current.colors.text.hint
|
|
155
161
|
)
|
|
156
162
|
Box(Modifier.weight(1f)) {
|
|
157
|
-
if (text.value.isEmpty()) {
|
|
163
|
+
if (inputSearchProps.text.value.isEmpty()) {
|
|
158
164
|
Text(
|
|
159
|
-
text = placeholder,
|
|
165
|
+
text = inputSearchProps.placeholder,
|
|
160
166
|
style = TextStyle(
|
|
161
167
|
fontSize = 16.sp,
|
|
162
168
|
lineHeight = 24.sp,
|
|
163
|
-
fontWeight = fontWeight.value
|
|
169
|
+
fontWeight = inputSearchProps.fontWeight.value
|
|
164
170
|
),
|
|
165
171
|
color = placeholderColor
|
|
166
172
|
)
|
|
167
173
|
}
|
|
168
174
|
innerTextField()
|
|
169
175
|
}
|
|
170
|
-
if (isFocused && text.value.isNotEmpty()) {
|
|
176
|
+
if (isFocused && inputSearchProps.text.value.isNotEmpty()) {
|
|
171
177
|
Row {
|
|
172
178
|
Spacer(Modifier.width(Spacing.XS))
|
|
173
179
|
Icon(
|
|
@@ -175,25 +181,30 @@ fun InputSearch(
|
|
|
175
181
|
size = 16.dp,
|
|
176
182
|
color = AppTheme.current.colors.text.hint,
|
|
177
183
|
modifier = Modifier.clickable(
|
|
178
|
-
onClick = { text.value = "" },
|
|
184
|
+
onClick = { inputSearchProps.text.value = "" },
|
|
179
185
|
interactionSource = remember { MutableInteractionSource() },
|
|
180
186
|
indication = null
|
|
181
187
|
)
|
|
182
188
|
)
|
|
183
189
|
}
|
|
184
190
|
}
|
|
185
|
-
RenderRightIconSearch(
|
|
191
|
+
RenderRightIconSearch(
|
|
192
|
+
inputSearchProps.loading,
|
|
193
|
+
inputSearchProps.icon,
|
|
194
|
+
iconTintColor,
|
|
195
|
+
inputSearchProps.onRightIconPressed
|
|
196
|
+
)
|
|
186
197
|
}
|
|
187
198
|
}
|
|
188
|
-
if (showButtonText) {
|
|
199
|
+
if (inputSearchProps.showButtonText) {
|
|
189
200
|
Text(
|
|
190
|
-
text = buttonText,
|
|
201
|
+
text = inputSearchProps.buttonText,
|
|
191
202
|
style = Typography.actionDefault,
|
|
192
203
|
color = AppTheme.current.colors.text.default,
|
|
193
204
|
modifier = Modifier.padding(start = Spacing.L).clickable(
|
|
194
205
|
interactionSource = remember { MutableInteractionSource() },
|
|
195
206
|
indication = null,
|
|
196
|
-
onClick = onPressButtonText
|
|
207
|
+
onClick = inputSearchProps.onPressButtonText
|
|
197
208
|
)
|
|
198
209
|
)
|
|
199
210
|
}
|
|
@@ -106,7 +106,7 @@ val defaultTheme = Theme(
|
|
|
106
106
|
),
|
|
107
107
|
font = "SFProText",
|
|
108
108
|
assets = ThemeAssets(
|
|
109
|
-
headerBackground =
|
|
109
|
+
headerBackground = null
|
|
110
110
|
)
|
|
111
111
|
)
|
|
112
112
|
|
|
@@ -168,6 +168,5 @@ val darkTheme = Theme(
|
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
val AppTheme = staticCompositionLocalOf { defaultTheme }
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
171
|
+
|
|
172
|
+
val AppStatusBar = staticCompositionLocalOf<Dp?> { null }
|
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
|
+
#Tue Apr 23 16:40:15 ICT 2024
|
|
8
|
+
sdk.dir=/Users/hung.dao1/Library/Android/sdk
|