@momo-kits/native-kits 0.111.1-rc.2 → 0.112.1-beta.1

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,6 +40,7 @@ import vn.momo.kits.const.Spacing
40
40
  import vn.momo.kits.modifier.conditional
41
41
  import vn.momo.kits.modifier.shadow
42
42
  import vn.momo.kits.platform.getStatusBarHeight
43
+ import vn.momo.kits.components.HeaderRight
43
44
 
44
45
  enum class HeaderType {
45
46
  DEFAULT,
@@ -62,7 +63,7 @@ fun Screen(
62
63
  onContentLayout: ((LayoutCoordinates) -> Unit)? = null,
63
64
  useAvoidKeyboard: Boolean = true,
64
65
  footer: @Composable (() -> Unit)? = null,
65
- headerRight: @Composable (() -> Unit)? = null,
66
+ headerRight: @Composable (() -> Unit)? = { HeaderRight() },
66
67
  fabProps: FabProps? = null,
67
68
  animatedHeader: AnimatedHeader? = null,
68
69
  layoutOffset: Dp = 56.dp,
@@ -17,9 +17,9 @@ enum class DotSize(val size: Int) {
17
17
  }
18
18
 
19
19
  @Composable
20
- fun BadgeDot(size: DotSize = DotSize.Large) {
20
+ fun BadgeDot(size: DotSize = DotSize.Large, modifier: Modifier = Modifier) {
21
21
  Box(
22
- modifier = Modifier
22
+ modifier = modifier
23
23
  .size(size.size.dp)
24
24
  .border(width = 1.dp, color = Colors.black_01, shape = RoundedCornerShape(Radius.S))
25
25
  .background(color = Colors.red_03, shape = RoundedCornerShape(Radius.S))
@@ -0,0 +1,209 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.border
5
+ import androidx.compose.foundation.clickable
6
+ import androidx.compose.foundation.layout.Arrangement
7
+ import androidx.compose.foundation.layout.Box
8
+ import androidx.compose.foundation.layout.Row
9
+ import androidx.compose.foundation.layout.height
10
+ import androidx.compose.foundation.layout.offset
11
+ import androidx.compose.foundation.layout.padding
12
+ import androidx.compose.foundation.layout.size
13
+ import androidx.compose.foundation.layout.width
14
+ import androidx.compose.foundation.shape.CircleShape
15
+ import androidx.compose.foundation.shape.RoundedCornerShape
16
+ import androidx.compose.runtime.Composable
17
+ import androidx.compose.runtime.getValue
18
+ import androidx.compose.runtime.mutableStateOf
19
+ import androidx.compose.runtime.remember
20
+ import androidx.compose.runtime.setValue
21
+ import androidx.compose.ui.Alignment
22
+ import androidx.compose.ui.Modifier
23
+ import androidx.compose.ui.draw.clip
24
+ import androidx.compose.ui.graphics.Color
25
+ import androidx.compose.ui.unit.dp
26
+ import vn.momo.kits.application.ComposeApi
27
+ import vn.momo.kits.application.PlatformApi
28
+ import vn.momo.kits.const.Colors
29
+
30
+ data class HeaderRightData(
31
+ val useOnBoarding: Boolean = false,
32
+ val buttonOnBoarding: String? = null,
33
+ val onPress: (() -> Unit)? = null,
34
+ val tintColor: Color = Colors.black_20,
35
+ val preventClose: Any? = null,
36
+ val useShortcut: Boolean = false,
37
+ val useMore: Boolean = false,
38
+ val tools: List<ToolGroup> = emptyList(),
39
+ val appId: String = ""
40
+ )
41
+
42
+ data class Tool(
43
+ val key: String,
44
+ val icon: String,
45
+ val onPress: () -> Unit,
46
+ val showBadge: Boolean = false
47
+ )
48
+
49
+ data class ToolGroup(
50
+ val items: List<Tool>
51
+ )
52
+
53
+ data class NavigationButtonConfig(
54
+ val icon: String,
55
+ val onPress: () -> Unit
56
+ )
57
+
58
+ object Spacing {
59
+ val M = 16.dp
60
+ val S = 8.dp
61
+ val XXS = 2.dp
62
+ }
63
+
64
+ @Composable
65
+ fun HeaderRight(
66
+ headerRight: HeaderRightData? = null,
67
+ ) {
68
+ Row(
69
+ verticalAlignment = Alignment.CenterVertically,
70
+ ) {
71
+ ToolkitHeaderRight(headerRight = headerRight)
72
+ }
73
+ }
74
+
75
+ @Composable
76
+ fun ToolkitHeaderRight(headerRight: HeaderRightData? = null) {
77
+ var isFavorite by remember { mutableStateOf(false) }
78
+ val isLoading by remember { mutableStateOf(false) }
79
+ val api = PlatformApi.current as? ComposeApi
80
+
81
+ fun onPressShortcut() {
82
+ isFavorite = !isFavorite
83
+ }
84
+ fun onPressHelpCenter(){
85
+ api?.request("showHelpCenter", "")
86
+ }
87
+ fun onPressClose(){
88
+ api?.request("dismiss", "")
89
+ }
90
+ fun onPressMore() {
91
+ api?.request("showTools", "")
92
+ }
93
+
94
+ fun getNavigationButtonConfig(
95
+ tools: List<ToolGroup>? = emptyList(),
96
+ useMore: Boolean? = false,
97
+ isFavorite: Boolean = false,
98
+ onPressShortcut: () -> Unit,
99
+ onPressMore: () -> Unit
100
+ ): NavigationButtonConfig {
101
+ val totalTools = tools?.sumOf { it.items.size } ?: 0
102
+ var icon = if (isFavorite) "pin_star_checked" else "pin_star"
103
+ var onClickHandler = onPressShortcut
104
+ if (totalTools > 1 || useMore == true) {
105
+ icon = "navigation_more_icon"
106
+ onClickHandler = onPressMore
107
+ } else if (totalTools == 1 && !tools.isNullOrEmpty()) {
108
+ val singleTool = tools.first().items.firstOrNull()
109
+ if (singleTool != null) {
110
+ icon = singleTool.icon
111
+ onClickHandler = {
112
+ singleTool.onPress()
113
+ }
114
+ }
115
+ }
116
+ return NavigationButtonConfig(icon, onClickHandler)
117
+ }
118
+
119
+ val navButtonConfig = getNavigationButtonConfig(
120
+ headerRight?.tools,
121
+ headerRight?.useMore,
122
+ isFavorite,
123
+ ::onPressShortcut,
124
+ ::onPressMore
125
+ )
126
+
127
+ val showBadge = headerRight?.tools?.any { group ->
128
+ group.items.any { it.showBadge }
129
+ }
130
+
131
+ Row(
132
+ verticalAlignment = Alignment.CenterVertically
133
+ ) {
134
+ if (headerRight?.useShortcut == true) {
135
+ NavigationButton(
136
+ disabled = isLoading,
137
+ icon = navButtonConfig.icon,
138
+ showBadge = showBadge,
139
+ onClick = navButtonConfig.onPress
140
+ )
141
+ }
142
+ Row(
143
+ verticalAlignment = Alignment.CenterVertically,
144
+ horizontalArrangement = Arrangement.Center,
145
+ modifier = Modifier
146
+ .padding(start = Spacing.S)
147
+ .border(0.2.dp, Color(0x33000000), shape = RoundedCornerShape(14.dp))
148
+ .width(65.dp)
149
+ .height(28.dp)
150
+ .clip(shape = RoundedCornerShape(14.dp))
151
+ .background(Color(0x99FFFFFF))
152
+ ) {
153
+ Icon(source = "help_center", size = 20.dp, modifier = Modifier.padding(4.dp).clickable {
154
+ onPressHelpCenter()
155
+ })
156
+ Box(
157
+ modifier = Modifier
158
+ .width(0.5.dp)
159
+ .height(12.dp)
160
+ .background(Colors.black_20)
161
+ )
162
+ Icon(
163
+ source = "16_navigation_close_circle",
164
+ size = 20.dp,
165
+ modifier = Modifier.padding(4.dp).clickable { onPressClose() }
166
+ )
167
+ }
168
+ }
169
+ }
170
+
171
+ @Composable
172
+ fun NavigationButton(
173
+ disabled: Boolean,
174
+ icon: String,
175
+ showBadge: Boolean? = false,
176
+ onClick: () -> Unit
177
+ ) {
178
+ Box(
179
+ modifier = Modifier
180
+ .size(28.dp)
181
+ .clickable(enabled = !disabled, onClick = onClick)
182
+ ) {
183
+ Box(
184
+ modifier = Modifier
185
+ .matchParentSize()
186
+ .clip(CircleShape)
187
+ .background(Color(0x99FFFFFF))
188
+ .border(0.2.dp, Color(0x33000000), CircleShape)
189
+ )
190
+ Box(
191
+ modifier = Modifier.matchParentSize(),
192
+ contentAlignment = Alignment.Center
193
+ ) {
194
+ Icon(
195
+ source = icon,
196
+ size = 16.dp
197
+ )
198
+ }
199
+
200
+ if (showBadge != true) {
201
+ BadgeDot(
202
+ size = DotSize.Small,
203
+ modifier = Modifier
204
+ .align(Alignment.TopEnd)
205
+ .offset(x = -Spacing.XXS, y = -Spacing.XXS)
206
+ )
207
+ }
208
+ }
209
+ }
@@ -22,10 +22,10 @@ fun Icon(
22
22
  color: Color? = AppTheme.current.colors.text.default,
23
23
  modifier: Modifier = Modifier,
24
24
  ) {
25
- val icon = if (source.contains("https")) {
26
- source
27
- } else {
28
- Icons[source] ?: ""
25
+ val icon = when {
26
+ source.startsWith("data:") -> source
27
+ source.contains("https") -> source
28
+ else -> Icons[source] ?: ""
29
29
  }
30
30
  Box(modifier = modifier.size(size).semantics {contentDescription = "img|$icon"}) {
31
31
  AsyncImage(
@@ -1318,5 +1318,10 @@ val Icons = mapOf(
1318
1318
  "ic_checked" to "https://img.mservice.com.vn/app/img/kits/checked_ic.png",
1319
1319
  "ic_minus" to "https://img.mservice.com.vn/app/img/kits/minus.png",
1320
1320
  "ic_navigation" to "https://static.momocdn.net/app/img/kits/ic_navigation.png",
1321
- "ic_money_bag" to "https://static.momocdn.net/app/img/kits/ic_money_bag.png"
1321
+ "ic_money_bag" to "https://static.momocdn.net/app/img/kits/ic_money_bag.png",
1322
+ "ic_support" to "https://static.momocdn.net/app/img/kits/ic_support.png",
1323
+ "navigation_more_icon" to "https://static.momocdn.net/app/img/kits/navigation_more_icon.png",
1324
+ "help_center" to "https://static.momocdn.net/app/img/kits/help-center.png",
1325
+ "pin_star" to "https://static.momocdn.net/app/img/kits/pin_star.png",
1326
+ "pin_star_checked" to "https://static.momocdn.net/app/img/kits/pin_star_checked.png"
1322
1327
  )
@@ -41,7 +41,7 @@ public struct Checkbox: View{
41
41
  .resizable()
42
42
  .foregroundColor(backgroundColor)
43
43
  .background(Colors.black01)
44
- .frame(width: 24, height: 24)
44
+ .frame(width: 20, height: 20)
45
45
  }
46
46
  }
47
47
 
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
- #Wed Aug 21 14:20:12 ICT 2024
8
- sdk.dir=/Users/huynhdung/Library/Android/sdk
7
+ #Tue Apr 23 16:40:15 ICT 2024
8
+ sdk.dir=/Users/hung.dao1/Library/Android/sdk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.111.1-rc.2",
3
+ "version": "0.112.1-beta.1",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},