@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.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.162.16-debug"
43
+ version = "0.162.17-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -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 width: Dp,
25
- val height: Dp,
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
- IconSpecs(
33
- height = 48.dp,
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
- // Pre-computed shape to avoid repeated creation
50
- private val iconButtonShape = RoundedCornerShape(Radius.XL)
36
+ enum class IconShape {
37
+ CIRCLE,
38
+ SQUARE,
39
+ }
51
40
 
52
- // Cache for icon sizes to avoid repeated calculations
53
- private val iconSizeMap = mapOf(
54
- IconSize.SMALL to 16.dp,
55
- IconSize.LARGE to 24.dp
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, iconButtonShape)
66
- .border(0.dp, Color.Unspecified, iconButtonShape)
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, iconButtonShape)
70
- .border(0.dp, Color.Unspecified, iconButtonShape)
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, iconButtonShape)
74
- .border(1.dp, theme.colors.border.default, iconButtonShape)
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, iconButtonShape)
78
- .border(1.dp, color ?: theme.colors.primary, iconButtonShape)
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, iconButtonShape)
82
- .border(0.dp, Color.Unspecified, iconButtonShape)
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, iconButtonShape)
86
- .border(0.dp, Color.Unspecified, iconButtonShape)
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
- // Memoize icon size calculation
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
- // Memoize radius for clipping
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(size.value.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(RoundedCornerShape(radius))
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 = iconSize,
122
+ size = specs.icon,
138
123
  )
139
124
  }
140
- }
125
+ }
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.162.16
21
+ version=0.162.17
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.16-debug",
3
+ "version": "0.162.17-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},