@momo-kits/native-kits 0.160.1-searchBackground.2-debug → 0.160.1-searchBackground.3-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
|
@@ -104,6 +104,7 @@ fun LiteScreen(
|
|
|
104
104
|
headerRightData: HeaderRightData? = null,
|
|
105
105
|
headerTintColor: Color? = null,
|
|
106
106
|
headerBackgroundColor: Color? = null,
|
|
107
|
+
headerSpaceBetween: Dp? = null,
|
|
107
108
|
/* End of header props */
|
|
108
109
|
|
|
109
110
|
screenContent: @Composable () -> Unit,
|
|
@@ -140,6 +141,7 @@ fun LiteScreen(
|
|
|
140
141
|
headerRightData = headerRightData,
|
|
141
142
|
tintColor = headerTintColor,
|
|
142
143
|
headerBackgroundColor = headerBackgroundColor,
|
|
144
|
+
headerSpaceBetween = headerSpaceBetween,
|
|
143
145
|
)
|
|
144
146
|
|
|
145
147
|
Box(
|
|
@@ -172,6 +174,7 @@ private fun LiteScreenHeader(
|
|
|
172
174
|
useAnimationSearch: Boolean = true,
|
|
173
175
|
onGoBack: (() -> Unit)? = null,
|
|
174
176
|
headerBackgroundColor: Color? = null,
|
|
177
|
+
headerSpaceBetween: Dp? = null,
|
|
175
178
|
inputSearchProps: LiteInputSearchProps? = null,
|
|
176
179
|
headerRight: @Composable (() -> Unit)? = null,
|
|
177
180
|
) {
|
|
@@ -248,6 +251,7 @@ private fun LiteScreenHeader(
|
|
|
248
251
|
statusBarHeight,
|
|
249
252
|
titlePosition,
|
|
250
253
|
scrollPercentage,
|
|
254
|
+
headerSpaceBetween,
|
|
251
255
|
) {
|
|
252
256
|
LiteScreenHeaderPolicy(
|
|
253
257
|
useAnimationSearch = useAnimationSearch,
|
|
@@ -255,6 +259,7 @@ private fun LiteScreenHeader(
|
|
|
255
259
|
statusBarHeight = statusBarHeight,
|
|
256
260
|
titlePosition = titlePosition,
|
|
257
261
|
scrollPercentage = scrollPercentage,
|
|
262
|
+
headerSpaceBetween = headerSpaceBetween,
|
|
258
263
|
)
|
|
259
264
|
}
|
|
260
265
|
|
|
@@ -350,6 +355,7 @@ private class LiteScreenHeaderPolicy(
|
|
|
350
355
|
private val statusBarHeight: Dp,
|
|
351
356
|
private val scrollPercentage: State<Float>,
|
|
352
357
|
private val titlePosition: TitlePosition,
|
|
358
|
+
private val headerSpaceBetween: Dp? = null,
|
|
353
359
|
) : MeasurePolicy {
|
|
354
360
|
|
|
355
361
|
override fun MeasureScope.measure(
|
|
@@ -357,6 +363,7 @@ private class LiteScreenHeaderPolicy(
|
|
|
357
363
|
constraints: Constraints
|
|
358
364
|
): MeasureResult {
|
|
359
365
|
val spacing12 = Spacing.M.roundToPx()
|
|
366
|
+
val spaceBetween = headerSpaceBetween?.roundToPx() ?: spacing12
|
|
360
367
|
val statusBarPx = statusBarHeight.roundToPx()
|
|
361
368
|
val scrollPercent = scrollPercentage.value
|
|
362
369
|
|
|
@@ -376,7 +383,7 @@ private class LiteScreenHeaderPolicy(
|
|
|
376
383
|
)
|
|
377
384
|
val inputSearchConstraints = if (isHeaderExtend) {
|
|
378
385
|
val minWidth =
|
|
379
|
-
if (useAnimationSearch) realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth -
|
|
386
|
+
if (useAnimationSearch) realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
|
|
380
387
|
else realConstraints.maxWidth
|
|
381
388
|
realConstraints.copy(
|
|
382
389
|
maxWidth = (realConstraints.maxWidth * (1 - scrollPercent)).toInt()
|
|
@@ -384,8 +391,8 @@ private class LiteScreenHeaderPolicy(
|
|
|
384
391
|
)
|
|
385
392
|
} else {
|
|
386
393
|
var spaceConsumed = 0
|
|
387
|
-
if (backIconPlaceable.safeWidth != 0) spaceConsumed += backIconPlaceable.safeWidth +
|
|
388
|
-
if (headerRightPlaceable.safeWidth != 0) spaceConsumed += headerRightPlaceable.safeWidth +
|
|
394
|
+
if (backIconPlaceable.safeWidth != 0) spaceConsumed += backIconPlaceable.safeWidth + spaceBetween
|
|
395
|
+
if (headerRightPlaceable.safeWidth != 0) spaceConsumed += headerRightPlaceable.safeWidth + spaceBetween
|
|
389
396
|
realConstraints.copy(
|
|
390
397
|
maxWidth = realConstraints.maxWidth - spaceConsumed
|
|
391
398
|
)
|
|
@@ -394,7 +401,7 @@ private class LiteScreenHeaderPolicy(
|
|
|
394
401
|
?.measure(inputSearchConstraints)
|
|
395
402
|
val titlePlaceable = measurables.find { it.layoutId == HeaderId.TITLE_ID }?.measure(
|
|
396
403
|
constraints = realConstraints.copy(
|
|
397
|
-
maxWidth = realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth -
|
|
404
|
+
maxWidth = realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spaceBetween * 2
|
|
398
405
|
)
|
|
399
406
|
)
|
|
400
407
|
|
|
@@ -432,7 +439,7 @@ private class LiteScreenHeaderPolicy(
|
|
|
432
439
|
x = startX,
|
|
433
440
|
y = startY + backIconPlaceable.verticalCenterOffset(firstRowMaxHeight),
|
|
434
441
|
)
|
|
435
|
-
curX += backIconPlaceable.safeWidth +
|
|
442
|
+
curX += backIconPlaceable.safeWidth + spaceBetween
|
|
436
443
|
}
|
|
437
444
|
|
|
438
445
|
headerRightPlaceable?.place(
|
|
@@ -457,7 +464,7 @@ private class LiteScreenHeaderPolicy(
|
|
|
457
464
|
|
|
458
465
|
val inputSearchOffset = if (isHeaderExtend) {
|
|
459
466
|
IntOffset(
|
|
460
|
-
x = startX + ((backIconPlaceable.safeWidth +
|
|
467
|
+
x = startX + ((backIconPlaceable.safeWidth + spaceBetween) * (scrollPercent * 2f).coerceIn(
|
|
461
468
|
0f, 1f
|
|
462
469
|
)).toInt(),
|
|
463
470
|
y = (curY * (1 - scrollPercent)).toInt().coerceAtLeast(
|
|
@@ -518,6 +525,7 @@ data class LiteInputSearchProps(
|
|
|
518
525
|
|
|
519
526
|
val customBackIcon: @Composable (() -> Unit)? = null,
|
|
520
527
|
val customSearchIcon: @Composable (() -> Unit)? = null,
|
|
528
|
+
val customPlaceHolder: @Composable (() -> Unit)? = null,
|
|
521
529
|
|
|
522
530
|
val iconRightTextField: @Composable ((Modifier) -> Unit)? = null,
|
|
523
531
|
)
|
|
@@ -629,7 +637,7 @@ private fun LiteInputSearch(
|
|
|
629
637
|
contentAlignment = Alignment.CenterStart,
|
|
630
638
|
) {
|
|
631
639
|
if (!placeHolder.isNullOrEmpty()) {
|
|
632
|
-
Text(
|
|
640
|
+
inputSearchProps.customPlaceHolder?.invoke() ?: Text(
|
|
633
641
|
text = placeHolder ?: "",
|
|
634
642
|
style = Typography.bodyDefaultRegular,
|
|
635
643
|
maxLines = 1,
|