@momo-kits/native-kits 0.89.25 → 0.89.26

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.
@@ -26,6 +26,7 @@ actual fun NativePaint.setMaskFilter(blurRadius: Float) {
26
26
  }
27
27
 
28
28
  @SuppressLint("InternalInsetResource")
29
+ @Composable
29
30
  actual fun getStatusBarHeight(): Dp {
30
31
  val resourceId = Resources.getSystem().getIdentifier(
31
32
  "status_bar_height",
@@ -46,6 +46,7 @@ import vn.momo.kits.const.AppTheme
46
46
  import vn.momo.kits.const.Colors
47
47
  import vn.momo.kits.const.Spacing
48
48
  import vn.momo.kits.const.Typography
49
+ import vn.momo.kits.platform.getStatusBarHeight
49
50
  import vn.momo.kits.utils.bottomBorder
50
51
 
51
52
  enum class TitlePosition {
@@ -63,9 +64,10 @@ fun HeaderImage(
63
64
  headerType: HeaderType = HeaderType.DEFAULT,
64
65
  headerBackground: String?,
65
66
  ) {
67
+ val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
66
68
  when (headerType) {
67
69
  HeaderType.DEFAULT -> {
68
- val height = AppStatusBar.current + 52.dp
70
+ val height = statusBarHeight + 52.dp
69
71
  Image(
70
72
  source = headerBackground ?: "",
71
73
  modifier = Modifier.fillMaxWidth().height(height),
@@ -86,7 +88,7 @@ fun HeaderImage(
86
88
  }
87
89
 
88
90
  HeaderType.SURFACE -> {
89
- val height = AppStatusBar.current + 52.dp
91
+ val height =statusBarHeight + 52.dp
90
92
  Box(
91
93
  modifier = Modifier.fillMaxWidth().height(height)
92
94
  .background(AppTheme.current.colors.background.surface)
@@ -115,6 +117,7 @@ fun Header(
115
117
  animatedHeader: AnimatedHeader? = null,
116
118
  scrollState: Int = 0
117
119
  ) {
120
+ val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
118
121
  var tintIconColor = Colors.black_01
119
122
  var backgroundButton = Colors.black_20.copy(alpha = 0.4f)
120
123
  if (headerType == HeaderType.SURFACE) {
@@ -143,7 +146,7 @@ fun Header(
143
146
 
144
147
  if (headerType != HeaderType.NONE) {
145
148
  BoxWithConstraints(
146
- Modifier.height(AppStatusBar.current + 52.dp)
149
+ Modifier.height(statusBarHeight + 52.dp)
147
150
  .fillMaxWidth()
148
151
  .zIndex(10f),
149
152
  contentAlignment = Alignment.BottomCenter
@@ -34,6 +34,7 @@ import vn.momo.kits.const.AppTheme
34
34
  import vn.momo.kits.const.Colors
35
35
  import vn.momo.kits.const.Spacing
36
36
  import vn.momo.kits.modifier.shadow
37
+ import vn.momo.kits.platform.getStatusBarHeight
37
38
 
38
39
  enum class HeaderType {
39
40
  DEFAULT,
@@ -62,6 +63,7 @@ fun Screen(
62
63
  layoutOffset: Dp = 56.dp,
63
64
  content: @Composable () -> Unit,
64
65
  ) {
66
+ val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
65
67
  val keyboardController = LocalSoftwareKeyboardController.current
66
68
  val keyboardHeight = WindowInsets.ime.asPaddingValues().calculateBottomPadding()
67
69
  val keyboardSize = when {
@@ -117,7 +119,7 @@ fun Screen(
117
119
 
118
120
  Column(
119
121
  modifier = Modifier.fillMaxSize()
120
- .padding(top = if (animatedHeader === null && headerType !== HeaderType.NONE) AppStatusBar.current + 52.dp else 0.dp)
122
+ .padding(top = if (animatedHeader === null && headerType !== HeaderType.NONE) statusBarHeight + 52.dp else 0.dp)
121
123
  .pointerInput(Unit) {
122
124
  detectTapGestures(onTap = {
123
125
  keyboardController?.hide()
@@ -137,7 +139,7 @@ fun Screen(
137
139
  headerAnimated()
138
140
  Column {
139
141
  if (animatedHeader !== null) {
140
- Spacer(modifier = Modifier.padding(top = AppStatusBar.current + 52.dp + layoutOffset))
142
+ Spacer(modifier = Modifier.padding(top = statusBarHeight + 52.dp + layoutOffset))
141
143
  }
142
144
  content()
143
145
  }
@@ -2,7 +2,7 @@ package vn.momo.kits.const
2
2
 
3
3
  import androidx.compose.runtime.staticCompositionLocalOf
4
4
  import androidx.compose.ui.graphics.Color
5
- import androidx.compose.ui.unit.dp
5
+ import androidx.compose.ui.unit.Dp
6
6
 
7
7
  data class Background(
8
8
  val default: Color,
@@ -168,6 +168,6 @@ val darkTheme = Theme(
168
168
 
169
169
 
170
170
  val AppTheme = staticCompositionLocalOf { defaultTheme }
171
- val AppStatusBar = staticCompositionLocalOf {
172
- 0.dp
171
+ val AppStatusBar = staticCompositionLocalOf<Dp?> {
172
+ null
173
173
  }
@@ -18,4 +18,5 @@ expect fun getScreenDimensions(): ScreenDimension
18
18
 
19
19
  expect fun NativePaint.setMaskFilter(blurRadius: Float)
20
20
 
21
+ @Composable
21
22
  expect fun getStatusBarHeight(): Dp
@@ -2,6 +2,9 @@ package vn.momo.kits.platform
2
2
 
3
3
  import androidx.compose.foundation.ExperimentalFoundationApi
4
4
  import androidx.compose.foundation.gestures.optOutOfCupertinoOverscroll
5
+ import androidx.compose.foundation.layout.WindowInsets
6
+ import androidx.compose.foundation.layout.asPaddingValues
7
+ import androidx.compose.foundation.layout.systemBars
5
8
  import androidx.compose.runtime.Composable
6
9
  import androidx.compose.ui.graphics.NativePaint
7
10
  import androidx.compose.ui.unit.Dp
@@ -36,8 +39,7 @@ actual fun NativePaint.setMaskFilter(blurRadius: Float) {
36
39
  this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
37
40
  }
38
41
 
39
- @OptIn(ExperimentalForeignApi::class)
42
+ @Composable
40
43
  actual fun getStatusBarHeight(): Dp {
41
- val size = UIApplication.sharedApplication.statusBarFrame.size
42
- return size.dp
44
+ return WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
43
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.89.25",
3
+ "version": "0.89.26",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},