From 610b7d353ffd1dca4c4763141fb07eba12e94f34 Mon Sep 17 00:00:00 2001 From: kangsudal Date: Sat, 9 Nov 2019 19:45:33 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B1=85=20=EC=B6=94=EA=B0=80=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=ED=81=B4=EB=A6=AD=ED=95=98=EB=A9=B4=20=EB=8B=A4?= =?UTF-8?q?=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=EB=A1=9C=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=9E=85=EB=A0=A5=EB=B0=9B=EA=B2=8C=20?= =?UTF-8?q?=EB=A7=8C=EB=93=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/shelfdetailpage.dart | 47 +++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/lib/page/shelfdetailpage.dart b/lib/page/shelfdetailpage.dart index 372fec4..8426745 100644 --- a/lib/page/shelfdetailpage.dart +++ b/lib/page/shelfdetailpage.dart @@ -19,16 +19,53 @@ class _ShelfDetailPageState extends State { ListModel _bookList; dynamic selectedItem; - void _addBook() { - - dynamic element = "new book"; - int index = selectedItem == null ? _bookList.length : _bookList.indexOf(selectedItem); + void _addBook() async { + dynamic newBook = await _asyncInputDialog(context); + print("New book name is $newBook"); + int index = selectedItem == null + ? _bookList.length + : _bookList.indexOf(selectedItem); setState(() { - _bookList.insert(index, element); + _bookList.insert(index, newBook); }); print(_bookList.length); } + Future _asyncInputDialog(BuildContext context) async { + String bookName = ''; + return showDialog( + context: context, + barrierDismissible: + false, // dialog is dismissible with a tap on the barrier + builder: (BuildContext context) { + return AlertDialog( + title: Text('책 추가'), + content: new Row( + children: [ + new Expanded( + child: new TextField( + autofocus: true, + decoration: new InputDecoration( + labelText: '이름', hintText: 'eg. 나의 아름다운 정원'), + onChanged: (value) { + bookName = value; + }, + )) + ], + ), + actions: [ + FlatButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(context).pop(bookName); + }, + ), + ], + ); + }, + ); + } + @override void initState() { super.initState();