Specialize AlertDialog and SimpleDialog (#6098)

We were trying to cram too much functionality in to the Dialog widget. Now we
have AlertDialog and SimpleDialog to cover to two different kinds of dialogs in
the spec.
This commit is contained in:
Adam Barth
2016-09-27 15:44:11 -07:00
committed by GitHub
parent 517ddab3a0
commit dc4a1638ee
11 changed files with 209 additions and 73 deletions

View File

@@ -69,10 +69,10 @@ class DialogDemoState extends State<DialogDemo> {
_selectedTime = new TimeOfDay(hour: now.hour, minute: now.minute);
}
void showDemoDialog/*<T>*/({ BuildContext context, Dialog dialog }) {
void showDemoDialog/*<T>*/({ BuildContext context, Widget child }) {
showDialog/*<T>*/(
context: context,
child: dialog
child: child
)
.then((dynamic/*=T*/ value) { // The value passed to Navigator.pop() or null.
if (value != null) {
@@ -101,7 +101,7 @@ class DialogDemoState extends State<DialogDemo> {
onPressed: () {
showDemoDialog/*<DialogDemoAction>*/(
context: context,
dialog: new Dialog(
child: new AlertDialog(
content: new Text(
_alertWithoutTitleText,
style: dialogTextStyle
@@ -125,7 +125,7 @@ class DialogDemoState extends State<DialogDemo> {
onPressed: () {
showDemoDialog/*<DialogDemoAction>*/(
context: context,
dialog: new Dialog(
child: new AlertDialog(
title: new Text('Use Google\'s location service?'),
content: new Text(
_alertWithTitleText,
@@ -150,30 +150,27 @@ class DialogDemoState extends State<DialogDemo> {
onPressed: () {
showDemoDialog/*<String>*/(
context: context,
dialog: new Dialog(
child: new SimpleDialog(
title: new Text('Set backup account'),
contentPadding: const EdgeInsets.only(top: 12.0, bottom: 16.0),
content: new Column(
children: <Widget>[
new DialogDemoItem(
icon: Icons.account_circle,
color: theme.primaryColor,
text: 'username@gmail.com',
onPressed: () { Navigator.pop(context, 'username@gmail.com'); }
),
new DialogDemoItem(
icon: Icons.account_circle,
color: theme.primaryColor,
text: 'user02@gmail.com',
onPressed: () { Navigator.pop(context, 'user02@gmail.com'); }
),
new DialogDemoItem(
icon: Icons.add_circle,
text: 'add account',
color: theme.disabledColor
)
]
)
children: <Widget>[
new DialogDemoItem(
icon: Icons.account_circle,
color: theme.primaryColor,
text: 'username@gmail.com',
onPressed: () { Navigator.pop(context, 'username@gmail.com'); }
),
new DialogDemoItem(
icon: Icons.account_circle,
color: theme.primaryColor,
text: 'user02@gmail.com',
onPressed: () { Navigator.pop(context, 'user02@gmail.com'); }
),
new DialogDemoItem(
icon: Icons.add_circle,
text: 'add account',
color: theme.disabledColor
)
]
)
);
}

View File

@@ -115,7 +115,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
showDialog(
context: context,
child: new Dialog(
child: new AlertDialog(
content: new Text(
'Discard new event?',
style: dialogTextStyle

View File

@@ -55,7 +55,7 @@ class _PersistentBottomSheetDemoState extends State<PersistentBottomSheetDemo> {
void _showMessage() {
showDialog(
context: context,
child: new Dialog(
child: new AlertDialog(
content: new Text('You tapped the floating action button.'),
actions: <Widget>[
new FlatButton(

View File

@@ -49,7 +49,7 @@ class UpdaterState extends State<Updater> {
final ThemeData theme = Theme.of(context);
final TextStyle dialogTextStyle =
theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
return new Dialog(
return new AlertDialog(
title: new Text('Update Flutter Gallery?'),
content: new Text('A newer version is available.', style: dialogTextStyle),
actions: <Widget>[

View File

@@ -19,7 +19,7 @@ enum StockHomeTab { market, portfolio }
class _NotImplementedDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Dialog(
return new AlertDialog(
title: new Text('Not Implemented'),
content: new Text('This feature has not yet been implemented.'),
actions: <Widget>[

View File

@@ -67,7 +67,7 @@ class StockSettingsState extends State<StockSettings> {
case StockMode.pessimistic:
showDialog(
context: context,
child: new Dialog(
child: new AlertDialog(
title: new Text("Change mode?"),
content: new Text("Optimistic mode means everything is awesome. Are you sure you can handle that?"),
actions: <Widget>[