-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ad-hoc): Dynamic action container background (#262)
- Loading branch information
1 parent
d3b723f
commit 0cdd928
Showing
13 changed files
with
151 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
ui-core/src/main/kotlin/com/processout/sdk/ui/core/component/POIme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.processout.sdk.ui.core.component | ||
|
||
import android.view.ViewTreeObserver | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.platform.LocalView | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import com.processout.sdk.ui.core.annotation.ProcessOutInternalApi | ||
|
||
/** @suppress */ | ||
@ProcessOutInternalApi | ||
object POIme { | ||
|
||
@Composable | ||
fun isImeVisibleAsState(): State<Boolean> { | ||
val isImeVisible = remember { | ||
mutableStateOf( | ||
value = false, | ||
policy = neverEqualPolicy() | ||
) | ||
} | ||
val view = LocalView.current.rootView | ||
val viewTreeObserver = view.viewTreeObserver | ||
DisposableEffect(viewTreeObserver) { | ||
val listener = ViewTreeObserver.OnGlobalLayoutListener { | ||
isImeVisible.value = ViewCompat.getRootWindowInsets(view) | ||
?.isVisible(WindowInsetsCompat.Type.ime()) ?: false | ||
} | ||
viewTreeObserver.addOnGlobalLayoutListener(listener) | ||
onDispose { | ||
viewTreeObserver.removeOnGlobalLayoutListener(listener) | ||
} | ||
} | ||
return isImeVisible | ||
} | ||
|
||
@Composable | ||
fun imeHeight(): Int = | ||
ViewCompat.getRootWindowInsets(LocalView.current.rootView) | ||
?.getInsets(WindowInsetsCompat.Type.ime()) | ||
?.bottom ?: 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.