From 1abdf8e721ce0d789f82a0b70158a89b3eac61a0 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 22 Mar 2020 16:34:52 +0200 Subject: [PATCH] improve dropdown design in login page --- lib/screens/auth/login_screen.dart | 8 --- lib/widgets/auth/login_form.dart | 111 +++++++++++++---------------- 2 files changed, 51 insertions(+), 68 deletions(-) diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index e88acb3a..61d989df 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -21,14 +21,7 @@ class _LoginsreenState extends State { Future getSharedPref() async { final SharedPreferences prefs = await _prefs; - final int counter = (prefs.getInt('counter') ?? 0) + 1; platformImei = prefs.getString('platformImei'); - // setState(() { - print(platformImei); - prefs.setInt("counter", counter).then((bool success) { - return counter; - // }); - }); } @override @@ -41,7 +34,6 @@ class _LoginsreenState extends State { @override Widget build(BuildContext context) { - // prefs.setInt("counter", 1); getSharedPref(); return Scaffold( backgroundColor: Colors.white, diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index abc969e7..e15622ac 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -128,58 +128,48 @@ class _LoginFormState extends State { SizedBox( height: 20, ), - // TextFormField( - // decoration: InputDecoration( - // prefixIcon: Image.asset('assets/images/hospital_icon.png'), - // hintText: 'Select Project', - // hintStyle: TextStyle( - // fontSize: - // isSmallScreen ? 14 : constraints.maxWidth * 0.024), - // enabledBorder: OutlineInputBorder( - // borderRadius: BorderRadius.all(Radius.circular(20)), - // borderSide: BorderSide(color: Hexcolor('#CCCCCC')), - // ), - // focusedBorder: OutlineInputBorder( - // borderRadius: BorderRadius.all(Radius.circular(10.0)), - // borderSide: - // BorderSide(color: Theme.of(context).primaryColor), - // ) - // //BorderRadius.all(Radius.circular(20)); - // ), - // validator: (value) { - // if (value.isEmpty) { - // return 'Please enter some text'; - // } - // return null; - // }, - // ), - // - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - // border: Border.all(color: Theme.of(context).primaryColor), - ), - width: double.infinity, - child: DropdownButton( + DropdownButtonFormField( value: userInfo.ProjectID, - iconSize: 24, - elevation: 16, - selectedItemBuilder: (BuildContext context) { - return projectsList.map((item) { - return Text(item['Desciption']); - }).toList(); + isExpanded: false, + decoration: InputDecoration( + contentPadding: EdgeInsets.all(10), + isDense: true, + prefixIcon: + Image.asset('assets/images/hospital_icon.png'), + // hintText: 'Enter Password', + hintStyle: TextStyle( + fontSize: isSmallScreen + ? 14 + : constraints.maxWidth * 0.024), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: + BorderSide(color: Theme.of(context).primaryColor), + ) + //BorderRadius.all(Radius.circular(20)); + ), + validator: (value) { + print(value); + if (value == null) { + return 'Please enter some text'; + } + return null; }, items: projectsList.map((item) { return DropdownMenuItem( - child: Text('${item['Desciption']}'), + child: Text( + '${item['Desciption']}', + ), value: item['ID'], ); }).toList(), - onChanged: (val) { - userInfo.ProjectID = val; - }, - ), - ), + onChanged: (value) { + userInfo.ProjectID = value; + }), SizedBox( height: 20, @@ -241,21 +231,22 @@ class _LoginFormState extends State { } login(context, AuthProvider authProv) { - loginFormKey.currentState.validate(); - loginFormKey.currentState.save(); - authProv.login(userInfo).then((res) { - if (res['MessageStatus'] == 1) { - insertDeviceImei(res, authProv); - } else { - // handel error - // widget.showCenterShortLoadingToast("watting"); - showLoginError(res['ErrorEndUserMessage']); - } - // Navigator.of(context).pushNamed(HOME); - }).catchError((err) { - print('$err'); - showLoginError(); - }); + if (loginFormKey.currentState.validate()) { + loginFormKey.currentState.save(); + authProv.login(userInfo).then((res) { + if (res['MessageStatus'] == 1) { + insertDeviceImei(res, authProv); + } else { + // handel error + // widget.showCenterShortLoadingToast("watting"); + showLoginError(res['ErrorEndUserMessage']); + } + // Navigator.of(context).pushNamed(HOME); + }).catchError((err) { + print('$err'); + showLoginError(); + }); + } } insertDeviceImei(res, AuthProvider authProv) {