@momo-kits/native-kits 0.150.1-beta.2 → 0.150.1-beta.3

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.
@@ -1,11 +1,9 @@
1
- package vn.momo.kits.components
2
-
3
1
  import androidx.compose.foundation.background
4
2
  import androidx.compose.foundation.border
5
3
  import androidx.compose.foundation.layout.Arrangement
6
4
  import androidx.compose.foundation.layout.Row
7
- import androidx.compose.foundation.layout.height
8
5
  import androidx.compose.foundation.layout.padding
6
+ import androidx.compose.foundation.layout.wrapContentHeight
9
7
  import androidx.compose.foundation.layout.wrapContentWidth
10
8
  import androidx.compose.foundation.shape.RoundedCornerShape
11
9
  import androidx.compose.runtime.Composable
@@ -14,15 +12,15 @@ import androidx.compose.ui.Alignment
14
12
  import androidx.compose.ui.Modifier
15
13
  import androidx.compose.ui.draw.clip
16
14
  import androidx.compose.ui.graphics.Color
17
- import androidx.compose.ui.text.style.TextAlign
18
15
  import androidx.compose.ui.text.style.TextOverflow
19
16
  import androidx.compose.ui.unit.Dp
20
17
  import androidx.compose.ui.unit.dp
18
+ import vn.momo.kits.components.Icon
19
+ import vn.momo.kits.components.Text
21
20
  import vn.momo.kits.const.AppTheme
22
21
  import vn.momo.kits.const.Colors
23
22
  import vn.momo.kits.const.Radius
24
23
  import vn.momo.kits.const.Typography
25
- import vn.momo.kits.const.scaleSize
26
24
  import vn.momo.kits.modifier.activeOpacityClickable
27
25
  import vn.momo.kits.modifier.conditional
28
26
  import vn.momo.kits.modifier.setAutomationId
@@ -57,13 +55,10 @@ fun Chip(
57
55
  ChipSize.LARGE -> ChipDefaults.Large
58
56
  }
59
57
 
60
- val (height, horizontal, iconSize, iconSpacing) =
61
- listOf(scaleSize(dims.height), scaleSize(dims.horizontal), scaleSize(dims.iconSize), scaleSize(dims.iconSpacing))
62
-
63
58
  Row(
64
59
  modifier
65
60
  .wrapContentWidth()
66
- .height(height)
61
+ .wrapContentHeight()
67
62
  .clip(RoundedCornerShape(Radius.L))
68
63
  .background(bg)
69
64
  .conditional(selected) {
@@ -72,12 +67,12 @@ fun Chip(
72
67
  .activeOpacityClickable {
73
68
  onClick()
74
69
  }
75
- .padding(horizontal = horizontal)
70
+ .padding(horizontal = dims.horizontal, vertical = dims.vertical)
76
71
  .conditional(accessibilityLabel != null) {
77
72
  setAutomationId(accessibilityLabel.toString())
78
73
  },
79
74
  verticalAlignment = Alignment.CenterVertically,
80
- horizontalArrangement = Arrangement.spacedBy(iconSpacing)
75
+ horizontalArrangement = Arrangement.spacedBy(dims.iconSpacing)
81
76
  ) {
82
77
  if (iconLeft != null) {
83
78
  Icon(source = iconLeft, size = dims.iconSize, color = leftTint)
@@ -86,7 +81,6 @@ fun Chip(
86
81
  if (!label.isNullOrEmpty()) {
87
82
  Text(
88
83
  text = label,
89
- textAlign = TextAlign.Center,
90
84
  color = textColor,
91
85
  style = when (size) {
92
86
  ChipSize.SMALL -> Typography.labelSMedium
@@ -98,7 +92,7 @@ fun Chip(
98
92
  }
99
93
 
100
94
  if (iconRight != null) {
101
- Icon(source = iconRight, size = iconSize, color = rightTint)
95
+ Icon(source = iconRight, size = dims.iconSize, color = rightTint)
102
96
  }
103
97
  }
104
98
  }
@@ -108,23 +102,23 @@ enum class ChipSize { SMALL, LARGE }
108
102
  object ChipDefaults {
109
103
  @Immutable
110
104
  data class Dimensions(
111
- val height: Dp,
112
105
  val horizontal: Dp,
106
+ val vertical: Dp,
113
107
  val iconSize: Dp,
114
108
  val iconSpacing: Dp,
115
109
  )
116
110
 
117
111
  val Large = Dimensions(
118
- height = 32.dp,
119
112
  horizontal = 12.dp,
113
+ vertical = 8.dp,
120
114
  iconSize = 20.dp,
121
- iconSpacing = 4.dp,
115
+ iconSpacing = 8.dp,
122
116
  )
123
117
 
124
118
  val Small = Dimensions(
125
- height = 24.dp,
126
119
  horizontal = 10.dp,
120
+ vertical = 6.dp,
127
121
  iconSize = 16.dp,
128
- iconSpacing = 4.dp,
122
+ iconSpacing = 6.dp,
129
123
  )
130
124
  }
@@ -7,7 +7,6 @@ import androidx.compose.ui.text.TextStyle
7
7
  import androidx.compose.ui.text.font.FontFamily
8
8
  import androidx.compose.ui.text.font.FontWeight
9
9
  import androidx.compose.ui.text.style.TextDecoration
10
- import androidx.compose.ui.unit.Dp
11
10
  import androidx.compose.ui.unit.sp
12
11
  import org.jetbrains.compose.resources.Font
13
12
  import org.jetbrains.compose.resources.FontResource
@@ -59,15 +58,6 @@ fun scaleSize(size: Float): Float {
59
58
  )
60
59
  }
61
60
 
62
- @Composable
63
- fun scaleSize(size: Dp): Dp {
64
- val density = LocalDensity.current
65
- val px = with(density) { size.toPx() }
66
- val scaledPx = scaleSize(px)
67
- return with(density) { scaledPx.toDp() }
68
- }
69
-
70
-
71
61
  @OptIn(InternalResourceApi::class)
72
62
  @Composable
73
63
  fun getFont(font: FontResource): FontFamily {
@@ -101,6 +101,7 @@ internal fun BottomSheet(
101
101
  )
102
102
  )
103
103
  navigator.pop()
104
+ OverplayComponentRegistry.hardClearAfterDismiss()
104
105
  }
105
106
  }
106
107
 
@@ -67,6 +67,7 @@ internal fun ModalScreen(
67
67
  animationSpec = tween(durationMillis = 200)
68
68
  )
69
69
  navigator.pop()
70
+ OverplayComponentRegistry.hardClearAfterDismiss()
70
71
  }
71
72
  }
72
73
 
@@ -7,6 +7,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
7
7
  import androidx.navigation.NavController
8
8
  import kotlinx.coroutines.CoroutineScope
9
9
  import kotlinx.coroutines.Dispatchers
10
+ import kotlinx.coroutines.IO
10
11
  import kotlinx.coroutines.SupervisorJob
11
12
  import kotlinx.coroutines.cancel
12
13
  import kotlinx.coroutines.delay
@@ -18,7 +19,7 @@ class Navigator(
18
19
  private val navController: NavController,
19
20
  private val maxApi: IMaxApi?
20
21
  ) {
21
- private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
22
+ private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
22
23
 
23
24
  fun push(content: @Composable () -> Unit, options: NavigationOptions? = null) {
24
25
  val route = DynamicScreenRegistry.register(content, options)
@@ -34,26 +35,23 @@ class Navigator(
34
35
  }
35
36
  }
36
37
 
37
- fun pop(count: Int = 1, callBack: (() -> Unit)? = null) {
38
- scope.launch {
39
- repeat(count) {
40
- if (OverplayComponentRegistry.isOverplayShowing()){
41
- OverplayComponentRegistry.clear()
42
- delay(300L)
43
- OverplayComponentRegistry.hardClearAfterDismiss()
44
- } else {
45
- if (navController.previousBackStackEntry != null){
46
- navController.popBackStack()
38
+ fun pop(count: Int = 1) {
39
+ repeat(count) {
40
+ if (OverplayComponentRegistry.isOverplayShowing()){
41
+ OverplayComponentRegistry.clear()
42
+ } else {
43
+ if (navController.previousBackStackEntry != null){
44
+ navController.popBackStack()
45
+ scope.launch {
47
46
  delay(300L)
48
47
  DynamicScreenRegistry.getLatestScreen()?.let { it1 ->
49
48
  DynamicScreenRegistry.unregisterScreen(it1.id)
50
49
  }
51
- } else {
52
- maxApi?.dismiss { }
53
50
  }
51
+ } else {
52
+ maxApi?.dismiss { }
54
53
  }
55
54
  }
56
- callBack?.invoke()
57
55
  }
58
56
  }
59
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.150.1-beta.2",
3
+ "version": "0.150.1-beta.3",
4
4
  "private": false,
5
5
  "dependencies": {
6
6
  "@momo-platform/native-max-api": "1.0.18"