1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| @Composable fun AlertDialogSample2() { MaterialTheme { Column( Modifier .fillMaxSize() .wrapContentSize(Alignment.Center) ) { val openDialog = remember { mutableStateOf(false) } Button(onClick = { openDialog.value = true }) { Text(text = "弹出提示框") } if (openDialog.value) { AlertDialog( onDismissRequest = { openDialog.value = false }, title = { Text( text = "开启位置服务", fontWeight = FontWeight.W700, style = MaterialTheme.typography.h6 ) }, text = { Text( text = "这将意味着,我们会给您提供精准的位置服务,并且您将接受关于您订阅的位置信息", fontSize = 16.sp ) }, confirmButton = { TextButton( onClick = { openDialog.value = false }, ) { Text( "确认", fontWeight = FontWeight.W700, style = MaterialTheme.typography.button ) } }, dismissButton = { TextButton( onClick = { openDialog.value = false } ) { Text( "取消", fontWeight = FontWeight.W700, style = MaterialTheme.typography.button ) } }) } } } }
|