@momo-kits/native-kits 0.168.1-beta.37-debug → 0.168.1-beta.38-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.
Files changed (47) hide show
  1. package/CLAUDE.md +2 -3
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +81 -72
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +13 -8
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +163 -54
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +12 -17
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +34 -27
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +319 -167
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +93 -326
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -2
  18. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +3 -2
  19. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +3 -9
  20. package/ios/Input/Input.swift +1 -3
  21. package/ios/Input/InputTextArea.swift +1 -3
  22. package/ios/Layout/ScreenLayout.swift +24 -28
  23. package/ios/Navigation/BottomSheet.swift +157 -29
  24. package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
  25. package/ios/Navigation/BottomTab/BottomTabBar.swift +280 -132
  26. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  27. package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
  28. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  29. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  30. package/ios/Navigation/ModalScreen.swift +7 -18
  31. package/ios/Navigation/StackScreen.swift +3 -1
  32. package/ios/Popup/PopupDisplay.swift +2 -4
  33. package/ios/Popup/PopupInput.swift +2 -4
  34. package/ios/Popup/PopupLayout.swift +9 -10
  35. package/ios/Popup/PopupNotify.swift +23 -26
  36. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  37. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  38. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  39. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -103
  40. package/package.json +1 -1
  41. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  45. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  46. package/ios/Layout/ModalLayout.swift +0 -152
  47. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
@@ -1,86 +1,94 @@
1
1
  package vn.momo.kits.navigation.bottomtab
2
2
 
3
- import androidx.compose.foundation.Canvas
4
- import androidx.compose.foundation.layout.Box
5
- import androidx.compose.foundation.layout.height
6
- import androidx.compose.foundation.layout.offset
7
- import androidx.compose.foundation.layout.width
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Alignment
10
3
  import androidx.compose.ui.Modifier
4
+ import androidx.compose.ui.draw.dropShadow
5
+ import androidx.compose.ui.geometry.Rect
6
+ import androidx.compose.ui.geometry.RoundRect
7
+ import androidx.compose.ui.geometry.Size
8
+ import androidx.compose.ui.geometry.CornerRadius
9
+ import androidx.compose.ui.geometry.Offset
10
+ import androidx.compose.ui.graphics.addOutline
11
+ import androidx.compose.ui.graphics.Color
12
+ import androidx.compose.ui.graphics.Outline
11
13
  import androidx.compose.ui.graphics.Path
12
- import androidx.compose.ui.platform.LocalDensity
14
+ import androidx.compose.ui.graphics.Shape
15
+ import androidx.compose.ui.graphics.shadow.Shadow
16
+ import androidx.compose.ui.unit.Density
13
17
  import androidx.compose.ui.unit.Dp
14
- import androidx.compose.ui.unit.IntOffset
18
+ import androidx.compose.ui.unit.DpOffset
19
+ import androidx.compose.ui.unit.LayoutDirection
15
20
  import androidx.compose.ui.unit.dp
16
- import androidx.compose.ui.zIndex
21
+ import androidx.compose.foundation.background
22
+ import androidx.compose.runtime.Composable
17
23
  import vn.momo.kits.const.AppTheme
18
24
 
19
- @Composable
20
- internal fun CurvedContainer(
21
- circleSize: Dp = 48.dp,
22
- tabBarItemIconSize: Dp = 28.dp,
23
- circleOverSize: Dp = 2.dp,
24
- width: Dp = 71.dp,
25
- height: Dp = 16.dp
26
- ) {
27
- val theme = AppTheme.current
28
- val density = LocalDensity.current
29
- val widthPx = with(density) { width.toPx()}
30
-
31
- val circleSizePx = with(density) { circleSize.toPx() }
32
- val tabBarItemIconSizePx = with(density) { tabBarItemIconSize.toPx() }
33
- val circleOverSizePx = with(density) { circleOverSize.toPx() }
34
-
35
- val circlePositionTop = circleSizePx - tabBarItemIconSizePx - 10f
36
- val circleOverTop = circlePositionTop + circleOverSizePx
37
- val circleR = circleSizePx / 2
38
- val circleOverR = circleR + circleOverSizePx
39
-
40
- val centerX = widthPx / 2
41
-
42
- val curvedPath = getPath(
43
- circleOverTop = circleOverTop,
44
- centerX = centerX,
45
- circleOverR = circleOverR,
46
- widthPx = widthPx
47
- )
48
-
49
- Box(
50
- contentAlignment = Alignment.BottomCenter
51
- ){
52
- Canvas(
53
- modifier = Modifier
54
- .width(width)
55
- .height(height)
56
- .offset{ IntOffset(x = 0, y = 24) }
57
- .zIndex(-1f)
58
- ) {
59
- drawPath(path = curvedPath, color = theme.colors.background.surface)
25
+ // Rounded container, with the notch dipped into the top edge around `notchCenterX` (from the left).
26
+ internal class NotchedBarShape(
27
+ private val radius: Dp,
28
+ private val notchCenterX: Dp? = null,
29
+ ) : Shape {
30
+ override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
31
+ val r = minOf(with(density) { radius.toPx() }, size.height / 2, size.width / 2)
32
+ val path = Path()
33
+ if (notchCenterX == null) {
34
+ path.addRoundRect(RoundRect(Rect(0f, 0f, size.width, size.height), CornerRadius(r)))
35
+ return Outline.Generic(path)
60
36
  }
37
+ val cx = with(density) { notchCenterX.toPx() }
38
+ val unit = density.density
39
+ path.apply {
40
+ moveTo(r, 0f)
41
+ lineTo(cx - NOTCH_HALF_WIDTH * unit, 0f)
42
+ NOTCH_CURVES.forEach { (c1, c2, end) ->
43
+ cubicTo(
44
+ cx + c1.first * unit, c1.second * unit,
45
+ cx + c2.first * unit, c2.second * unit,
46
+ cx + end.first * unit, end.second * unit,
47
+ )
48
+ }
49
+ lineTo(size.width - r, 0f)
50
+ arcTo(Rect(size.width - 2 * r, 0f, size.width, 2 * r), -90f, 90f, false)
51
+ lineTo(size.width, size.height - r)
52
+ arcTo(Rect(size.width - 2 * r, size.height - 2 * r, size.width, size.height), 0f, 90f, false)
53
+ lineTo(r, size.height)
54
+ arcTo(Rect(0f, size.height - 2 * r, 2 * r, size.height), 90f, 90f, false)
55
+ lineTo(0f, r)
56
+ arcTo(Rect(0f, 0f, 2 * r, 2 * r), 180f, 90f, false)
57
+ close()
58
+ }
59
+ return Outline.Generic(path)
61
60
  }
62
61
  }
63
62
 
64
- private fun getPath(circleOverTop: Float, centerX: Float, circleOverR: Float, widthPx: Float): Path{
65
- return Path().apply {
66
- moveTo(0f, circleOverTop)
67
- lineTo(centerX - circleOverR - 40f, circleOverTop)
63
+ // The shape shrunk by `inset` on every side. A shadow cast from it with no spread is a shadow of the
64
+ // shape with spread -inset; dropShadow's own negative spread clips the blur of path outlines.
65
+ internal class InsetShape(private val shape: Shape, private val inset: Dp) : Shape {
66
+ override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
67
+ val insetPx = with(density) { inset.toPx() }
68
+ val inner = Size((size.width - 2 * insetPx).coerceAtLeast(0f), (size.height - 2 * insetPx).coerceAtLeast(0f))
69
+ val path = Path().apply {
70
+ addOutline(shape.createOutline(inner, layoutDirection, density))
71
+ translate(Offset(insetPx, insetPx))
72
+ }
73
+ return Outline.Generic(path)
74
+ }
75
+ }
68
76
 
69
- cubicTo(
70
- centerX - circleOverR, circleOverTop,
71
- centerX - circleOverR, 0f,
72
- centerX, 0f
73
- )
77
+ // Shadow with a negative spread, cast from the shrunk shape.
78
+ internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier =
79
+ if (shadow.spread < 0.dp) dropShadow(
80
+ InsetShape(shape, -shadow.spread),
81
+ Shadow(radius = shadow.radius, color = shadow.color, offset = shadow.offset, alpha = shadow.alpha),
82
+ )
83
+ else dropShadow(shape, shadow)
74
84
 
75
- cubicTo(
76
- centerX + circleOverR, 0f,
77
- centerX + circleOverR, circleOverTop,
78
- centerX + circleOverR + 40f, circleOverTop
85
+ // Navigation bar container: surface fill with the floating shadow following the shape (Figma
86
+ // Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16).
87
+ @Composable
88
+ internal fun Modifier.tabBarContainer(shape: Shape): Modifier =
89
+ dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
90
+ .spreadShadow(
91
+ shape,
92
+ Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
79
93
  )
80
-
81
- lineTo(widthPx, circleOverTop)
82
- lineTo(widthPx, 60f)
83
- lineTo(0f, 60f)
84
- close()
85
- }
86
- }
94
+ .background(AppTheme.current.colors.background.surface, shape)