@momo-kits/native-kits 0.157.5-debug → 0.157.6-debug
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 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +123 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +348 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +256 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +494 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +131 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +215 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +531 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +192 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +3 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +5 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +2 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +5 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -0
- package/gradle.properties +1 -1
- package/ios/Popup/PopupPromotion.swift +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.foundation.background
|
|
4
|
+
import androidx.compose.foundation.border
|
|
5
|
+
import androidx.compose.foundation.horizontalScroll
|
|
6
|
+
import androidx.compose.foundation.layout.Arrangement
|
|
7
|
+
import androidx.compose.foundation.layout.Box
|
|
8
|
+
import androidx.compose.foundation.layout.Column
|
|
9
|
+
import androidx.compose.foundation.layout.Row
|
|
10
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
11
|
+
import androidx.compose.foundation.layout.padding
|
|
12
|
+
import androidx.compose.foundation.layout.size
|
|
13
|
+
import androidx.compose.foundation.rememberScrollState
|
|
14
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
15
|
+
import androidx.compose.runtime.Composable
|
|
16
|
+
import androidx.compose.runtime.remember
|
|
17
|
+
import androidx.compose.ui.Alignment
|
|
18
|
+
import androidx.compose.ui.Modifier
|
|
19
|
+
import androidx.compose.ui.draw.clip
|
|
20
|
+
import androidx.compose.ui.draw.drawBehind
|
|
21
|
+
import androidx.compose.ui.geometry.CornerRadius
|
|
22
|
+
import androidx.compose.ui.graphics.Color
|
|
23
|
+
import androidx.compose.ui.graphics.PathEffect
|
|
24
|
+
import androidx.compose.ui.graphics.drawscope.Stroke
|
|
25
|
+
import androidx.compose.ui.unit.Dp
|
|
26
|
+
import androidx.compose.ui.unit.dp
|
|
27
|
+
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
28
|
+
import vn.momo.kits.const.AppTheme
|
|
29
|
+
import vn.momo.kits.const.Colors
|
|
30
|
+
import vn.momo.kits.const.Radius
|
|
31
|
+
import vn.momo.kits.const.Spacing
|
|
32
|
+
import vn.momo.kits.const.Typography
|
|
33
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
34
|
+
import vn.momo.kits.modifier.conditional
|
|
35
|
+
|
|
36
|
+
data class UploadImage(
|
|
37
|
+
val uri: String? = null,
|
|
38
|
+
val loading: Boolean = false,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
@Composable
|
|
42
|
+
fun Uploader(
|
|
43
|
+
images: List<UploadImage>,
|
|
44
|
+
modifier: Modifier = Modifier,
|
|
45
|
+
numberOfImages: Int = 1,
|
|
46
|
+
disabled: Boolean = false,
|
|
47
|
+
width: Dp = 64.dp,
|
|
48
|
+
height: Dp = 64.dp,
|
|
49
|
+
onAdd: () -> Unit = {},
|
|
50
|
+
onCancel: ((image: UploadImage, index: Int) -> Unit)? = null,
|
|
51
|
+
onPressImage: (image: UploadImage, index: Int) -> Unit = { _, _ -> },
|
|
52
|
+
) {
|
|
53
|
+
val shouldShowPicker = remember(images.size, numberOfImages) {
|
|
54
|
+
images.size < numberOfImages
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Row(
|
|
58
|
+
modifier = modifier
|
|
59
|
+
.conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) },
|
|
60
|
+
horizontalArrangement = Arrangement.spacedBy(Spacing.S),
|
|
61
|
+
verticalAlignment = Alignment.Top,
|
|
62
|
+
) {
|
|
63
|
+
if (shouldShowPicker) {
|
|
64
|
+
UploaderPickerCell(
|
|
65
|
+
disabled = disabled,
|
|
66
|
+
width = width,
|
|
67
|
+
height = height,
|
|
68
|
+
onAdd = onAdd,
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Row(
|
|
73
|
+
modifier = Modifier.horizontalScroll(rememberScrollState()),
|
|
74
|
+
horizontalArrangement = Arrangement.spacedBy(Spacing.S),
|
|
75
|
+
) {
|
|
76
|
+
images.forEachIndexed { index, image ->
|
|
77
|
+
UploaderImageItem(
|
|
78
|
+
image = image,
|
|
79
|
+
width = width,
|
|
80
|
+
height = height,
|
|
81
|
+
index = index,
|
|
82
|
+
onCancel = onCancel,
|
|
83
|
+
onPressImage = { onPressImage(image, index) },
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Composable
|
|
91
|
+
private fun UploaderPickerCell(
|
|
92
|
+
disabled: Boolean,
|
|
93
|
+
width: Dp,
|
|
94
|
+
height: Dp,
|
|
95
|
+
onAdd: () -> Unit,
|
|
96
|
+
) {
|
|
97
|
+
val theme = AppTheme.current
|
|
98
|
+
val mainColor = if (disabled) theme.colors.text.disable else theme.colors.text.hint
|
|
99
|
+
val borderColor = if (disabled) theme.colors.border.disable else theme.colors.border.default
|
|
100
|
+
|
|
101
|
+
Box(
|
|
102
|
+
modifier = Modifier
|
|
103
|
+
.size(width = width, height = height)
|
|
104
|
+
.clip(RoundedCornerShape(Radius.XS))
|
|
105
|
+
.dashedBorder(color = borderColor, radius = Radius.XS)
|
|
106
|
+
.activeOpacityClickable(enabled = !disabled, onClick = onAdd),
|
|
107
|
+
contentAlignment = Alignment.Center,
|
|
108
|
+
) {
|
|
109
|
+
Column(
|
|
110
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
111
|
+
verticalArrangement = Arrangement.spacedBy(Spacing.XXS),
|
|
112
|
+
) {
|
|
113
|
+
Icon(
|
|
114
|
+
source = "16_navigation_plus",
|
|
115
|
+
color = mainColor,
|
|
116
|
+
size = 16.dp,
|
|
117
|
+
)
|
|
118
|
+
Text(
|
|
119
|
+
text = "Thêm hình",
|
|
120
|
+
style = Typography.descriptionXsRegular,
|
|
121
|
+
color = mainColor,
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@Composable
|
|
128
|
+
private fun UploaderImageItem(
|
|
129
|
+
image: UploadImage,
|
|
130
|
+
width: Dp,
|
|
131
|
+
height: Dp,
|
|
132
|
+
index: Int,
|
|
133
|
+
onCancel: ((image: UploadImage, index: Int) -> Unit)?,
|
|
134
|
+
onPressImage: () -> Unit,
|
|
135
|
+
) {
|
|
136
|
+
Box(
|
|
137
|
+
modifier = Modifier
|
|
138
|
+
.size(width = width, height = height)
|
|
139
|
+
.activeOpacityClickable(onClick = onPressImage),
|
|
140
|
+
) {
|
|
141
|
+
Image(
|
|
142
|
+
source = image.uri ?: "",
|
|
143
|
+
modifier = Modifier
|
|
144
|
+
.fillMaxSize()
|
|
145
|
+
.clip(RoundedCornerShape(Radius.XS)),
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
if (onCancel != null && !image.loading) {
|
|
149
|
+
Icon(
|
|
150
|
+
source = "navigation_close_circle_full",
|
|
151
|
+
size = 16.dp,
|
|
152
|
+
color = null,
|
|
153
|
+
modifier = Modifier
|
|
154
|
+
.align(Alignment.TopEnd)
|
|
155
|
+
.padding(top = Spacing.XXS, end = Spacing.XXS)
|
|
156
|
+
.activeOpacityClickable { onCancel(image, index) },
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (image.loading) {
|
|
161
|
+
Box(
|
|
162
|
+
modifier = Modifier
|
|
163
|
+
.fillMaxSize()
|
|
164
|
+
.clip(RoundedCornerShape(Radius.XS))
|
|
165
|
+
.background(Color(0x66FFFFFF)),
|
|
166
|
+
contentAlignment = Alignment.Center,
|
|
167
|
+
) {
|
|
168
|
+
Skeleton()
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private fun Modifier.dashedBorder(
|
|
175
|
+
color: Color,
|
|
176
|
+
radius: Dp,
|
|
177
|
+
strokeWidth: Dp = 1.dp,
|
|
178
|
+
dashWidth: Float = 10f,
|
|
179
|
+
dashGap: Float = 6f,
|
|
180
|
+
): Modifier = this.drawBehind {
|
|
181
|
+
val strokePx = strokeWidth.toPx()
|
|
182
|
+
val pathEffect = PathEffect.dashPathEffect(floatArrayOf(dashWidth, dashGap), 0f)
|
|
183
|
+
val cornerRadiusPx = radius.toPx()
|
|
184
|
+
drawRoundRect(
|
|
185
|
+
color = color,
|
|
186
|
+
style = Stroke(
|
|
187
|
+
width = strokePx,
|
|
188
|
+
pathEffect = pathEffect,
|
|
189
|
+
),
|
|
190
|
+
cornerRadius = CornerRadius(cornerRadiusPx, cornerRadiusPx),
|
|
191
|
+
)
|
|
192
|
+
}
|
|
@@ -19,6 +19,7 @@ data class Background(
|
|
|
19
19
|
data class ColorScheme(
|
|
20
20
|
val primary: Color,
|
|
21
21
|
val secondary: Color,
|
|
22
|
+
val gradient: Color,
|
|
22
23
|
val background: Background,
|
|
23
24
|
val text: TextColors,
|
|
24
25
|
val border: BorderColors,
|
|
@@ -71,6 +72,7 @@ val defaultTheme = Theme(
|
|
|
71
72
|
colors = ColorScheme(
|
|
72
73
|
primary = Colors.pink_03,
|
|
73
74
|
secondary = Colors.pink_07,
|
|
75
|
+
gradient = Color(0xFFFDCADE),
|
|
74
76
|
background = Background(
|
|
75
77
|
default = Color(0xFFF2F2F6),
|
|
76
78
|
surface = Colors.black_01,
|
|
@@ -87,7 +89,7 @@ val defaultTheme = Theme(
|
|
|
87
89
|
),
|
|
88
90
|
border = BorderColors(
|
|
89
91
|
default = Colors.black_04,
|
|
90
|
-
disable = Colors.
|
|
92
|
+
disable = Colors.black_02
|
|
91
93
|
),
|
|
92
94
|
success = ColorSet(
|
|
93
95
|
primary = Colors.green_03,
|
|
@@ -127,10 +129,11 @@ val darkTheme = Theme(
|
|
|
127
129
|
colors = ColorScheme(
|
|
128
130
|
primary = Colors.pink_04,
|
|
129
131
|
secondary = Colors.pink_08,
|
|
132
|
+
gradient = Color(0xFFFDCADE),
|
|
130
133
|
background = Background(
|
|
131
134
|
default = Color(0xFF121212),
|
|
132
135
|
surface = Color(0xFF1E1E1E),
|
|
133
|
-
tonal = Colors.
|
|
136
|
+
tonal = Colors.pink_10,
|
|
134
137
|
pressed = Color(0xFF1A1A1A),
|
|
135
138
|
selected = Colors.pink_11,
|
|
136
139
|
disable = Color(0xFF303030)
|
|
@@ -5,21 +5,12 @@ import androidx.compose.ui.node.ModifierNodeElement
|
|
|
5
5
|
import androidx.compose.ui.node.SemanticsModifierNode
|
|
6
6
|
import androidx.compose.ui.semantics.SemanticsPropertyReceiver
|
|
7
7
|
import androidx.compose.ui.semantics.contentDescription
|
|
8
|
-
import androidx.compose.ui.semantics.semantics
|
|
9
8
|
import androidx.compose.ui.semantics.testTag
|
|
10
9
|
import vn.momo.kits.platform.getPlatformName
|
|
10
|
+
import vn.momo.kits.platform.semantics
|
|
11
11
|
|
|
12
12
|
fun Modifier.setAutomationId(accessibilityId: String, label: String? = null): Modifier {
|
|
13
|
-
return
|
|
14
|
-
semantics {
|
|
15
|
-
contentDescription = accessibilityId
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
semantics {
|
|
19
|
-
testTag = accessibilityId
|
|
20
|
-
contentDescription = label ?: accessibilityId
|
|
21
|
-
}
|
|
22
|
-
}
|
|
13
|
+
return this.semantics(accessibilityId)
|
|
23
14
|
}
|
|
24
15
|
|
|
25
16
|
/**
|
|
@@ -16,6 +16,8 @@ import androidx.compose.ui.graphics.Color
|
|
|
16
16
|
import androidx.compose.ui.graphics.NativePaint
|
|
17
17
|
import androidx.compose.ui.graphics.toArgb
|
|
18
18
|
import androidx.compose.ui.interop.UIKitView
|
|
19
|
+
import androidx.compose.ui.semantics.SemanticsPropertyKey
|
|
20
|
+
import androidx.compose.ui.semantics.semantics
|
|
19
21
|
import androidx.compose.ui.unit.Dp
|
|
20
22
|
import androidx.compose.ui.unit.dp
|
|
21
23
|
import cocoapods.lottie_ios.CompatibleAnimation
|
|
@@ -146,4 +148,14 @@ fun Color.toUIColor(): UIColor {
|
|
|
146
148
|
|
|
147
149
|
actual fun NativePaint.setColor(color: Color){
|
|
148
150
|
this.color = color.toArgb()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private val TestAutomationId = SemanticsPropertyKey<String>(
|
|
154
|
+
name = "TestAutomationId"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
actual fun Modifier.semantics(accessibilityId: String): Modifier {
|
|
158
|
+
return this.semantics(mergeDescendants = false) {
|
|
159
|
+
this[TestAutomationId] = accessibilityId
|
|
160
|
+
}
|
|
149
161
|
}
|
package/gradle.properties
CHANGED
|
@@ -27,11 +27,11 @@ public struct PopupPromotion: View {
|
|
|
27
27
|
.resizable()
|
|
28
28
|
.placeholder {
|
|
29
29
|
Color.gray
|
|
30
|
-
.aspectRatio(0.
|
|
30
|
+
.aspectRatio(0.72, contentMode: .fit)
|
|
31
31
|
.frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2)
|
|
32
32
|
.clipped()
|
|
33
33
|
}
|
|
34
|
-
.aspectRatio(0.
|
|
34
|
+
.aspectRatio(0.72, contentMode: .fit)
|
|
35
35
|
.frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2, alignment: .center)
|
|
36
36
|
.clipped()
|
|
37
37
|
.onTapGesture {
|