From 03a0cd25a5905bb2340c538aed1c6ce719171ade Mon Sep 17 00:00:00 2001 From: Landon Woerdeman Date: Tue, 10 Apr 2018 10:31:24 -0500 Subject: [PATCH] Make full-screen dialog text editable in gallery (#13690) (#15732) Make the full-screen dialog text editable in gallery (#13690) --- .../material/full_screen_dialog_demo.dart | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart b/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart index d44263be53..91d5802741 100644 --- a/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart @@ -106,8 +106,12 @@ class FullScreenDialogDemoState extends State { DateTime _toDateTime = new DateTime.now(); bool _allDayValue = false; bool _saveNeeded = false; + bool _hasLocation = false; + bool _hasName = false; + String _eventName; Future _onWillPop() async { + _saveNeeded = _hasLocation || _hasName || _saveNeeded; if (!_saveNeeded) return true; @@ -147,7 +151,7 @@ class FullScreenDialogDemoState extends State { return new Scaffold( appBar: new AppBar( - title: const Text('New event'), + title: new Text(_hasName ? _eventName : 'Event Name TBD'), actions: [ new FlatButton( child: new Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)), @@ -164,19 +168,38 @@ class FullScreenDialogDemoState extends State { children: [ new Container( padding: const EdgeInsets.symmetric(vertical: 8.0), - decoration: new BoxDecoration( - border: new Border(bottom: new BorderSide(color: theme.dividerColor)) - ), alignment: Alignment.bottomLeft, - child: new Text('Event name', style: theme.textTheme.display2) + child: new TextField( + decoration: const InputDecoration( + labelText: 'Event name', + filled: true + ), + style: theme.textTheme.headline, + onChanged: (String value) { + setState(() { + _hasName = value.isNotEmpty; + if (_hasName) { + _eventName = value; + } + }); + } + ) ), new Container( padding: const EdgeInsets.symmetric(vertical: 8.0), - decoration: new BoxDecoration( - border: new Border(bottom: new BorderSide(color: theme.dividerColor)) - ), alignment: Alignment.bottomLeft, - child: new Text('Location', style: theme.textTheme.title.copyWith(color: Colors.black54)) + child: new TextField( + decoration: const InputDecoration( + labelText: 'Location', + hintText: 'Where is the event?', + filled: true + ), + onChanged: (String value) { + setState(() { + _hasLocation = value.isNotEmpty; + }); + } + ) ), new Column( crossAxisAlignment: CrossAxisAlignment.start,