Ahmet Delibaş
03/09/2021, 8:10 AMUtkarsh Tiwari
03/09/2021, 9:17 AMAlertDialog(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight(),
// .... other required params
)
Ahmet Delibaş
03/09/2021, 11:15 AMUtkarsh Tiwari
03/09/2021, 12:32 PMAhmet Delibaş
03/09/2021, 1:45 PM@Composable
fun AlertDialogSample(modifier: Modifier, onCancel: () -> Unit, onConfirm: () -> Unit) {
Column(
modifier = modifier
.background(descriptionTypingBackground)
.fillMaxSize()
.clickable { },
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
AlertDialog(
onDismissRequest = {},
title = {
Row(
modifier = modifier
.fillMaxWidth()
.height(56.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.Bottom
) {
Text(
text = stringResource(id = R.string.do_you_want_to_exit),
textAlign = TextAlign.Center,
modifier = modifier.height(24.dp)
)
}
},
buttons = {
Row(
modifier
.fillMaxWidth()
.height(72.dp)
.padding(top = 24.dp, bottom = 8.dp),
verticalAlignment = Alignment.Bottom
) {
ConstraintLayout(
modifier = modifier
.fillMaxWidth()
.height(40.dp)
) {
val (leftButton, rightButton) = createRefs()
val half = createGuidelineFromStart(0.5f)
Button(
onClick = {
onCancel.invoke()
},
modifier = modifier.constrainAs(leftButton) {
start.linkTo(parent.start, 8.dp)
top.linkTo(<http://parent.top|parent.top>)
bottom.linkTo(parent.bottom)
end.linkTo(half, 4.dp)
width = Dimension.fillToConstraints
height = Dimension.fillToConstraints
},
shape = RoundedCornerShape(20.dp)
) {
Text(
text = stringResource(id = R.string.Cancel),
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
)
}
Button(
onClick = {
onConfirm.invoke()
},
modifier = modifier
.constrainAs(rightButton) {
start.linkTo(half, 4.dp)
top.linkTo(<http://parent.top|parent.top>)
bottom.linkTo(parent.bottom)
end.linkTo(parent.end, 8.dp)
width = Dimension.fillToConstraints
height = Dimension.fillToConstraints
},
shape = RoundedCornerShape(20.dp)
) {
Text(
text = stringResource(id = R.string.ok),
fontSize = 16.sp,
fontWeight = FontWeight.Medium
)
}
}
}
},
shape = RoundedCornerShape(20.dp),
backgroundColor = surfaceColor,
modifier = modifier.fillMaxWidth()
)
}
}
Utkarsh Tiwari
03/10/2021, 11:41 AMAhmet Delibaş
03/10/2021, 11:56 AM