@momo-kits/native-kits 0.89.19 → 0.89.21

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 (43) hide show
  1. package/compose/build.gradle.kts +11 -15
  2. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +22 -0
  3. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Components.kt +71 -27
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +200 -0
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +47 -0
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +7 -139
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +89 -22
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +17 -1
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -7
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -2
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +6 -8
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -2
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +37 -17
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +54 -21
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +155 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +2 -20
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +185 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -19
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +2 -18
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +58 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +37 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +65 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +43 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -3
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -2
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +14 -1
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +2 -2
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +28 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +1 -2
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +18 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -23
  32. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +33 -0
  33. package/gradle.properties +1 -1
  34. package/package.json +1 -1
  35. package/settings.gradle.kts +1 -0
  36. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Platform.kt +0 -3
  37. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +0 -8
  38. package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Utils.android.kt +0 -14
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Platform.kt +0 -3
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +0 -5
  41. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Platform.kt +0 -3
  42. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +0 -9
  43. package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Utils.ios.kt +0 -18
@@ -0,0 +1,65 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.horizontalScroll
5
+ import androidx.compose.foundation.layout.Box
6
+ import androidx.compose.foundation.layout.Column
7
+ import androidx.compose.foundation.layout.Row
8
+ import androidx.compose.foundation.layout.fillMaxWidth
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.width
13
+ import androidx.compose.foundation.rememberScrollState
14
+ import androidx.compose.foundation.shape.RoundedCornerShape
15
+ import androidx.compose.runtime.Composable
16
+ import androidx.compose.ui.Alignment
17
+ import androidx.compose.ui.Modifier
18
+ import androidx.compose.ui.draw.clip
19
+ import androidx.compose.ui.unit.Dp
20
+ import androidx.compose.ui.unit.dp
21
+ import vn.momo.kits.const.AppTheme
22
+ import vn.momo.kits.const.Spacing
23
+
24
+ val INDICATOR_WIDTH = 24.dp
25
+ val PROGRESS_WIDTH = 72.dp
26
+
27
+ fun calculateOffset(currentPosition: Int, maxBound: Int): Dp {
28
+ return (PROGRESS_WIDTH - INDICATOR_WIDTH).times(currentPosition / maxBound.toFloat())
29
+ }
30
+
31
+ @Composable
32
+ fun PaginationScroll(
33
+ modifier: Modifier = Modifier,
34
+ content: @Composable () -> Unit
35
+ ) {
36
+ val scrollOffset = rememberScrollState()
37
+
38
+ Column(horizontalAlignment = Alignment.CenterHorizontally) {
39
+ Row(
40
+ modifier = modifier.fillMaxWidth().padding(bottom = Spacing.L)
41
+ .horizontalScroll(scrollOffset)
42
+ ) {
43
+ content()
44
+ }
45
+ Box(
46
+ modifier = Modifier.clip(
47
+ RoundedCornerShape(Spacing.XS)
48
+ ).width(PROGRESS_WIDTH).height(4.dp)
49
+ .background(color = AppTheme.current.colors.background.pressed)
50
+ ) {
51
+ Box(
52
+ modifier = Modifier.offset(
53
+ x = calculateOffset(
54
+ scrollOffset.value,
55
+ scrollOffset.maxValue
56
+ )
57
+ ).clip(RoundedCornerShape(Spacing.XS))
58
+ .width(
59
+ INDICATOR_WIDTH
60
+ ).height(4.dp)
61
+ .background(color = AppTheme.current.colors.primary)
62
+ )
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,43 @@
1
+ package vn.momo.kits.components
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.layout.Box
5
+ import androidx.compose.foundation.layout.BoxWithConstraints
6
+ import androidx.compose.foundation.layout.Row
7
+ import androidx.compose.foundation.layout.height
8
+ import androidx.compose.foundation.layout.padding
9
+ import androidx.compose.foundation.layout.size
10
+ import androidx.compose.foundation.shape.RoundedCornerShape
11
+ import androidx.compose.runtime.Composable
12
+ import androidx.compose.ui.Alignment
13
+ import androidx.compose.ui.Modifier
14
+ import androidx.compose.ui.draw.alpha
15
+ import androidx.compose.ui.draw.clip
16
+ import androidx.compose.ui.draw.clipToBounds
17
+ import androidx.compose.ui.graphics.Color
18
+ import androidx.compose.ui.unit.dp
19
+ import vn.momo.kits.const.AppTheme
20
+ import vn.momo.kits.const.Colors
21
+ import vn.momo.kits.const.Spacing
22
+ import vn.momo.kits.const.Typography
23
+
24
+ @Composable
25
+ fun PaginationWhiteDot(
26
+ activeIndex: Int = 0,
27
+ dataLength: Int = 3
28
+ ) {
29
+ Row(
30
+ modifier = Modifier.background(
31
+ color = Color(0x33000000),
32
+ shape = RoundedCornerShape(Spacing.S)
33
+ ).padding(Spacing.XS)
34
+ ) {
35
+ for (i in 0 until dataLength) {
36
+ Dot(
37
+ i == activeIndex,
38
+ Colors.black_01,
39
+ modifier = Modifier.padding(end = if (i != dataLength - 1) Spacing.XS else 0.dp)
40
+ )
41
+ }
42
+ }
43
+ }
@@ -32,7 +32,6 @@ import androidx.compose.ui.semantics.semantics
32
32
  import androidx.compose.ui.semantics.testTag
33
33
  import androidx.compose.ui.text.TextLayoutResult
34
34
  import androidx.compose.ui.unit.dp
35
- import vn.momo.kits.application.AppNavigator
36
35
  import vn.momo.kits.const.AppTheme
37
36
  import vn.momo.kits.const.Radius
38
37
  import vn.momo.kits.const.Spacing
@@ -63,7 +62,6 @@ fun PopupNotify(
63
62
  ) {
64
63
  var isScroll by remember { mutableStateOf(false) }
65
64
  val layoutResult = remember { mutableStateOf<TextLayoutResult?>(null) }
66
- val navigator = AppNavigator.current
67
65
 
68
66
  LaunchedEffect(layoutResult.value) {
69
67
  if ((layoutResult.value?.lineCount ?: 0) > 3) {
@@ -95,7 +93,6 @@ fun PopupNotify(
95
93
  }
96
94
 
97
95
  fun onClose(callback: (() -> Unit)?) {
98
- navigator.pop()
99
96
  callback?.invoke()
100
97
  }
101
98
 
@@ -41,8 +41,6 @@ fun Switch(
41
41
  RoundedCornerShape(20.dp)
42
42
  ).background(backgroundColor, RoundedCornerShape(20.dp)).clip(RoundedCornerShape(20.dp))
43
43
  .clickable(
44
- interactionSource = remember { MutableInteractionSource() },
45
- indication = rememberRipple(),
46
44
  enabled = !disabled,
47
45
  onClick = { onChange(!value) }
48
46
  )
@@ -16,7 +16,6 @@ import vn.momo.kits.const.Radius
16
16
  import vn.momo.kits.const.Spacing
17
17
  import vn.momo.kits.const.Typography
18
18
  import vn.momo.kits.const.scaleSize
19
- import vn.momo.kits.utils.primaryColors
20
19
 
21
20
  enum class TagSize(val height: Float) {
22
21
  Large(24.toFloat()),
@@ -40,6 +39,20 @@ fun Tag(
40
39
  size: TagSize = TagSize.Large,
41
40
  customColor: Color? = null,
42
41
  ) {
42
+ val primaryColors = listOf(
43
+ Color(0xFFF0F0F0),
44
+ Color(0xFFEB2F96),
45
+ Color(0xFF962AF0),
46
+ Color(0xFF4E4BFF),
47
+ Color(0xFF007AFF),
48
+ Color(0xFF13C2C2),
49
+ Color(0xFF34C759),
50
+ Color(0xFFA0D911),
51
+ Color(0xFFFFCC00),
52
+ Color(0xFFFA8C16),
53
+ Color(0xFFFA541C),
54
+ Color(0xFFF5222D)
55
+ )
43
56
  var tagColor = color.backgroundColor
44
57
  var labelColor = color.textColor
45
58
 
@@ -11,13 +11,13 @@ import org.jetbrains.compose.resources.Font
11
11
  import org.jetbrains.compose.resources.FontResource
12
12
  import org.jetbrains.compose.resources.InternalResourceApi
13
13
  import org.jetbrains.compose.resources.ResourceItem
14
- import vn.momo.kits.utils.getScreenDimensions
14
+ import vn.momo.kits.platform.getScreenDimensions
15
15
 
16
16
  const val DEFAULT_SCREEN_SIZE = 375f
17
17
 
18
18
  @Composable
19
19
  fun scaleSize(size: Float): Float {
20
- val deviceWidth = getScreenDimensions().screenWidth
20
+ val deviceWidth = getScreenDimensions().width
21
21
  val scaleRate = deviceWidth / DEFAULT_SCREEN_SIZE
22
22
  if (scaleRate > 1) {
23
23
  return if ((scaleRate * size) > (size + 5)) size + 5 else scaleRate * size
@@ -1,2 +1,30 @@
1
1
  package vn.momo.kits.layout
2
2
 
3
+ import androidx.compose.foundation.layout.Box
4
+ import androidx.compose.foundation.layout.height
5
+ import androidx.compose.foundation.layout.width
6
+ import androidx.compose.runtime.Composable
7
+ import androidx.compose.ui.Modifier
8
+ import androidx.compose.ui.unit.Dp
9
+
10
+ data class GridContext (
11
+ val numberOfColumns: Number,
12
+ val gutterSize: Number,
13
+ val sizePerSpan: Number,
14
+ val getSizeSpan: (Number) -> Number
15
+ )
16
+
17
+ @Composable
18
+ fun Item(heightSpan: Number = 1,
19
+ widthSpan: Number = 1,
20
+ content: @Composable() () -> Unit,
21
+ modifier: Modifier = Modifier,
22
+ grid: GridContext) {
23
+
24
+ val widthItem = grid.getSizeSpan(widthSpan)
25
+ val heightItem = grid.getSizeSpan(heightSpan)
26
+
27
+ Box(modifier = modifier.width(width = Dp(widthItem.toFloat())).height(height = Dp(heightItem.toFloat()))) {
28
+ content()
29
+ }
30
+ }
@@ -8,7 +8,7 @@ import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
8
8
  import androidx.compose.ui.graphics.toArgb
9
9
  import androidx.compose.ui.unit.Dp
10
10
  import androidx.compose.ui.unit.dp
11
- import vn.momo.kits.utils.setMaskFilter
11
+ import vn.momo.kits.platform.setMaskFilter
12
12
 
13
13
 
14
14
  fun Modifier.shadow(
@@ -29,7 +29,6 @@ fun Modifier.shadow(
29
29
  val topPixel = (0f - spreadPixel) + offsetY.toPx()
30
30
  val rightPixel = (this.size.width + spreadPixel)
31
31
  val bottomPixel = (0f + spreadPixel) - offsetY.toPx()
32
- // val bottomPixel = if (offsetY < 0.dp) 0f else this.size.height + spreadPixel
33
32
 
34
33
  if (blurRadius != 0f) {
35
34
  frameworkPaint.setMaskFilter(blurRadius)
@@ -0,0 +1,18 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.ui.graphics.NativePaint
5
+
6
+ data class ScreenDimension(
7
+ val width: Int,
8
+ val height: Int,
9
+ )
10
+
11
+ expect fun getPlatformName(): String
12
+
13
+ expect fun disableOverscroll(): Unit
14
+
15
+ @Composable
16
+ expect fun getScreenDimensions(): ScreenDimension
17
+
18
+ expect fun NativePaint.setMaskFilter(blurRadius: Float)
@@ -1,6 +1,5 @@
1
1
  package vn.momo.kits.utils
2
2
 
3
- import androidx.compose.runtime.Composable
4
3
  import androidx.compose.ui.Modifier
5
4
  import androidx.compose.ui.composed
6
5
  import androidx.compose.ui.draw.drawBehind
@@ -11,10 +10,6 @@ import androidx.compose.ui.unit.Dp
11
10
  import androidx.compose.ui.unit.dp
12
11
  import kotlin.math.abs
13
12
 
14
- data class ScreenDimension(
15
- val screenWidth: Int,
16
- val screenHeight: Int,
17
- )
18
13
 
19
14
  internal fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed(
20
15
  factory = {
@@ -77,21 +72,3 @@ fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
77
72
 
78
73
  return result + currency
79
74
  }
80
-
81
- @Composable
82
- expect fun getScreenDimensions(): ScreenDimension
83
-
84
- val primaryColors = listOf(
85
- Color(0xFFF0F0F0),
86
- Color(0xFFEB2F96),
87
- Color(0xFF962AF0),
88
- Color(0xFF4E4BFF),
89
- Color(0xFF007AFF),
90
- Color(0xFF13C2C2),
91
- Color(0xFF34C759),
92
- Color(0xFFA0D911),
93
- Color(0xFFFFCC00),
94
- Color(0xFFFA8C16),
95
- Color(0xFFFA541C),
96
- Color(0xFFF5222D)
97
- )
@@ -0,0 +1,33 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import androidx.compose.foundation.ExperimentalFoundationApi
4
+ import androidx.compose.foundation.gestures.optOutOfCupertinoOverscroll
5
+ import androidx.compose.runtime.Composable
6
+ import androidx.compose.ui.graphics.NativePaint
7
+ import kotlinx.cinterop.ExperimentalForeignApi
8
+ import kotlinx.cinterop.get
9
+ import kotlinx.cinterop.memScoped
10
+ import org.jetbrains.skia.FilterBlurMode
11
+ import org.jetbrains.skia.MaskFilter
12
+ import platform.UIKit.UIScreen
13
+
14
+ actual fun getPlatformName(): String = "iOS"
15
+
16
+ @OptIn(ExperimentalFoundationApi::class)
17
+ actual fun disableOverscroll() {
18
+ optOutOfCupertinoOverscroll()
19
+ }
20
+
21
+ @OptIn(ExperimentalForeignApi::class)
22
+ @Composable
23
+ actual fun getScreenDimensions(): ScreenDimension = memScoped {
24
+ val config = UIScreen.mainScreen.bounds.ptr[0]
25
+ return ScreenDimension(
26
+ config.size.width.toInt(),
27
+ config.size.height.toInt()
28
+ )
29
+ }
30
+
31
+ actual fun NativePaint.setMaskFilter(blurRadius: Float) {
32
+ this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
33
+ }
package/gradle.properties CHANGED
@@ -14,6 +14,6 @@ android.minSdk=24
14
14
  #Versions
15
15
  kotlin.version=1.9.24
16
16
  agp.version=8.1.1
17
- compose.version=1.6.11
17
+ compose.version=1.7.0-alpha02
18
18
  composeCompilerVersion = 1.5.14
19
19
  maven-publish.version=0.25.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.89.19",
3
+ "version": "0.89.21",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},
@@ -13,6 +13,7 @@ pluginManagement {
13
13
  }
14
14
 
15
15
  plugins {
16
+
16
17
  val kotlinVersion = extra["kotlin.version"] as String
17
18
  val agpVersion = extra["agp.version"] as String
18
19
  val composeVersion = extra["compose.version"] as String
@@ -1,3 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- actual fun getPlatformName(): String = "Android"
@@ -1,8 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import android.graphics.BlurMaskFilter
4
- import androidx.compose.ui.graphics.NativePaint
5
-
6
- actual fun NativePaint.setMaskFilter(blurRadius: Float) {
7
- this.maskFilter = BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.NORMAL)
8
- }
@@ -1,14 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.ui.platform.LocalConfiguration
5
- import androidx.compose.ui.text.font.Font
6
- import androidx.compose.ui.text.font.FontFamily
7
-
8
- @Composable
9
- actual fun getScreenDimensions(): ScreenDimension {
10
- val config = LocalConfiguration.current
11
- return ScreenDimension(
12
- config.screenWidthDp, config.screenHeightDp
13
- )
14
- }
@@ -1,3 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- expect fun getPlatformName(): String
@@ -1,5 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.ui.graphics.NativePaint
4
-
5
- expect fun NativePaint.setMaskFilter(blurRadius: Float)
@@ -1,3 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- actual fun getPlatformName(): String = "iOS"
@@ -1,9 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.ui.graphics.NativePaint
4
- import org.jetbrains.skia.FilterBlurMode
5
- import org.jetbrains.skia.MaskFilter
6
-
7
- actual fun NativePaint.setMaskFilter(blurRadius: Float) {
8
- this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
9
- }
@@ -1,18 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.ui.text.font.FontFamily
5
- import kotlinx.cinterop.ExperimentalForeignApi
6
- import kotlinx.cinterop.get
7
- import kotlinx.cinterop.memScoped
8
- import platform.UIKit.UIScreen
9
-
10
- @OptIn(ExperimentalForeignApi::class)
11
- @Composable
12
- actual fun getScreenDimensions(): ScreenDimension = memScoped {
13
- val config = UIScreen.mainScreen.bounds.ptr[0]
14
- return ScreenDimension(
15
- config.size.width.toInt(),
16
- config.size.height.toInt()
17
- )
18
- }