Add CupertinoActionSheet to gallery (#20411)
This commit is contained in:
parent
fa5374e871
commit
faffd3aef3
@ -3,8 +3,8 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
export 'cupertino_activity_indicator_demo.dart';
|
export 'cupertino_activity_indicator_demo.dart';
|
||||||
|
export 'cupertino_alert_demo.dart';
|
||||||
export 'cupertino_buttons_demo.dart';
|
export 'cupertino_buttons_demo.dart';
|
||||||
export 'cupertino_dialog_demo.dart';
|
|
||||||
export 'cupertino_navigation_demo.dart';
|
export 'cupertino_navigation_demo.dart';
|
||||||
export 'cupertino_picker_demo.dart';
|
export 'cupertino_picker_demo.dart';
|
||||||
export 'cupertino_refresh_demo.dart';
|
export 'cupertino_refresh_demo.dart';
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CupertinoDialogDemo extends StatefulWidget {
|
class CupertinoAlertDemo extends StatefulWidget {
|
||||||
static const String routeName = '/cupertino/dialog';
|
static const String routeName = '/cupertino/alert';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_CupertinoDialogDemoState createState() => new _CupertinoDialogDemoState();
|
_CupertinoAlertDemoState createState() => new _CupertinoAlertDemoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
|
class _CupertinoAlertDemoState extends State<CupertinoAlertDemo> {
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
void showDemoDialog<T>({BuildContext context, Widget child}) {
|
void showDemoDialog<T>({BuildContext context, Widget child}) {
|
||||||
@ -32,12 +32,27 @@ class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showDemoActionSheet<T>({BuildContext context, Widget child}) {
|
||||||
|
showCupertinoModalPopup<T>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) => child,
|
||||||
|
).then<void>((T value) {
|
||||||
|
if (value != null) {
|
||||||
|
_scaffoldKey.currentState.showSnackBar(
|
||||||
|
new SnackBar(
|
||||||
|
content: new Text('You selected: $value'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Scaffold(
|
return new Scaffold(
|
||||||
key: _scaffoldKey,
|
key: _scaffoldKey,
|
||||||
appBar: new AppBar(
|
appBar: new AppBar(
|
||||||
title: const Text('Cupertino Dialogs'),
|
title: const Text('Cupertino Alerts'),
|
||||||
),
|
),
|
||||||
body: new ListView(
|
body: new ListView(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
|
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
|
||||||
@ -129,6 +144,48 @@ class _CupertinoDialogDemoState extends State<CupertinoDialogDemo> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const Padding(padding: EdgeInsets.all(8.0)),
|
||||||
|
new CupertinoButton(
|
||||||
|
child: const Text('Action Sheet'),
|
||||||
|
color: CupertinoColors.activeBlue,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0),
|
||||||
|
onPressed: () {
|
||||||
|
showDemoActionSheet<String>(
|
||||||
|
context: context,
|
||||||
|
child: new CupertinoActionSheet(
|
||||||
|
title: const Text('Favorite Dessert'),
|
||||||
|
message: const Text('Please select the best dessert from the options below.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
new CupertinoActionSheetAction(
|
||||||
|
child: const Text('Profiteroles'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context, 'Profiteroles');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
new CupertinoActionSheetAction(
|
||||||
|
child: const Text('Cannolis'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context, 'Cannolis');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
new CupertinoActionSheetAction(
|
||||||
|
child: const Text('Trifle'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context, 'Trifle');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
cancelButton: new CupertinoActionSheetAction(
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
isDefaultAction: true,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context, 'Cancel');
|
||||||
|
},
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
@ -402,11 +402,11 @@ List<GalleryDemo> _buildGalleryDemos() {
|
|||||||
buildRoute: (BuildContext context) => new CupertinoButtonsDemo(),
|
buildRoute: (BuildContext context) => new CupertinoButtonsDemo(),
|
||||||
),
|
),
|
||||||
new GalleryDemo(
|
new GalleryDemo(
|
||||||
title: 'Dialogs',
|
title: 'Alerts',
|
||||||
icon: GalleryIcons.dialogs,
|
icon: GalleryIcons.dialogs,
|
||||||
category: _kCupertinoComponents,
|
category: _kCupertinoComponents,
|
||||||
routeName: CupertinoDialogDemo.routeName,
|
routeName: CupertinoAlertDemo.routeName,
|
||||||
buildRoute: (BuildContext context) => new CupertinoDialogDemo(),
|
buildRoute: (BuildContext context) => new CupertinoAlertDemo(),
|
||||||
),
|
),
|
||||||
new GalleryDemo(
|
new GalleryDemo(
|
||||||
title: 'Navigation',
|
title: 'Navigation',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user