@momo-kits/native-kits 0.160.7-debug → 0.160.8-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.160.7-debug"
43
+ version = "0.160.8-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -63,6 +63,7 @@ import androidx.compose.ui.platform.LocalDensity
63
63
  import androidx.compose.ui.platform.LocalFocusManager
64
64
  import androidx.compose.ui.platform.LocalSoftwareKeyboardController
65
65
  import androidx.compose.ui.text.style.TextOverflow
66
+ import androidx.compose.ui.text.TextStyle
66
67
  import androidx.compose.ui.unit.Constraints
67
68
  import androidx.compose.ui.unit.Dp
68
69
  import androidx.compose.ui.unit.IntOffset
@@ -78,6 +79,7 @@ import vn.momo.kits.const.Colors
78
79
  import vn.momo.kits.const.Radius
79
80
  import vn.momo.kits.const.Spacing
80
81
  import vn.momo.kits.const.Typography
82
+ import vn.momo.kits.modifier.conditional
81
83
  import vn.momo.kits.modifier.kitsAutomationId
82
84
  import vn.momo.kits.modifier.noFeedbackClickable
83
85
  import vn.momo.kits.modifier.setAutomationId
@@ -101,6 +103,9 @@ fun LiteScreen(
101
103
  useAnimationSearch: Boolean = true,
102
104
  titlePosition: TitlePosition = TitlePosition.LEFT,
103
105
  headerRightData: HeaderRightData? = null,
106
+ headerTintColor: Color? = null,
107
+ headerBackgroundColor: Color? = null,
108
+ headerSpaceBetween: Dp? = null,
104
109
  /* End of header props */
105
110
 
106
111
  screenContent: @Composable () -> Unit,
@@ -135,6 +140,9 @@ fun LiteScreen(
135
140
  titlePosition = titlePosition,
136
141
  useAnimationSearch = useAnimationSearch,
137
142
  headerRightData = headerRightData,
143
+ tintColor = headerTintColor,
144
+ headerBackgroundColor = headerBackgroundColor,
145
+ headerSpaceBetween = headerSpaceBetween,
138
146
  )
139
147
 
140
148
  Box(
@@ -166,6 +174,8 @@ private fun LiteScreenHeader(
166
174
  titlePosition: TitlePosition = TitlePosition.LEFT,
167
175
  useAnimationSearch: Boolean = true,
168
176
  onGoBack: (() -> Unit)? = null,
177
+ headerBackgroundColor: Color? = null,
178
+ headerSpaceBetween: Dp? = null,
169
179
  inputSearchProps: LiteInputSearchProps? = null,
170
180
  headerRight: @Composable (() -> Unit)? = null,
171
181
  ) {
@@ -242,6 +252,7 @@ private fun LiteScreenHeader(
242
252
  statusBarHeight,
243
253
  titlePosition,
244
254
  scrollPercentage,
255
+ headerSpaceBetween,
245
256
  ) {
246
257
  LiteScreenHeaderPolicy(
247
258
  useAnimationSearch = useAnimationSearch,
@@ -249,6 +260,7 @@ private fun LiteScreenHeader(
249
260
  statusBarHeight = statusBarHeight,
250
261
  titlePosition = titlePosition,
251
262
  scrollPercentage = scrollPercentage,
263
+ headerSpaceBetween = headerSpaceBetween,
252
264
  )
253
265
  }
254
266
 
@@ -260,17 +272,21 @@ private fun LiteScreenHeader(
260
272
  HeaderId.EXTENDED_HEADER_HEIGHT.toPx(),
261
273
  size.height,
262
274
  )
263
- drawRect(color = Colors.black_01)
264
- drawRect(
265
- brush = Brush.linearGradient(
266
- colors = listGradientColors,
267
- start = Offset.Zero,
268
- end = Offset(
269
- x = 0f,
270
- y = headerHeight * (1 - scrollPercentage.value),
271
- ),
275
+ headerBackgroundColor?.let {
276
+ drawRect(color = it)
277
+ } ?: run {
278
+ drawRect(color = Colors.black_01)
279
+ drawRect(
280
+ brush = Brush.linearGradient(
281
+ colors = listGradientColors,
282
+ start = Offset.Zero,
283
+ end = Offset(
284
+ x = 0f,
285
+ y = headerHeight * (1 - scrollPercentage.value),
286
+ ),
287
+ )
272
288
  )
273
- )
289
+ }
274
290
  },
275
291
  content = {
276
292
  if (onGoBack != null) {
@@ -279,17 +295,19 @@ private fun LiteScreenHeader(
279
295
  .size(28.dp)
280
296
  .layoutId(HeaderId.BACK_ID)
281
297
  .clip(CircleShape)
282
- .border(
283
- width = 0.2.dp,
284
- color = headerColor.borderColor,
285
- shape = CircleShape,
286
- )
287
- .background(color = headerColor.backgroundButton)
298
+ .conditional(inputSearchProps?.customBackIcon == null) {
299
+ this.border(
300
+ width = 0.2.dp,
301
+ color = headerColor.borderColor,
302
+ shape = CircleShape,
303
+ )
304
+ .background(color = headerColor.backgroundButton)
305
+ }
288
306
  .noFeedbackClickable(onClick = onGoBack)
289
307
  .setAutomationId("btn_navigation_back")
290
308
  .padding(Spacing.XS),
291
309
  ) {
292
- Icon(
310
+ inputSearchProps?.customBackIcon?.invoke() ?: Icon(
293
311
  source = "arrow-back",
294
312
  color = headerColor.tintIconColor,
295
313
  size = 20.dp,
@@ -338,6 +356,7 @@ private class LiteScreenHeaderPolicy(
338
356
  private val statusBarHeight: Dp,
339
357
  private val scrollPercentage: State<Float>,
340
358
  private val titlePosition: TitlePosition,
359
+ private val headerSpaceBetween: Dp? = null,
341
360
  ) : MeasurePolicy {
342
361
 
343
362
  override fun MeasureScope.measure(
@@ -345,6 +364,7 @@ private class LiteScreenHeaderPolicy(
345
364
  constraints: Constraints
346
365
  ): MeasureResult {
347
366
  val spacing12 = Spacing.M.roundToPx()
367
+ val spaceBetween = headerSpaceBetween?.roundToPx() ?: spacing12
348
368
  val statusBarPx = statusBarHeight.roundToPx()
349
369
  val scrollPercent = scrollPercentage.value
350
370
 
@@ -364,7 +384,7 @@ private class LiteScreenHeaderPolicy(
364
384
  )
365
385
  val inputSearchConstraints = if (isHeaderExtend) {
366
386
  val minWidth =
367
- if (useAnimationSearch) realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spacing12 * 2
387
+ if (useAnimationSearch) realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
368
388
  else realConstraints.maxWidth
369
389
  realConstraints.copy(
370
390
  maxWidth = (realConstraints.maxWidth * (1 - scrollPercent)).toInt()
@@ -372,8 +392,8 @@ private class LiteScreenHeaderPolicy(
372
392
  )
373
393
  } else {
374
394
  var spaceConsumed = 0
375
- if (backIconPlaceable.safeWidth != 0) spaceConsumed += backIconPlaceable.safeWidth + spacing12
376
- if (headerRightPlaceable.safeWidth != 0) spaceConsumed += headerRightPlaceable.safeWidth + spacing12
395
+ if (backIconPlaceable.safeWidth != 0) spaceConsumed += backIconPlaceable.safeWidth + spaceBetween
396
+ if (headerRightPlaceable.safeWidth != 0) spaceConsumed += headerRightPlaceable.safeWidth + spaceBetween
377
397
  realConstraints.copy(
378
398
  maxWidth = realConstraints.maxWidth - spaceConsumed
379
399
  )
@@ -382,7 +402,7 @@ private class LiteScreenHeaderPolicy(
382
402
  ?.measure(inputSearchConstraints)
383
403
  val titlePlaceable = measurables.find { it.layoutId == HeaderId.TITLE_ID }?.measure(
384
404
  constraints = realConstraints.copy(
385
- maxWidth = realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spacing12 * 2
405
+ maxWidth = realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
386
406
  )
387
407
  )
388
408
 
@@ -420,7 +440,7 @@ private class LiteScreenHeaderPolicy(
420
440
  x = startX,
421
441
  y = startY + backIconPlaceable.verticalCenterOffset(firstRowMaxHeight),
422
442
  )
423
- curX += backIconPlaceable.safeWidth + spacing12
443
+ curX += backIconPlaceable.safeWidth + spaceBetween
424
444
  }
425
445
 
426
446
  headerRightPlaceable?.place(
@@ -445,7 +465,7 @@ private class LiteScreenHeaderPolicy(
445
465
 
446
466
  val inputSearchOffset = if (isHeaderExtend) {
447
467
  IntOffset(
448
- x = startX + ((backIconPlaceable.safeWidth + spacing12) * (scrollPercent * 2f).coerceIn(
468
+ x = startX + ((backIconPlaceable.safeWidth + spaceBetween) * (scrollPercent * 2f).coerceIn(
449
469
  0f, 1f
450
470
  )).toInt(),
451
471
  y = (curY * (1 - scrollPercent)).toInt().coerceAtLeast(
@@ -504,6 +524,11 @@ data class LiteInputSearchProps(
504
524
 
505
525
  val placeHolder: String? = null,
506
526
 
527
+ val customBackIcon: @Composable (() -> Unit)? = null,
528
+ val customSearchIcon: @Composable (() -> Unit)? = null,
529
+ val customPlaceHolder: @Composable (() -> Unit)? = null,
530
+ val customTextStyle: TextStyle? = null,
531
+ val customIconClear: @Composable (() -> Unit)? = null,
507
532
  val iconRightTextField: @Composable ((Modifier) -> Unit)? = null,
508
533
  )
509
534
 
@@ -545,7 +570,6 @@ private fun LiteInputSearch(
545
570
  val textFieldModifier = remember(inputSearchProps.modifier) {
546
571
  inputSearchProps.modifier
547
572
  .weight(1f)
548
- .sizeIn(minHeight = 36.dp)
549
573
  }
550
574
  BasicTextField(
551
575
  value = textState,
@@ -554,7 +578,7 @@ private fun LiteInputSearch(
554
578
  keyboardOptions = inputSearchProps.keyboardOptions,
555
579
  keyboardActions = inputSearchProps.keyboardActions,
556
580
  modifier = textFieldModifier,
557
- textStyle = inputFieldStyle,
581
+ textStyle = inputSearchProps.customTextStyle ?: inputFieldStyle,
558
582
  singleLine = true,
559
583
  interactionSource = interactionSource,
560
584
  decorationBox = { innerTextField ->
@@ -592,10 +616,6 @@ private fun LiteInputSearch(
592
616
 
593
617
  Row(
594
618
  modifier = Modifier
595
- .background(
596
- color = theme.colors.background.surface,
597
- shape = RoundedCornerShape(Radius.XL),
598
- )
599
619
  .padding(
600
620
  horizontal = Spacing.M,
601
621
  vertical = Spacing.S,
@@ -603,7 +623,7 @@ private fun LiteInputSearch(
603
623
  horizontalArrangement = Arrangement.Start,
604
624
  verticalAlignment = Alignment.CenterVertically,
605
625
  ) {
606
- Icon(
626
+ inputSearchProps.customSearchIcon?.invoke() ?: Icon(
607
627
  source = "navigation_search",
608
628
  modifier = Modifier.padding(end = Spacing.XS),
609
629
  size = 24.dp,
@@ -614,9 +634,9 @@ private fun LiteInputSearch(
614
634
  contentAlignment = Alignment.CenterStart,
615
635
  ) {
616
636
  if (!placeHolder.isNullOrEmpty()) {
617
- Text(
637
+ inputSearchProps.customPlaceHolder?.invoke() ?: Text(
618
638
  text = placeHolder ?: "",
619
- style = Typography.bodyDefaultRegular,
639
+ style = inputSearchProps.customTextStyle ?: Typography.bodyDefaultRegular,
620
640
  maxLines = 1,
621
641
  color = theme.colors.text.hint,
622
642
  overflow = TextOverflow.Ellipsis
@@ -626,7 +646,7 @@ private fun LiteInputSearch(
626
646
  }
627
647
 
628
648
  if (isShowClear) {
629
- Icon(
649
+ inputSearchProps.customIconClear?.invoke() ?: Icon(
630
650
  source = "24_navigation_close_circle_full",
631
651
  size = 16.dp,
632
652
  color = theme.colors.text.hint,
@@ -717,4 +737,4 @@ fun Modifier.hideKeyboardOnTap() = composed {
717
737
  focusManager.clearFocus()
718
738
  }
719
739
  }
720
- }
740
+ }
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.160.7
21
+ version=0.160.8
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.160.7-debug",
3
+ "version": "0.160.8-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},