From 2f171c75d4c8ed007a76b37abf17d66d29460d01 Mon Sep 17 00:00:00 2001 From: harveyjavier Date: Sun, 3 Nov 2019 14:29:25 +0800 Subject: [PATCH] Improve registration UI --- lib/screens/register_one.dart | 8 ----- lib/screens/register_two.dart | 55 +++++++++++++---------------------- 2 files changed, 20 insertions(+), 43 deletions(-) diff --git a/lib/screens/register_one.dart b/lib/screens/register_one.dart index 1b5a77a..a6cd7f0 100644 --- a/lib/screens/register_one.dart +++ b/lib/screens/register_one.dart @@ -29,14 +29,6 @@ class _RegisterOneState extends State { _password_c = new TextEditingController(); _confirm_password_c = new TextEditingController(); super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) => onMount()); - } - - void onMount() { - _email_c.text = storage.getItem("register_data")["email"] != null ? storage.getItem("register_data")["email"] : ""; - _mobile_number_c.text = storage.getItem("register_data")["mobile_number"] != null ? storage.getItem("register_data")["mobile_number"] : ""; - _password_c.text = storage.getItem("register_data")["password"] != null ? storage.getItem("register_data")["password"] : ""; - _confirm_password_c.text = storage.getItem("register_data")["password"] != null ? storage.getItem("register_data")["password"] : ""; } Future _onBack() { diff --git a/lib/screens/register_two.dart b/lib/screens/register_two.dart index d7a3f8b..a840da8 100644 --- a/lib/screens/register_two.dart +++ b/lib/screens/register_two.dart @@ -30,14 +30,6 @@ class _RegisterTwoState extends State { _lastname_c = new TextEditingController(); _birthday_c = new TextEditingController(); super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) => onMount()); - } - - void onMount() { - _username_c.text = storage.getItem("register_data")["username"] != null ? storage.getItem("register_data")["username"] : ""; - _firstname_c.text = storage.getItem("register_data")["firstname"] != null ? storage.getItem("register_data")["firstname"] : ""; - _lastname_c.text = storage.getItem("register_data")["lastname"] != null ? storage.getItem("register_data")["lastname"] : ""; - _birthday_c.text = storage.getItem("register_data")["birthday"] != null ? storage.getItem("register_data")["birthday"] : ""; } @override @@ -141,34 +133,31 @@ class _RegisterTwoState extends State { padding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 30.0), child: TextFormField( controller: _birthday_c, + onTap: () { + DatePicker.showDatePicker(context, + locale: LocaleType.en, + currentTime: DateTime.now(), + maxTime: DateTime.now(), + showTitleActions: true, + theme: DatePickerTheme( + backgroundColor: Colors.black, + itemStyle: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), + doneStyle: TextStyle(color: Colors.white, fontSize: 16), + cancelStyle: TextStyle(color: Colors.white, fontSize: 16), + ), + onConfirm: (date) { + setState(() { + _birthday = formatDate(date, [yyyy, "-", mm, "-", dd]); + _birthday_c.text = formatDate(date, [yyyy, "-", mm, "-", dd]); + }); + }, + ); + }, maxLines: 1, readOnly: true, decoration: InputDecoration( hintText: "Enter your birthday", labelText: "Birthday", - suffixIcon: TextFieldIconButton( - icon: Icons.calendar_today, - onPressed: () { - DatePicker.showDatePicker(context, - locale: LocaleType.en, - currentTime: DateTime.now(), - maxTime: DateTime.now(), - showTitleActions: true, - theme: DatePickerTheme( - backgroundColor: Colors.black, - itemStyle: TextStyle( color: Colors.white, fontWeight: FontWeight.bold), - doneStyle: TextStyle(color: Colors.white, fontSize: 16), - ), - onChanged: (date) { print(formatDate(date, [yyyy, "-", mm, "-", dd])); }, - onConfirm: (date) { - setState(() { - _birthday = formatDate(date, [yyyy, "-", mm, "-", dd]); - _birthday_c.text = formatDate(date, [yyyy, "-", mm, "-", dd]); - }); - }, - ); - }, - ), ), validator: (input) { if (input.isEmpty) @@ -266,10 +255,6 @@ class _RegisterTwoState extends State { ) ); } - setState(() { - _signing_up = false; - _username_matched = false; - }); } } } \ No newline at end of file