Created
August 10, 2021 12:44
-
-
Save jershell/0691d5633f24684fe84d2f9e23719e30 to your computer and use it in GitHub Desktop.
popup full screen compose dialog
This file contains hidden or 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
package components | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.unit.* | |
import androidx.compose.ui.window.Popup | |
import androidx.compose.ui.window.PopupPositionProvider | |
@Composable | |
actual fun Dialog(content: @Composable () -> Unit) { | |
Popup(popupPositionProvider = object : PopupPositionProvider { | |
override fun calculatePosition( | |
anchorBounds: IntRect, | |
windowSize: IntSize, | |
layoutDirection: LayoutDirection, | |
popupContentSize: IntSize | |
): IntOffset { | |
return IntOffset.Zero | |
} | |
}) { | |
Box( | |
modifier = Modifier.fillMaxSize().background(Color.Green), | |
contentAlignment = Alignment.Center, | |
content = { | |
Text("AAA") | |
} | |
) | |
} | |
} |
It exits the app when I open the popup and press button Back
.
It exits the app when I open the popup and press button
Back
.
Hello bro wtf
@Composable
fun DialogPopUp(onCloseClick: () -> Unit, content: @Composable () -> Unit) {
Popup(
onDismissRequest = onCloseClick,
popupPositionProvider = object : PopupPositionProvider {
override fun calculatePosition(
anchorBounds: IntRect,
windowSize: IntSize,
layoutDirection: LayoutDirection,
popupContentSize: IntSize
): IntOffset {
return IntOffset.Zero
}
}) {
`
Box(
modifier = Modifier
.fillMaxSize()
.background(Color.White),
contentAlignment = Alignment.Center,
content = {
content()
}
)
BackHandler {
onCloseClick()
}
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if android