@momo-kits/native-kits 0.160.12-debug → 0.160.13-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.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.160.12-debug"
43
+ version = "0.160.13-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.159.1-beta.16'
3
+ spec.version = '0.161.2-beta.1'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -3,6 +3,7 @@ package vn.momo.kits.navigation
3
3
  import androidx.compose.animation.*
4
4
  import androidx.compose.animation.core.tween
5
5
  import androidx.compose.runtime.*
6
+ import androidx.compose.runtime.saveable.rememberSaveable
6
7
  import androidx.compose.ui.unit.Dp
7
8
  import androidx.navigation.compose.NavHost
8
9
  import androidx.navigation.compose.composable
@@ -49,7 +50,9 @@ fun NavigationContainer(
49
50
  }
50
51
  }
51
52
 
52
- val startDestination = DynamicScreenRegistry.register(initialScreenName, initialScreen, options)
53
+ val screenId = rememberSaveable { DynamicScreenRegistry.nextId() }
54
+ DynamicScreenRegistry.bind(screenId, initialScreenName, initialScreen, options)
55
+ val startDestination = remember(screenId) { DynamicScreenRoute(screenId) }
53
56
 
54
57
  ProvideNavigationEventDispatcherOwner {
55
58
  CompositionLocalProvider(
@@ -132,6 +135,7 @@ fun NavigationContainer(
132
135
  DisposableEffect(Unit) {
133
136
  onDispose {
134
137
  navigator.dispose()
138
+ DynamicScreenRegistry.unregisterScreen(screenId)
135
139
  }
136
140
  }
137
141
  }
@@ -196,6 +196,18 @@ object DynamicScreenRegistry {
196
196
  return DynamicScreenRoute(id)
197
197
  }
198
198
 
199
+ fun nextId(): Int = idCounter++
200
+
201
+ fun bind(id: Int, screenName: String, content: @Composable () -> Unit, options: NavigationOptions?) {
202
+ screens[id] = DynamicScreen(
203
+ id = id,
204
+ name = screenName,
205
+ content = content,
206
+ options = options
207
+ )
208
+ if (id >= idCounter) idCounter = id + 1 // keep counter ahead after process-death restore
209
+ }
210
+
199
211
  fun unregisterScreen(id: Int) {
200
212
  screens.remove(id)
201
213
  }
@@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.Column
11
11
  import androidx.compose.foundation.layout.ColumnScope
12
12
  import androidx.compose.foundation.layout.Spacer
13
13
  import androidx.compose.foundation.layout.WindowInsets
14
+ import androidx.compose.foundation.layout.asPaddingValues
14
15
  import androidx.compose.foundation.layout.aspectRatio
15
16
  import androidx.compose.foundation.layout.fillMaxSize
16
17
  import androidx.compose.foundation.layout.fillMaxWidth
@@ -27,10 +28,12 @@ import androidx.compose.material.ExperimentalMaterialApi
27
28
  import androidx.compose.runtime.Composable
28
29
  import androidx.compose.runtime.CompositionLocalProvider
29
30
  import androidx.compose.runtime.LaunchedEffect
31
+ import androidx.compose.runtime.State
30
32
  import androidx.compose.runtime.getValue
31
33
  import androidx.compose.runtime.mutableIntStateOf
32
34
  import androidx.compose.runtime.mutableStateOf
33
35
  import androidx.compose.runtime.remember
36
+ import androidx.compose.runtime.rememberUpdatedState
34
37
  import androidx.compose.runtime.snapshotFlow
35
38
  import androidx.compose.runtime.staticCompositionLocalOf
36
39
  import androidx.compose.ui.Alignment
@@ -179,23 +182,20 @@ internal fun StackScreen(
179
182
  HeaderBackground()
180
183
  }
181
184
 
182
- Box(Modifier.zIndex(5f)) {
185
+ Box(Modifier.zIndex(4f)) {
183
186
  Header(onBackHandler)
184
187
  }
185
188
 
186
- Column(Modifier.zIndex(6f)) {
189
+ Column(Modifier.zIndex(5f)) {
187
190
  SearchAnimated(isScrollInProgress = scrollInProcess)
188
191
  }
189
192
 
190
193
  Column(Modifier.zIndex(2f).fillMaxSize()) {
191
194
  MainContent(content = content)
192
- }
193
-
194
- Box(Modifier.zIndex(4f).align(Alignment.BottomCenter)) {
195
195
  FooterContent()
196
196
  }
197
197
 
198
- Box(Modifier.zIndex(7f)) {
198
+ Box(Modifier.zIndex(6f)) {
199
199
  FloatingContent()
200
200
  }
201
201
 
@@ -261,11 +261,6 @@ fun ColumnScope.MainContent(content: @Composable () -> Unit) {
261
261
  ScreenContent(content = content)
262
262
  }
263
263
 
264
- if (options.footerComponent != null) {
265
- val footerHeight = LocalFooterHeightPx.current
266
- val footerHeightDp = with(density) { footerHeight.value.toDp() }
267
- Spacer(Modifier.height(footerHeightDp))
268
- }
269
264
  }
270
265
 
271
266
  @Composable
@@ -292,22 +287,24 @@ fun ScreenContent(content: @Composable () -> Unit) {
292
287
  fun FooterContent() {
293
288
  val options = LocalOptions.current
294
289
  if (options.footerComponent != null) {
295
- val ime = WindowInsets.ime
296
- val density = LocalDensity.current
297
- val imeBottom = ime.getBottom(density)
298
- val thresholdPx = with(density) { 50.dp.toPx() }
299
- val isKeyboardVisible = imeBottom > thresholdPx
300
- val bottomPadding = if (isKeyboardVisible) 0.dp else AppNavigationBar.current
290
+ val keyboardSize = keyboardSizeState()
291
+ val bottomPadding = (AppNavigationBar.current - keyboardSize.value).coerceAtLeast(0.dp)
301
292
  Footer(footerComponent = options.footerComponent, bottomPadding = bottomPadding)
302
293
  }
303
294
  }
304
295
 
296
+ @Composable
297
+ fun keyboardSizeState(): State<Dp> {
298
+ val bottom = WindowInsets.ime.asPaddingValues()
299
+ return rememberUpdatedState(bottom.calculateBottomPadding())
300
+ }
301
+
305
302
  @Composable
306
303
  fun OverplayView(bottomTabIndex: Int, id: Int) {
307
304
  val overplayType = OverplayComponentRegistry.getOverplayType()
308
305
 
309
306
  if (overplayType != null) {
310
- Box(Modifier.zIndex(if (overplayType == OverplayComponentType.SNACK_BAR) 3f else 8f).fillMaxSize()) {
307
+ Box(Modifier.zIndex(if (overplayType == OverplayComponentType.SNACK_BAR) 3f else 7f).fillMaxSize()) {
311
308
  if (bottomTabIndex != -1) return@Box
312
309
  if (OverplayComponentRegistry.currentRootId() != id) return@Box
313
310
  OverplayComponentRegistry.OverlayComponent()
@@ -466,13 +463,6 @@ fun SearchAnimated(
466
463
  }
467
464
  }
468
465
 
469
- @Composable
470
- internal fun isKeyboardVisible(): Boolean {
471
- val ime = WindowInsets.ime
472
- val density = LocalDensity.current
473
- return ime.getBottom(density) > 0
474
- }
475
-
476
466
  private fun quantize(value: Int, stepPx: Int): Int {
477
467
  if (stepPx <= 1) return value
478
468
  return (value / stepPx) * stepPx
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.160.12
21
+ version=0.160.13
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.160.12-debug",
3
+ "version": "0.160.13-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},