@momo-kits/native-kits 0.162.2-beta.21-debug → 0.162.2-beta.22-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.2-beta.21-debug"
43
+ version = "0.162.2-beta.22-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -139,7 +139,7 @@ private fun ToolkitHeaderRight(
139
139
  }
140
140
 
141
141
  fun onPressClose() {
142
- api?.request("dismissAll", "", { _ -> })
142
+ api?.request("dismissAll", "")
143
143
  }
144
144
 
145
145
  fun onPressMore() {
@@ -20,6 +20,8 @@ import androidx.compose.ui.Modifier
20
20
  import androidx.compose.ui.draw.alpha
21
21
  import androidx.compose.ui.draw.clip
22
22
  import androidx.compose.ui.graphics.Color
23
+ import androidx.compose.ui.semantics.contentDescription
24
+ import androidx.compose.ui.semantics.semantics
23
25
  import androidx.compose.ui.text.TextStyle
24
26
  import androidx.compose.ui.text.style.TextOverflow
25
27
  import androidx.compose.ui.unit.Dp
@@ -143,9 +145,10 @@ fun RenderIcon(
143
145
  icon: String = "",
144
146
  forceLoading: Boolean = false,
145
147
  textColor: Color? = null,
148
+ iconOnly: Boolean = false,
146
149
  ) {
147
150
  val iconSize = remember(size) { getIconSize(size) }
148
- val margin = remember(size) { getIconSpace(size) }
151
+ val margin = remember(size, iconOnly) { if (iconOnly) 0.dp else getIconSpace(size) }
149
152
  val color = if (useTintColor) textColor else Color.Unspecified
150
153
 
151
154
  val modifier = Modifier.padding(
@@ -246,6 +249,12 @@ fun getButtonBackgroundColor(
246
249
  private fun Color.withLoading(loading: Boolean): Color =
247
250
  this.copy(alpha = if (loading) 0.75f else 1f)
248
251
 
252
+ /**
253
+ * When [iconOnly] is true the label is hidden and the button collapses to a compact,
254
+ * icon-sized box (it ignores [isFull] and always wraps its content). [title] stays
255
+ * required and is exposed as the button's accessibility label. Supply the glyph via
256
+ * [iconLeft] (preferred) or [iconRight]; while [loading] the spinner replaces the icon.
257
+ */
249
258
  @Composable
250
259
  fun Button(
251
260
  onClick: () -> Unit,
@@ -257,6 +266,7 @@ fun Button(
257
266
  loading: Boolean = false,
258
267
  useTintColor: Boolean = true,
259
268
  isFull: Boolean = true,
269
+ iconOnly: Boolean = false,
260
270
  modifier: Modifier = Modifier,
261
271
  ) {
262
272
  val radius = remember(size) { size.value.radius }
@@ -264,6 +274,7 @@ fun Button(
264
274
  val loadingOnLeft = remember(iconLeft, iconRight) {
265
275
  shouldLoadingOnLeft(iconLeft, iconRight)
266
276
  }
277
+ val iconOnlyIcon = remember(iconLeft, iconRight) { iconLeft.ifEmpty { iconRight } }
267
278
 
268
279
  val sizeSpecs = remember(size) { size.value }
269
280
 
@@ -302,7 +313,7 @@ fun Button(
302
313
  val bgColor = getButtonBackgroundColor(loading, type)
303
314
  val textColor = getTextColor(loading, type)
304
315
 
305
- val rootModifier = if (isFull) {
316
+ val rootModifier = if (isFull && !iconOnly) {
306
317
  Modifier
307
318
  .fillMaxWidth()
308
319
  .wrapContentHeight()
@@ -311,7 +322,11 @@ fun Button(
311
322
  }
312
323
 
313
324
  Box(
314
- modifier = rootModifier.then(clickableModifier),
325
+ modifier = rootModifier
326
+ .then(clickableModifier)
327
+ .conditional(iconOnly) {
328
+ semantics(mergeDescendants = true) { contentDescription = title }
329
+ },
315
330
  contentAlignment = Alignment.Center
316
331
  ) {
317
332
  // Visual background (shrinks on press)
@@ -334,23 +349,35 @@ fun Button(
334
349
  horizontalArrangement = Arrangement.Center,
335
350
  verticalAlignment = Alignment.CenterVertically,
336
351
  ) {
337
- RenderIcon(
338
- size = size,
339
- isIconLeft = true,
340
- useTintColor = useTintColor,
341
- icon = iconLeft,
342
- forceLoading = loading && loadingOnLeft,
343
- textColor = textColor
344
- )
345
- RenderTitle(size, title, textColor = textColor)
346
- RenderIcon(
347
- size = size,
348
- isIconLeft = false,
349
- useTintColor = useTintColor,
350
- icon = iconRight,
351
- forceLoading = loading && !loadingOnLeft,
352
- textColor = textColor
353
- )
352
+ if (iconOnly) {
353
+ RenderIcon(
354
+ size = size,
355
+ isIconLeft = true,
356
+ useTintColor = useTintColor,
357
+ icon = iconOnlyIcon,
358
+ forceLoading = loading,
359
+ textColor = textColor,
360
+ iconOnly = true
361
+ )
362
+ } else {
363
+ RenderIcon(
364
+ size = size,
365
+ isIconLeft = true,
366
+ useTintColor = useTintColor,
367
+ icon = iconLeft,
368
+ forceLoading = loading && loadingOnLeft,
369
+ textColor = textColor
370
+ )
371
+ RenderTitle(size, title, textColor = textColor)
372
+ RenderIcon(
373
+ size = size,
374
+ isIconLeft = false,
375
+ useTintColor = useTintColor,
376
+ icon = iconRight,
377
+ forceLoading = loading && !loadingOnLeft,
378
+ textColor = textColor
379
+ )
380
+ }
354
381
  }
355
382
  }
356
383
  }
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.2-beta.20
21
+ version=0.162.2-beta.22
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
@@ -125,7 +125,12 @@ public struct Button: View {
125
125
  var iconRight: AnyView?
126
126
  var isFull: Bool
127
127
  var loading: Bool
128
+ var iconOnly: Bool
128
129
 
130
+ /// When `iconOnly` is true the label is hidden and the button collapses to a compact,
131
+ /// icon-sized box (it ignores `isFull`). `title` stays required and is exposed as the
132
+ /// accessibility label. Supply the glyph via `iconLeft` (preferred) or `iconRight`;
133
+ /// while `loading` the spinner replaces the icon.
129
134
  public init(
130
135
  title: String = "",
131
136
  action: @escaping () -> Void,
@@ -134,7 +139,8 @@ public struct Button: View {
134
139
  iconLeft: AnyView? = nil,
135
140
  iconRight: AnyView? = nil,
136
141
  isFull: Bool = true,
137
- loading: Bool = false
142
+ loading: Bool = false,
143
+ iconOnly: Bool = false
138
144
  ) {
139
145
  self.title = title
140
146
  self.action = action
@@ -144,6 +150,7 @@ public struct Button: View {
144
150
  self.iconRight = iconRight
145
151
  self.isFull = isFull
146
152
  self.loading = loading
153
+ self.iconOnly = iconOnly
147
154
  }
148
155
 
149
156
  private func shouldLoadingOnLeft(_ left: AnyView?, _ right: AnyView?) -> Bool {
@@ -166,35 +173,46 @@ public struct Button: View {
166
173
  let border = type.borderColor
167
174
  let borderWidth = type.borderWidth
168
175
 
169
- SwiftUI.Button(action: {
176
+ let button = SwiftUI.Button(action: {
170
177
  if !loading, type != .disabled {
171
178
  action()
172
179
  }
173
180
  }) {
174
181
  HStack(spacing: size.iconSpacing) {
175
- if loading && loadingOnLeft {
176
- LottieView(name: "lottie_circle_loader", loopMode: .loop)
177
- .frame(width: size.iconSize, height: size.iconSize)
178
- .colorMultiply(fg)
179
-
180
- } else if let iconLeft = iconLeft {
181
- iconLeft.frame(width: size.iconSize, height: size.iconSize)
182
- }
183
-
184
- MomoText(title, typography: size.typographyStyle, color: fg)
185
- .lineLimit(1)
186
- .truncationMode(.tail)
187
-
188
- if loading && !loadingOnLeft {
189
- LottieView(name: "lottie_circle_loader", loopMode: .loop)
190
- .frame(width: size.iconSize, height: size.iconSize)
191
- .colorMultiply(fg)
192
-
193
- } else if let iconRight = iconRight {
194
- iconRight.frame(width: size.iconSize, height: size.iconSize)
182
+ if iconOnly {
183
+ if loading {
184
+ LottieView(name: "lottie_circle_loader", loopMode: .loop)
185
+ .frame(width: size.iconSize, height: size.iconSize)
186
+ .colorMultiply(fg)
187
+
188
+ } else if let icon = iconLeft ?? iconRight {
189
+ icon.frame(width: size.iconSize, height: size.iconSize)
190
+ }
191
+ } else {
192
+ if loading && loadingOnLeft {
193
+ LottieView(name: "lottie_circle_loader", loopMode: .loop)
194
+ .frame(width: size.iconSize, height: size.iconSize)
195
+ .colorMultiply(fg)
196
+
197
+ } else if let iconLeft = iconLeft {
198
+ iconLeft.frame(width: size.iconSize, height: size.iconSize)
199
+ }
200
+
201
+ MomoText(title, typography: size.typographyStyle, color: fg)
202
+ .lineLimit(1)
203
+ .truncationMode(.tail)
204
+
205
+ if loading && !loadingOnLeft {
206
+ LottieView(name: "lottie_circle_loader", loopMode: .loop)
207
+ .frame(width: size.iconSize, height: size.iconSize)
208
+ .colorMultiply(fg)
209
+
210
+ } else if let iconRight = iconRight {
211
+ iconRight.frame(width: size.iconSize, height: size.iconSize)
212
+ }
195
213
  }
196
214
  }
197
- .frame(maxWidth: isFull ? .infinity : nil)
215
+ .frame(maxWidth: isFull && !iconOnly ? .infinity : nil)
198
216
  .padding(.horizontal, size.padding)
199
217
  .frame(height: size.height)
200
218
  .background(bg)
@@ -206,5 +224,11 @@ public struct Button: View {
206
224
  .opacity(loading ? 0.75 : 1)
207
225
  }
208
226
  .disabled(type == .disabled || loading)
227
+
228
+ if iconOnly {
229
+ button.accessibilityLabel(Text(title))
230
+ } else {
231
+ button
232
+ }
209
233
  }
210
234
  }
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Wed Aug 21 14:20:12 ICT 2024
8
+ sdk.dir=/Users/huynhdung/Library/Android/sdk
package/package.json CHANGED
@@ -1,8 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.2-beta.21-debug",
3
+ "version": "0.162.2-beta.22-debug",
4
4
  "private": false,
5
- "dependencies": {},
6
- "devDependencies": {},
7
5
  "license": "MoMo"
8
6
  }