@momo-kits/native-kits 0.114.2-beta.1 → 0.114.2-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 +1 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +28 -30
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +35 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +6 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +4 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +1 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +41 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +25 -37
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +13 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +3 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +178 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +237 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +92 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +12 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +1 -1
- package/ios/Application/ApplicationEnvironment.swift +17 -9
- package/ios/Application/Components.swift +9 -10
- package/ios/Application/HeaderRight.swift +29 -30
- package/ios/Application/Screen.swift +1 -1
- package/ios/Popup/PopupDisplay.swift +2 -2
- package/ios/Template/TrustBanner/TrustBanner.swift +75 -144
- package/local.properties +2 -2
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
|
@@ -38,7 +38,7 @@ fun HeaderBackground(
|
|
|
38
38
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
39
39
|
|
|
40
40
|
val opacityAni by animateFloatAsState(
|
|
41
|
-
targetValue = (1 - (scrollState / HEADER_HEIGHT*1f)).coerceIn(0f, 1f),
|
|
41
|
+
targetValue = (1 - (scrollState / HEADER_HEIGHT * 1f)).coerceIn(0f, 1f),
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
val backgroundColor by animateColorAsState(
|
|
@@ -88,8 +88,32 @@ fun HeaderRight(
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
private fun getNavigationButtonConfig(
|
|
92
|
+
headerRight: HeaderRightData? = null,
|
|
93
|
+
isFavorite: Boolean = false,
|
|
94
|
+
onPressShortcut: () -> Unit,
|
|
95
|
+
onPressMore: () -> Unit
|
|
96
|
+
): NavigationButtonConfig {
|
|
97
|
+
val totalTools = headerRight?.tools?.sumOf { it.items.size } ?: 0
|
|
98
|
+
var icon = if (isFavorite) "pin_star_checked" else "pin_star"
|
|
99
|
+
var onClickHandler = onPressShortcut
|
|
100
|
+
if (totalTools > 1 || headerRight?.useMore == true) {
|
|
101
|
+
icon = "navigation_more_icon"
|
|
102
|
+
onClickHandler = onPressMore
|
|
103
|
+
} else if (totalTools == 1 && !headerRight?.tools.isNullOrEmpty()) {
|
|
104
|
+
val singleTool = headerRight?.tools?.first()?.items?.firstOrNull()
|
|
105
|
+
if (singleTool != null) {
|
|
106
|
+
icon = singleTool.icon
|
|
107
|
+
onClickHandler = {
|
|
108
|
+
headerRight.toolCallback?.invoke(singleTool.key)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return NavigationButtonConfig(icon, onClickHandler)
|
|
113
|
+
}
|
|
114
|
+
|
|
91
115
|
@Composable
|
|
92
|
-
fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
|
|
116
|
+
private fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
|
|
93
117
|
var isFavorite by remember { mutableStateOf(false) }
|
|
94
118
|
val isLoading by remember { mutableStateOf(false) }
|
|
95
119
|
val api = PlatformApi.current as? ComposeApi
|
|
@@ -148,34 +172,8 @@ fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
|
|
|
148
172
|
}
|
|
149
173
|
}
|
|
150
174
|
|
|
151
|
-
fun getNavigationButtonConfig(
|
|
152
|
-
tools: List<ToolGroup>? = emptyList(),
|
|
153
|
-
useMore: Boolean? = false,
|
|
154
|
-
isFavorite: Boolean = false,
|
|
155
|
-
onPressShortcut: () -> Unit,
|
|
156
|
-
onPressMore: () -> Unit
|
|
157
|
-
): NavigationButtonConfig {
|
|
158
|
-
val totalTools = tools?.sumOf { it.items.size } ?: 0
|
|
159
|
-
var icon = if (isFavorite) "pin_star_checked" else "pin_star"
|
|
160
|
-
var onClickHandler = onPressShortcut
|
|
161
|
-
if (totalTools > 1 || useMore == true) {
|
|
162
|
-
icon = "navigation_more_icon"
|
|
163
|
-
onClickHandler = onPressMore
|
|
164
|
-
} else if (totalTools == 1 && !tools.isNullOrEmpty()) {
|
|
165
|
-
val singleTool = tools.first().items.firstOrNull()
|
|
166
|
-
if (singleTool != null) {
|
|
167
|
-
icon = singleTool.icon
|
|
168
|
-
onClickHandler = {
|
|
169
|
-
headerRight?.toolCallback?.invoke(singleTool.key)
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return NavigationButtonConfig(icon, onClickHandler)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
175
|
val navButtonConfig = getNavigationButtonConfig(
|
|
177
|
-
headerRight
|
|
178
|
-
headerRight?.useMore,
|
|
176
|
+
headerRight,
|
|
179
177
|
isFavorite,
|
|
180
178
|
::onPressShortcut,
|
|
181
179
|
::onPressMore
|
|
@@ -188,7 +186,7 @@ fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
|
|
|
188
186
|
val toolkitWidth = if (context !== null) 65.dp else 28.dp
|
|
189
187
|
|
|
190
188
|
var isShowShortcut = headerRight?.useShortcut == true
|
|
191
|
-
|
|
189
|
+
|
|
192
190
|
if (headerRight?.useMore == true && context == null) {
|
|
193
191
|
isShowShortcut = false
|
|
194
192
|
}
|
|
@@ -264,7 +262,7 @@ fun NavigationButton(
|
|
|
264
262
|
) {
|
|
265
263
|
Icon(
|
|
266
264
|
source = icon,
|
|
267
|
-
size =
|
|
265
|
+
size = 20.dp
|
|
268
266
|
)
|
|
269
267
|
}
|
|
270
268
|
|
|
@@ -9,7 +9,6 @@ import androidx.compose.runtime.remember
|
|
|
9
9
|
import androidx.compose.runtime.setValue
|
|
10
10
|
import androidx.compose.runtime.staticCompositionLocalOf
|
|
11
11
|
import androidx.compose.ui.unit.Dp
|
|
12
|
-
import kotlinx.serialization.Serializable
|
|
13
12
|
import vn.momo.kits.components.TrustBannerData
|
|
14
13
|
import vn.momo.kits.const.AppStatusBar
|
|
15
14
|
import vn.momo.kits.const.AppTheme
|
|
@@ -27,20 +26,41 @@ interface ComposeApi {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
class Navigator {
|
|
30
|
-
fun push(content: @Composable () -> Unit) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
fun
|
|
35
|
-
|
|
29
|
+
fun push(content: @Composable () -> Unit) {
|
|
30
|
+
//implement
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fun present(content: @Composable () -> Unit) {
|
|
34
|
+
//implement
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun reset(content: @Composable () -> Unit) {
|
|
38
|
+
//implement
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun pop() {
|
|
42
|
+
//implement
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun replace(content: @Composable () -> Unit) {
|
|
46
|
+
//implement
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fun popToTop() {
|
|
50
|
+
//implement
|
|
51
|
+
}
|
|
52
|
+
|
|
36
53
|
fun showModal(
|
|
37
54
|
onClose: () -> Unit = {},
|
|
38
55
|
canBackgroundClose: Boolean = true,
|
|
39
56
|
content: @Composable () -> Unit,
|
|
40
57
|
) {
|
|
58
|
+
//implement
|
|
41
59
|
}
|
|
42
60
|
|
|
43
|
-
fun showBottomSheet(content: @Composable () -> Unit) {
|
|
61
|
+
fun showBottomSheet(content: @Composable () -> Unit) {
|
|
62
|
+
//implement
|
|
63
|
+
}
|
|
44
64
|
}
|
|
45
65
|
|
|
46
66
|
data class MiniAppContext(
|
|
@@ -69,6 +89,10 @@ val AppConfig = staticCompositionLocalOf<KitConfig?> {
|
|
|
69
89
|
null
|
|
70
90
|
}
|
|
71
91
|
|
|
92
|
+
val AppLanguage = staticCompositionLocalOf<String?> {
|
|
93
|
+
null
|
|
94
|
+
}
|
|
95
|
+
|
|
72
96
|
data class KitConfig(
|
|
73
97
|
val trustBanner: TrustBannerData? = null,
|
|
74
98
|
val headerBar: String? = null,
|
|
@@ -82,6 +106,7 @@ fun ApplicationContainer(
|
|
|
82
106
|
statusBarHeight: Dp? = AppStatusBar.current,
|
|
83
107
|
applicationContext: MiniAppContext? = null,
|
|
84
108
|
config: KitConfig? = null,
|
|
109
|
+
language: String? = null,
|
|
85
110
|
content: @Composable () -> Unit,
|
|
86
111
|
) {
|
|
87
112
|
var appTheme by remember { mutableStateOf(theme) }
|
|
@@ -110,7 +135,8 @@ fun ApplicationContainer(
|
|
|
110
135
|
AppNavigator provides Navigator(),
|
|
111
136
|
AppStatusBar provides appStatusBarHeight,
|
|
112
137
|
ApplicationContext provides applicationContext,
|
|
113
|
-
AppConfig provides config
|
|
138
|
+
AppConfig provides config,
|
|
139
|
+
AppLanguage provides language
|
|
114
140
|
) {
|
|
115
141
|
content()
|
|
116
142
|
}
|
|
@@ -87,7 +87,7 @@ fun Screen(
|
|
|
87
87
|
val bottomPadding = min(indicator, 21.dp)
|
|
88
88
|
|
|
89
89
|
val opacity by animateFloatAsState(
|
|
90
|
-
targetValue = ((scrollState.value / HEADER_HEIGHT*1f)).coerceIn(0f, 1f),
|
|
90
|
+
targetValue = ((scrollState.value / HEADER_HEIGHT * 1f)).coerceIn(0f, 1f),
|
|
91
91
|
)
|
|
92
92
|
|
|
93
93
|
val headerAnimated =
|
|
@@ -42,18 +42,21 @@ fun useHeaderSearchAnimation(
|
|
|
42
42
|
)
|
|
43
43
|
|
|
44
44
|
val animatedTranslateX by animateFloatAsState(
|
|
45
|
-
targetValue = (scrollState / HEADER_HEIGHT*1f).coerceIn(
|
|
45
|
+
targetValue = (scrollState / HEADER_HEIGHT * 1f).coerceIn(
|
|
46
|
+
0f,
|
|
47
|
+
1f
|
|
48
|
+
) * (leftPosition.value - 12) + 12,
|
|
46
49
|
)
|
|
47
50
|
|
|
48
51
|
val animatedWidth by animateFloatAsState(
|
|
49
|
-
targetValue = (scrollState / HEADER_HEIGHT*1f).coerceIn(
|
|
52
|
+
targetValue = (scrollState / HEADER_HEIGHT * 1f).coerceIn(
|
|
50
53
|
0f,
|
|
51
54
|
1f
|
|
52
55
|
) * ((searchWidth - leftPosition.value - headerRightWidth.value + 12) - searchWidth) + searchWidth,
|
|
53
56
|
)
|
|
54
57
|
|
|
55
58
|
val animatedTranslateY by animateFloatAsState(
|
|
56
|
-
targetValue = (1 - (scrollState / HEADER_HEIGHT* 1f).coerceIn(0f, 1f)) * HEADER_HEIGHT
|
|
59
|
+
targetValue = (1 - (scrollState / HEADER_HEIGHT * 1f).coerceIn(0f, 1f)) * HEADER_HEIGHT
|
|
57
60
|
)
|
|
58
61
|
return HeaderAnimations(
|
|
59
62
|
opacity = opacityAni,
|
|
@@ -20,7 +20,6 @@ import vn.momo.kits.const.Typography
|
|
|
20
20
|
import vn.momo.kits.const.scaleSize
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
24
23
|
@Composable
|
|
25
24
|
fun Badge(label: String = "Label", backgroundColor: Color? = null) {
|
|
26
25
|
val primaryColors = listOf(
|
|
@@ -72,7 +71,7 @@ fun Badge(label: String = "Label", backgroundColor: Color? = null) {
|
|
|
72
71
|
Text(
|
|
73
72
|
text = formatTitle(label),
|
|
74
73
|
color = Colors.black_01,
|
|
75
|
-
style = Typography.
|
|
74
|
+
style = Typography.actionXxsBold
|
|
76
75
|
)
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -74,10 +74,10 @@ enum class Size(val value: ButtonSpecs) {
|
|
|
74
74
|
|
|
75
75
|
fun getStyle(size: Size): TextStyle {
|
|
76
76
|
return when (size.name) {
|
|
77
|
-
Size.LARGE.name -> Typography.
|
|
78
|
-
Size.MEDIUM.name -> Typography.
|
|
79
|
-
Size.SMALL.name -> Typography.
|
|
80
|
-
else -> Typography.
|
|
77
|
+
Size.LARGE.name -> Typography.actionDefaultBold
|
|
78
|
+
Size.MEDIUM.name -> Typography.actionSBold
|
|
79
|
+
Size.SMALL.name -> Typography.actionXsBold
|
|
80
|
+
else -> Typography.actionDefaultBold
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -3,15 +3,12 @@ package vn.momo.kits.components
|
|
|
3
3
|
import androidx.compose.foundation.background
|
|
4
4
|
import androidx.compose.foundation.border
|
|
5
5
|
import androidx.compose.foundation.clickable
|
|
6
|
-
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
7
6
|
import androidx.compose.foundation.layout.Box
|
|
8
7
|
import androidx.compose.foundation.layout.Row
|
|
9
8
|
import androidx.compose.foundation.layout.Spacer
|
|
10
9
|
import androidx.compose.foundation.layout.size
|
|
11
10
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
12
|
-
import androidx.compose.material.ripple.rememberRipple
|
|
13
11
|
import androidx.compose.runtime.Composable
|
|
14
|
-
import androidx.compose.runtime.remember
|
|
15
12
|
import androidx.compose.ui.Alignment
|
|
16
13
|
import androidx.compose.ui.Modifier
|
|
17
14
|
import androidx.compose.ui.unit.dp
|
|
@@ -68,7 +65,7 @@ fun CheckBox(
|
|
|
68
65
|
if (title.isNotEmpty()) {
|
|
69
66
|
Spacer(Modifier.size(Spacing.S))
|
|
70
67
|
Text(
|
|
71
|
-
style = Typography.
|
|
68
|
+
style = Typography.descriptionDefaultRegular,
|
|
72
69
|
text = title,
|
|
73
70
|
)
|
|
74
71
|
}
|
|
@@ -27,7 +27,7 @@ fun Icon(
|
|
|
27
27
|
} else {
|
|
28
28
|
Icons[source] ?: ""
|
|
29
29
|
}
|
|
30
|
-
Box(modifier = modifier.size(size).semantics {contentDescription = "img|$icon"}) {
|
|
30
|
+
Box(modifier = modifier.size(size).semantics { contentDescription = "img|$icon" }) {
|
|
31
31
|
AsyncImage(
|
|
32
32
|
modifier = Modifier.matchParentSize(),
|
|
33
33
|
model = icon,
|
|
@@ -3,13 +3,10 @@ package vn.momo.kits.components
|
|
|
3
3
|
import androidx.compose.foundation.background
|
|
4
4
|
import androidx.compose.foundation.border
|
|
5
5
|
import androidx.compose.foundation.clickable
|
|
6
|
-
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
7
6
|
import androidx.compose.foundation.layout.Box
|
|
8
7
|
import androidx.compose.foundation.layout.size
|
|
9
8
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
10
|
-
import androidx.compose.material.ripple.rememberRipple
|
|
11
9
|
import androidx.compose.runtime.Composable
|
|
12
|
-
import androidx.compose.runtime.remember
|
|
13
10
|
import androidx.compose.ui.Alignment
|
|
14
11
|
import androidx.compose.ui.Modifier
|
|
15
12
|
import androidx.compose.ui.draw.clip
|
|
@@ -47,7 +47,7 @@ fun Image(
|
|
|
47
47
|
)
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
Box(modifier = modifier.semantics {contentDescription = "img|$source"}) {
|
|
50
|
+
Box(modifier = modifier.semantics { contentDescription = "img|$source" }) {
|
|
51
51
|
AsyncImage(
|
|
52
52
|
modifier = Modifier.matchParentSize(),
|
|
53
53
|
model = source,
|
|
@@ -67,6 +67,7 @@ fun Image(
|
|
|
67
67
|
color = AppTheme.current.colors.text.disable,
|
|
68
68
|
modifier = modifier
|
|
69
69
|
)
|
|
70
|
+
|
|
70
71
|
ImageState.Success -> {}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -20,7 +20,7 @@ import vn.momo.kits.const.Spacing
|
|
|
20
20
|
import vn.momo.kits.const.Typography
|
|
21
21
|
|
|
22
22
|
enum class InformationState {
|
|
23
|
-
DEFAULT
|
|
23
|
+
DEFAULT,
|
|
24
24
|
WARNING,
|
|
25
25
|
ERROR
|
|
26
26
|
}
|
|
@@ -31,12 +31,12 @@ fun Information(
|
|
|
31
31
|
description: String = "Description",
|
|
32
32
|
state: InformationState = InformationState.DEFAULT,
|
|
33
33
|
image: String? = null,
|
|
34
|
-
|
|
34
|
+
onPressAction: (() -> Unit)? = null,
|
|
35
35
|
showIcon: Boolean = true,
|
|
36
|
-
|
|
36
|
+
action: String? = null,
|
|
37
37
|
showIconClose: Boolean = true,
|
|
38
|
-
onPressClose: (()->Unit)? = null,
|
|
39
|
-
){
|
|
38
|
+
onPressClose: (() -> Unit)? = null,
|
|
39
|
+
) {
|
|
40
40
|
var borderColor = Colors.blue_07
|
|
41
41
|
var backgroundColor = Colors.blue_10
|
|
42
42
|
var color = Colors.blue_03
|
|
@@ -46,45 +46,64 @@ fun Information(
|
|
|
46
46
|
borderColor = Colors.yellow_06
|
|
47
47
|
backgroundColor = Colors.yellow_09
|
|
48
48
|
color = Colors.orange_03
|
|
49
|
-
iconSource = "24_notifications_alert_triangle"
|
|
49
|
+
iconSource = "24_notifications_alert_triangle"
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
if (state === InformationState.ERROR) {
|
|
53
53
|
borderColor = Colors.red_07
|
|
54
54
|
backgroundColor = Colors.red_10
|
|
55
55
|
color = Colors.red_03
|
|
56
|
-
iconSource = "24_notifications_alert_octagon"
|
|
56
|
+
iconSource = "24_notifications_alert_octagon"
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
Column(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.
|
|
59
|
+
Column(
|
|
60
|
+
modifier = Modifier.border(
|
|
61
|
+
width = 0.5.dp,
|
|
62
|
+
shape = RoundedCornerShape(Radius.S),
|
|
63
|
+
color = borderColor
|
|
64
|
+
).background(color = backgroundColor)
|
|
65
|
+
.padding(Spacing.M)
|
|
65
66
|
) {
|
|
66
67
|
Row {
|
|
67
68
|
if (image != null) {
|
|
68
|
-
Image(
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
Image(
|
|
70
|
+
source = image,
|
|
71
|
+
modifier = Modifier.padding(end = Spacing.S).width(40.dp).height(40.dp).clip(
|
|
72
|
+
RoundedCornerShape(Radius.S)
|
|
73
|
+
)
|
|
74
|
+
)
|
|
71
75
|
}
|
|
72
76
|
if (image == null && showIcon) {
|
|
73
|
-
Icon(
|
|
77
|
+
Icon(
|
|
78
|
+
source = iconSource,
|
|
79
|
+
size = 16.dp,
|
|
80
|
+
color = color,
|
|
81
|
+
modifier = Modifier.padding(end = Spacing.S)
|
|
82
|
+
)
|
|
74
83
|
}
|
|
75
84
|
Column(modifier = Modifier.weight(1f)) {
|
|
76
85
|
if (title != null) {
|
|
77
|
-
Text(title, style = Typography.
|
|
86
|
+
Text(title, style = Typography.labelDefaultMedium)
|
|
78
87
|
}
|
|
79
|
-
Text(description, style = Typography.
|
|
88
|
+
Text(description, style = Typography.descriptionDefaultRegular)
|
|
80
89
|
}
|
|
81
90
|
if (onPressClose != null && showIconClose) {
|
|
82
|
-
Icon(
|
|
91
|
+
Icon(
|
|
92
|
+
source = "navigation_close",
|
|
93
|
+
size = 16.dp,
|
|
94
|
+
modifier = Modifier.clickable(onClick = onPressClose)
|
|
95
|
+
)
|
|
83
96
|
}
|
|
84
97
|
}
|
|
85
|
-
if (
|
|
98
|
+
if (action != null && onPressAction != null) {
|
|
86
99
|
Row(modifier = Modifier.padding(top = Spacing.S)) {
|
|
87
|
-
Text(
|
|
100
|
+
Text(
|
|
101
|
+
action,
|
|
102
|
+
modifier = Modifier.weight(1f).clickable(onClick = onPressAction),
|
|
103
|
+
textAlign = TextAlign.End,
|
|
104
|
+
style = Typography.actionXsBold,
|
|
105
|
+
color = color
|
|
106
|
+
)
|
|
88
107
|
}
|
|
89
108
|
}
|
|
90
109
|
}
|
|
@@ -21,7 +21,6 @@ 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
|
|
25
24
|
import androidx.compose.runtime.getValue
|
|
26
25
|
import androidx.compose.runtime.mutableStateOf
|
|
27
26
|
import androidx.compose.runtime.remember
|
|
@@ -37,7 +36,6 @@ import androidx.compose.ui.text.TextStyle
|
|
|
37
36
|
import androidx.compose.ui.text.font.FontWeight
|
|
38
37
|
import androidx.compose.ui.text.input.KeyboardType
|
|
39
38
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
|
40
|
-
import androidx.compose.ui.text.input.TextFieldValue
|
|
41
39
|
import androidx.compose.ui.text.input.VisualTransformation
|
|
42
40
|
import androidx.compose.ui.unit.Dp
|
|
43
41
|
import androidx.compose.ui.unit.dp
|
|
@@ -144,7 +142,7 @@ fun ErrorView(errorMessage: String, errorSpacing: Boolean, hintText: String) {
|
|
|
144
142
|
)
|
|
145
143
|
Text(
|
|
146
144
|
errorMessage.ifEmpty { hintTextDefault },
|
|
147
|
-
style = Typography.
|
|
145
|
+
style = Typography.descriptionDefaultRegular,
|
|
148
146
|
modifier = Modifier.padding(start = Spacing.XS),
|
|
149
147
|
color = color,
|
|
150
148
|
)
|
|
@@ -156,7 +154,7 @@ fun ErrorView(errorMessage: String, errorSpacing: Boolean, hintText: String) {
|
|
|
156
154
|
|
|
157
155
|
@Composable
|
|
158
156
|
fun Input(
|
|
159
|
-
text: String = "",
|
|
157
|
+
text: MutableState<String> = remember { mutableStateOf("") },
|
|
160
158
|
floatingValue: String = "",
|
|
161
159
|
floatingValueColor: Color = AppTheme.current.colors.text.hint,
|
|
162
160
|
floatingIcon: String = "",
|
|
@@ -183,11 +181,6 @@ fun Input(
|
|
|
183
181
|
keyboardType: KeyboardType = KeyboardType.Text,
|
|
184
182
|
modifier: Modifier = Modifier,
|
|
185
183
|
) {
|
|
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
|
-
|
|
191
184
|
var isFocused by remember { mutableStateOf(false) }
|
|
192
185
|
var passHidden by remember { mutableStateOf(false) }
|
|
193
186
|
var isBlurred = false
|
|
@@ -212,14 +205,14 @@ fun Input(
|
|
|
212
205
|
|
|
213
206
|
val testId = if (disabled) "input_${floatingValue}_disabled" else "input_$floatingValue"
|
|
214
207
|
|
|
215
|
-
Column(
|
|
216
|
-
|
|
208
|
+
Column(
|
|
209
|
+
modifier = modifier.setAutomationId(testId)
|
|
217
210
|
) {
|
|
218
211
|
BasicTextField(
|
|
219
|
-
value = text,
|
|
220
212
|
enabled = !disabled,
|
|
221
213
|
readOnly = readOnly,
|
|
222
214
|
singleLine = true,
|
|
215
|
+
value = text.value,
|
|
223
216
|
textStyle = TextStyle(
|
|
224
217
|
color = textColor,
|
|
225
218
|
fontSize = 16.sp,
|
|
@@ -236,15 +229,7 @@ fun Input(
|
|
|
236
229
|
if (!it.isFocused && isBlurred) onBlur()
|
|
237
230
|
if (it.isFocused && !isBlurred) isBlurred = true
|
|
238
231
|
},
|
|
239
|
-
onValueChange =
|
|
240
|
-
textFieldValueState.copy(text = newValue)
|
|
241
|
-
val stringChangedSinceLastInvocation = lastTextValue != newValue
|
|
242
|
-
lastTextValue = newValue
|
|
243
|
-
|
|
244
|
-
if (stringChangedSinceLastInvocation) {
|
|
245
|
-
onChangeText(newValue)
|
|
246
|
-
}
|
|
247
|
-
},
|
|
232
|
+
onValueChange = onChangeText,
|
|
248
233
|
decorationBox = { innerTextField ->
|
|
249
234
|
// Floating Icon
|
|
250
235
|
if (floatingValue.isNotEmpty() || floatingIcon.isNotEmpty()) {
|
|
@@ -261,13 +246,13 @@ fun Input(
|
|
|
261
246
|
) {
|
|
262
247
|
Text(
|
|
263
248
|
floatingValue,
|
|
264
|
-
style = Typography.
|
|
249
|
+
style = Typography.labelSMedium,
|
|
265
250
|
color = floatingTitleColor
|
|
266
251
|
)
|
|
267
252
|
if (required) {
|
|
268
253
|
Text(
|
|
269
254
|
"*",
|
|
270
|
-
style = Typography.
|
|
255
|
+
style = Typography.labelSMedium,
|
|
271
256
|
color = AppTheme.current.colors.error.primary,
|
|
272
257
|
)
|
|
273
258
|
}
|
|
@@ -306,7 +291,7 @@ fun Input(
|
|
|
306
291
|
)
|
|
307
292
|
}
|
|
308
293
|
Box(Modifier.weight(1f)) {
|
|
309
|
-
if (
|
|
294
|
+
if (text.value.isEmpty()) {
|
|
310
295
|
Text(
|
|
311
296
|
text = placeholder,
|
|
312
297
|
style = TextStyle(
|
|
@@ -319,7 +304,7 @@ fun Input(
|
|
|
319
304
|
}
|
|
320
305
|
innerTextField()
|
|
321
306
|
}
|
|
322
|
-
if (isFocused &&
|
|
307
|
+
if (isFocused && text.value.isNotEmpty()) {
|
|
323
308
|
Row {
|
|
324
309
|
Spacer(Modifier.width(Spacing.XS))
|
|
325
310
|
Icon(
|
|
@@ -327,10 +312,7 @@ fun Input(
|
|
|
327
312
|
size = 16.dp,
|
|
328
313
|
color = AppTheme.current.colors.text.hint,
|
|
329
314
|
modifier = Modifier.clickable(
|
|
330
|
-
onClick = {
|
|
331
|
-
onChangeText("")
|
|
332
|
-
textFieldValueState = TextFieldValue(text = "")
|
|
333
|
-
},
|
|
315
|
+
onClick = { text.value = "" },
|
|
334
316
|
interactionSource = remember { MutableInteractionSource() },
|
|
335
317
|
indication = null
|
|
336
318
|
)
|
|
@@ -338,16 +320,22 @@ fun Input(
|
|
|
338
320
|
}
|
|
339
321
|
}
|
|
340
322
|
if (secureTextEntry && passHidden) {
|
|
341
|
-
val hidePassword = { onRightIconPressed(); passHidden = !passHidden}
|
|
342
|
-
RenderRightIcon(
|
|
343
|
-
|
|
323
|
+
val hidePassword = { onRightIconPressed(); passHidden = !passHidden }
|
|
324
|
+
RenderRightIcon(
|
|
325
|
+
loading, "24_security_eye_open", iconTintColor,
|
|
326
|
+
hidePassword
|
|
327
|
+
)
|
|
344
328
|
} else if (secureTextEntry && !passHidden) {
|
|
345
|
-
val showPassword = { onRightIconPressed(); passHidden = !passHidden}
|
|
346
|
-
RenderRightIcon(
|
|
347
|
-
|
|
329
|
+
val showPassword = { onRightIconPressed(); passHidden = !passHidden }
|
|
330
|
+
RenderRightIcon(
|
|
331
|
+
loading, "24_security_eye_off", iconTintColor,
|
|
332
|
+
showPassword
|
|
333
|
+
)
|
|
348
334
|
} else {
|
|
349
|
-
RenderRightIcon(
|
|
350
|
-
|
|
335
|
+
RenderRightIcon(
|
|
336
|
+
loading, icon, iconTintColor,
|
|
337
|
+
onRightIconPressed
|
|
338
|
+
)
|
|
351
339
|
}
|
|
352
340
|
}
|
|
353
341
|
}
|
|
@@ -94,13 +94,13 @@ fun InputDropDown(
|
|
|
94
94
|
) {
|
|
95
95
|
Text(
|
|
96
96
|
floatingValue,
|
|
97
|
-
style = Typography.
|
|
97
|
+
style = Typography.labelSMedium,
|
|
98
98
|
color = floatingTitleColor
|
|
99
99
|
)
|
|
100
100
|
if (required) {
|
|
101
101
|
Text(
|
|
102
102
|
"*",
|
|
103
|
-
style = Typography.
|
|
103
|
+
style = Typography.labelSMedium,
|
|
104
104
|
color = AppTheme.current.colors.error.primary,
|
|
105
105
|
)
|
|
106
106
|
}
|