[英]How can I show full screen dialog or navigate to other screen when I click a Layout function?
What I am trying to is..我想做的是..
Column(
modifier = Modifier
.width(97.dp)
.clickable {
Dialog(onDismissResult = { /*TODO*/ }) {
}
}
,
horizontalAlignment = Alignment.CenterHorizontally
But in clickable, composable function is not callable.但是在可点击的情况下,可组合的功能是不可调用的。
So, What I tried is using this,所以,我尝试的是使用这个,
val isClicked = remember { mutableStateOf(false) }
Column(
modifier = Modifier
.width(97.dp)
.clickable {
isClicked.value = !isClicked.value
},
horizontalAlignment = Alignment.CenterHorizontally
)
if(isClicked.value){
// show full screen dialog or navigate to some screen.
}
Here are two problems.这里有两个问题。
Dialog(
onDismissResult: () -> Unit,
properties: DialogProperties = DialogProperties(),
content: @Composable () -> Unit
)
but, this doesn't show full screen but just next item.但是,这不会显示全屏,而是显示下一个项目。 (it's in GridLayout and when I click an item, the dialog needs to shows up to add the item.) (它在 GridLayout 中,当我单击一个项目时,需要显示对话框以添加该项目。)
Could you please help me out?你能帮帮我吗? or any advices?或任何建议?
This should do the trick for a simple full screen popup这应该可以解决简单的全屏弹出窗口
var showPopup by remember { mutableStateOf(false) }
Box(Modifier
.background(Color.Blue)
.fillMaxSize()) {
Button(onClick = { showPopup = true }) {
Text("Show popup")
}
}
if (showPopup) {
Popup(
onDismissRequest = { showPopup = false }
) {
Box(Modifier
.background(Color.Red)
.fillMaxSize()) {
Button(onClick = { showPopup = false },
modifier = Modifier.align(Alignment.Center)) {
Text("Hide popup")
}
}
}
}
Though if you want proper navigation you should probably use this虽然如果你想要正确的导航,你应该使用这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.