@momo-kits/native-kits 0.162.16-debug → 0.162.17-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
CHANGED
|
@@ -5,6 +5,7 @@ import androidx.compose.foundation.border
|
|
|
5
5
|
import androidx.compose.foundation.clickable
|
|
6
6
|
import androidx.compose.foundation.layout.Box
|
|
7
7
|
import androidx.compose.foundation.layout.size
|
|
8
|
+
import androidx.compose.foundation.shape.CircleShape
|
|
8
9
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
9
10
|
import androidx.compose.runtime.Composable
|
|
10
11
|
import androidx.compose.runtime.remember
|
|
@@ -12,6 +13,7 @@ import androidx.compose.ui.Alignment
|
|
|
12
13
|
import androidx.compose.ui.Modifier
|
|
13
14
|
import androidx.compose.ui.draw.clip
|
|
14
15
|
import androidx.compose.ui.graphics.Color
|
|
16
|
+
import androidx.compose.ui.graphics.Shape
|
|
15
17
|
import androidx.compose.ui.unit.Dp
|
|
16
18
|
import androidx.compose.ui.unit.dp
|
|
17
19
|
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
@@ -21,69 +23,58 @@ import vn.momo.kits.const.Radius
|
|
|
21
23
|
import vn.momo.kits.modifier.conditional
|
|
22
24
|
|
|
23
25
|
data class IconSpecs(
|
|
24
|
-
val
|
|
25
|
-
val
|
|
26
|
-
val radius: Dp,
|
|
27
|
-
val size: Dp
|
|
26
|
+
val box: Dp,
|
|
27
|
+
val icon: Dp,
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
enum class IconSize(val value: IconSpecs) {
|
|
31
|
-
LARGE(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
radius = Radius.XL,
|
|
35
|
-
width = 48.dp,
|
|
36
|
-
size = 48.dp
|
|
37
|
-
)
|
|
38
|
-
),
|
|
39
|
-
SMALL(
|
|
40
|
-
IconSpecs(
|
|
41
|
-
height = 40.dp,
|
|
42
|
-
radius = Radius.XL,
|
|
43
|
-
width = 40.dp,
|
|
44
|
-
size = 40.dp
|
|
45
|
-
)
|
|
46
|
-
)
|
|
31
|
+
LARGE(IconSpecs(box = 48.dp, icon = 24.dp)),
|
|
32
|
+
MEDIUM(IconSpecs(box = 36.dp, icon = 16.dp)),
|
|
33
|
+
SMALL(IconSpecs(box = 28.dp, icon = 16.dp)),
|
|
47
34
|
}
|
|
48
35
|
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
enum class IconShape {
|
|
37
|
+
CIRCLE,
|
|
38
|
+
SQUARE,
|
|
39
|
+
}
|
|
51
40
|
|
|
52
|
-
//
|
|
53
|
-
private val
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
// Square keeps an 8dp rounded corner; circle is fully rounded regardless of size.
|
|
42
|
+
private val squareShape = RoundedCornerShape(Radius.S)
|
|
43
|
+
|
|
44
|
+
private fun IconShape.toShape(): Shape = when (this) {
|
|
45
|
+
IconShape.CIRCLE -> CircleShape
|
|
46
|
+
IconShape.SQUARE -> squareShape
|
|
47
|
+
}
|
|
57
48
|
|
|
58
49
|
@Composable
|
|
59
|
-
internal fun getIconStyle(type: ButtonType, color: Color? = null): Modifier {
|
|
50
|
+
internal fun getIconStyle(type: ButtonType, shape: Shape, color: Color? = null): Modifier {
|
|
60
51
|
val theme = AppTheme.current
|
|
61
52
|
|
|
62
|
-
return remember(type, color, theme) {
|
|
53
|
+
return remember(type, shape, color, theme) {
|
|
63
54
|
when (type) {
|
|
64
55
|
ButtonType.DISABLED -> Modifier
|
|
65
|
-
.background(theme.colors.background.disable,
|
|
66
|
-
.border(0.dp, Color.Unspecified,
|
|
56
|
+
.background(theme.colors.background.disable, shape)
|
|
57
|
+
.border(0.dp, Color.Unspecified, shape)
|
|
67
58
|
|
|
68
59
|
ButtonType.PRIMARY -> Modifier
|
|
69
|
-
.background(theme.colors.primary,
|
|
70
|
-
.border(0.dp, Color.Unspecified,
|
|
60
|
+
.background(theme.colors.primary, shape)
|
|
61
|
+
.border(0.dp, Color.Unspecified, shape)
|
|
71
62
|
|
|
72
63
|
ButtonType.SECONDARY -> Modifier
|
|
73
|
-
.background(theme.colors.background.surface,
|
|
74
|
-
.border(1.dp, theme.colors.border.default,
|
|
64
|
+
.background(theme.colors.background.surface, shape)
|
|
65
|
+
.border(1.dp, theme.colors.border.default, shape)
|
|
75
66
|
|
|
76
67
|
ButtonType.OUTLINE -> Modifier
|
|
77
|
-
.background(theme.colors.background.surface,
|
|
78
|
-
.border(1.dp, color ?: theme.colors.primary,
|
|
68
|
+
.background(theme.colors.background.surface, shape)
|
|
69
|
+
.border(1.dp, color ?: theme.colors.primary, shape)
|
|
79
70
|
|
|
80
71
|
ButtonType.TONAL -> Modifier
|
|
81
|
-
.background(theme.colors.background.tonal,
|
|
82
|
-
.border(0.dp, Color.Unspecified,
|
|
72
|
+
.background(theme.colors.background.tonal, shape)
|
|
73
|
+
.border(0.dp, Color.Unspecified, shape)
|
|
83
74
|
|
|
84
75
|
ButtonType.DANGER -> Modifier
|
|
85
|
-
.background(theme.colors.error.primary,
|
|
86
|
-
.border(0.dp, Color.Unspecified,
|
|
76
|
+
.background(theme.colors.error.primary, shape)
|
|
77
|
+
.border(0.dp, Color.Unspecified, shape)
|
|
87
78
|
|
|
88
79
|
ButtonType.TEXT -> Modifier
|
|
89
80
|
}
|
|
@@ -103,38 +94,32 @@ fun IconButton(
|
|
|
103
94
|
onClick: () -> Unit,
|
|
104
95
|
type: ButtonType = ButtonType.PRIMARY,
|
|
105
96
|
size: IconSize = IconSize.SMALL,
|
|
97
|
+
shape: IconShape = IconShape.CIRCLE,
|
|
106
98
|
icon: String = "",
|
|
107
99
|
) {
|
|
108
|
-
|
|
109
|
-
val iconSize = remember(size) {
|
|
110
|
-
iconSizeMap[size] ?: 16.dp
|
|
111
|
-
}
|
|
100
|
+
val specs = size.value
|
|
112
101
|
|
|
113
|
-
// Memoize enabled state
|
|
114
102
|
val isEnabled = remember(type) {
|
|
115
103
|
type != ButtonType.DISABLED
|
|
116
104
|
}
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
val radius = remember(size) {
|
|
120
|
-
size.value.radius
|
|
121
|
-
}
|
|
106
|
+
val boxShape = remember(shape) { shape.toShape() }
|
|
122
107
|
|
|
123
108
|
Box(
|
|
124
109
|
modifier = Modifier
|
|
125
|
-
.size(
|
|
126
|
-
.then(getIconStyle(type))
|
|
110
|
+
.size(specs.box)
|
|
111
|
+
.then(getIconStyle(type, boxShape))
|
|
127
112
|
.conditional(IsShowBaseLineDebug) {
|
|
128
113
|
border(1.dp, Colors.blue_03)
|
|
129
114
|
}
|
|
130
|
-
.clip(
|
|
115
|
+
.clip(boxShape)
|
|
131
116
|
.clickable(enabled = isEnabled, onClick = onClick),
|
|
132
117
|
contentAlignment = Alignment.Center
|
|
133
118
|
) {
|
|
134
119
|
Icon(
|
|
135
120
|
source = icon,
|
|
136
121
|
color = getIconColor(type),
|
|
137
|
-
size =
|
|
122
|
+
size = specs.icon,
|
|
138
123
|
)
|
|
139
124
|
}
|
|
140
|
-
}
|
|
125
|
+
}
|
package/gradle.properties
CHANGED