shadcn_ui-dialog
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShadcn UI — Dialog
Shadcn UI — 对话框
Instructions
使用说明
A modal dialog that interrupts the user. Use and return a or . Provide , optional , optional (list of widgets, e.g. buttons), and optional for body content. Dismiss with .
showShadDialog(context: context, builder: ...)ShadDialogShadDialog.alerttitledescriptionactionschildNavigator.of(context).pop(...)一种会打断用户操作的模态对话框。使用并返回或。需提供(标题),可选的(描述)、(组件列表,如按钮),以及用于主体内容的可选。通过关闭对话框。
showShadDialog(context: context, builder: ...)ShadDialogShadDialog.alerttitledescriptionactionschildNavigator.of(context).pop(...)Standard dialog
标准对话框
dart
showShadDialog(
context: context,
builder: (context) => ShadDialog(
title: const Text('Edit Profile'),
description: const Text(
"Make changes to your profile here. Click save when you're done",
),
actions: const [ShadButton(child: Text('Save changes'))],
child: Container(
width: 375,
padding: const EdgeInsets.symmetric(vertical: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
spacing: 16,
children: profile
.map(
(p) => Row(
children: [
Expanded(
child: Text(
p.title,
textAlign: TextAlign.end,
style: theme.textTheme.small,
),
),
const SizedBox(width: 16),
Expanded(
flex: 3,
child: ShadInput(initialValue: p.value),
),
],
),
)
.toList(),
),
),
),
);dart
showShadDialog(
context: context,
builder: (context) => ShadDialog(
title: const Text('Edit Profile'),
description: const Text(
"Make changes to your profile here. Click save when you're done",
),
actions: const [ShadButton(child: Text('Save changes'))],
child: Container(
width: 375,
padding: const EdgeInsets.symmetric(vertical: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
spacing: 16,
children: profile
.map(
(p) => Row(
children: [
Expanded(
child: Text(
p.title,
textAlign: TextAlign.end,
style: theme.textTheme.small,
),
),
const SizedBox(width: 16),
Expanded(
flex: 3,
child: ShadInput(initialValue: p.value),
),
],
),
)
.toList(),
),
),
),
);Alert dialog
警告对话框
Use for confirmations; pass with Cancel and Continue (or similar) that call and .
ShadDialog.alertactionsNavigator.of(context).pop(false)Navigator.of(context).pop(true)dart
showShadDialog(
context: context,
builder: (context) => ShadDialog.alert(
title: const Text('Are you absolutely sure?'),
description: const Padding(
padding: EdgeInsets.only(bottom: 8),
child: Text(
'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
),
),
actions: [
ShadButton.outline(
child: const Text('Cancel'),
onPressed: () => Navigator.of(context).pop(false),
),
ShadButton(
child: const Text('Continue'),
onPressed: () => Navigator.of(context).pop(true),
),
],
),
);使用实现确认功能;传入包含Cancel(取消)和Continue(继续)等按钮的,分别调用和。
ShadDialog.alertactionsNavigator.of(context).pop(false)Navigator.of(context).pop(true)dart
showShadDialog(
context: context,
builder: (context) => ShadDialog.alert(
title: const Text('Are you absolutely sure?'),
description: const Padding(
padding: EdgeInsets.only(bottom: 8),
child: Text(
'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
),
),
actions: [
ShadButton.outline(
child: const Text('Cancel'),
onPressed: () => Navigator.of(context).pop(false),
),
ShadButton(
child: const Text('Continue'),
onPressed: () => Navigator.of(context).pop(true),
),
],
),
);