add focus to input and fix cupertino picker

merge-requests/68/head
Elham Rababah 6 years ago
parent 0670360af8
commit f4b62a6158

@ -16,6 +16,7 @@ DrAppToastMsg toastMsg = DrAppToastMsg();
*@desc: This class will contian some Function will help developer *@desc: This class will contian some Function will help developer
*/ */
class Helpers { class Helpers {
int cupertinoPickerIndex = 0;
/* /*
*@author: Elham Rababah *@author: Elham Rababah
*@Date:12/4/2020 *@Date:12/4/2020
@ -25,14 +26,58 @@ class Helpers {
*/ */
showCupertinoPicker(context, items, decKey, onSelectFun) { showCupertinoPicker(context, items, decKey, onSelectFun) {
showModalBottomSheet( showModalBottomSheet(
isDismissible: false,
context: context, context: context,
builder: (BuildContext builder) { builder: (BuildContext builder) {
return Container( return Container(
height: SizeConfig.realScreenHeight * .3, // height: 500,
child: buildPickerItems(context, items, decKey, onSelectFun)); height: SizeConfig.realScreenHeight * 0.4,
color: Color(0xfff7f7f7),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
color: Color(0xfff7f7f7),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
CupertinoButton(
child: Text('Cancel'.toUpperCase(), style: textStyle(context)),
onPressed: () {
Navigator.pop(context);
},
// padding: const EdgeInsets.symmetric(
// horizontal: 16.0,
// vertical: 5.0,
// ),
),
CupertinoButton(
child: Text(
'Done'.toUpperCase(),
style: textStyle(context),
),
onPressed: () {
Navigator.pop(context);
onSelectFun(cupertinoPickerIndex);
},
)
],
),
),
Container(
height: SizeConfig.realScreenHeight * 0.3,
color: Color(0xfff7f7f7),
child:
buildPickerItems(context, items, decKey, onSelectFun))
],
),
);
}); });
} }
TextStyle textStyle(context) =>
TextStyle(color: Theme.of(context).primaryColor);
/* /*
*@author: Elham Rababah *@author: Elham Rababah
*@Date:12/4/2020 *@Date:12/4/2020
@ -41,14 +86,15 @@ class Helpers {
*@desc: buildPickerIterm this function will build the items of the cupertino *@desc: buildPickerIterm this function will build the items of the cupertino
*/ */
buildPickerItems(context, List items, decKey, onSelectFun) { buildPickerItems(context, List items, decKey, onSelectFun) {
return Container( return CupertinoPicker(
child: CupertinoPicker(
magnification: 1.5, magnification: 1.5,
scrollController: FixedExtentScrollController(initialItem: cupertinoPickerIndex),
// backgroundColor: Colors.black87, // backgroundColor: Colors.black87,
children: items.map((item) { children: items.map((item) {
return Text( return Text(
'${item["$decKey"]}', '${item["$decKey"]}',
style: TextStyle(fontSize: SizeConfig.textMultiplier *3), style: TextStyle(fontSize: SizeConfig.textMultiplier * 3),
); );
}).toList(), }).toList(),
@ -56,9 +102,8 @@ class Helpers {
looping: true, looping: true,
onSelectedItemChanged: (int index) { onSelectedItemChanged: (int index) {
// selectitem =index; // selectitem =index;
onSelectFun(index); cupertinoPickerIndex = index;
}, },
),
); );
} }
@ -96,6 +141,7 @@ class Helpers {
return false; return false;
} }
} }
/* /*
*@author: Elham Rababah *@author: Elham Rababah
*@Date:12/5/2020 *@Date:12/5/2020
@ -103,15 +149,11 @@ class Helpers {
*@return: String *@return: String
*@desc: generate Contact Admin Msg *@desc: generate Contact Admin Msg
*/ */
generateContactAdminMsg([err = null]) { generateContactAdminMsg([err = null]) {
String localMsg = 'Something wrong happened, please contact the admin'; String localMsg = 'Something wrong happened, please contact the admin';
if (err != null) { if (err != null) {
localMsg = localMsg +'\n \n'+ err.toString(); localMsg = localMsg + '\n \n' + err.toString();
} }
return localMsg; return localMsg;
}
}
} }

@ -53,6 +53,9 @@ class _LoginFormState extends State<LoginForm> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final focusPass = FocusNode();
final focusProject = FocusNode();
if (projectsList.length == 0) { if (projectsList.length == 0) {
getProjectsList(); getProjectsList();
} }
@ -68,6 +71,7 @@ class _LoginFormState extends State<LoginForm> {
buildSizedBox(), buildSizedBox(),
TextFormField( TextFormField(
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
decoration: buildInputDecoration( decoration: buildInputDecoration(
context, 'Enter ID', 'assets/images/user_id_icon.png'), context, 'Enter ID', 'assets/images/user_id_icon.png'),
validator: (value) { validator: (value) {
@ -79,12 +83,17 @@ class _LoginFormState extends State<LoginForm> {
onSaved: (value) { onSaved: (value) {
userInfo.UserID = value; userInfo.UserID = value;
}, },
onFieldSubmitted: (_) {
FocusScope.of(context).requestFocus(focusPass);
},
), ),
buildSizedBox(), buildSizedBox(),
TextFormField( TextFormField(
focusNode: focusPass,
obscureText: true, obscureText: true,
decoration: buildInputDecoration(context, 'Enter Password', textInputAction: TextInputAction.next,
'assets/images/password_icon.png'), decoration: buildInputDecoration(
context, 'Enter Password', 'assets/images/password_icon.png'),
validator: (value) { validator: (value) {
if (value.isEmpty) { if (value.isEmpty) {
return 'Please enter your Password'; return 'Please enter your Password';
@ -93,9 +102,16 @@ class _LoginFormState extends State<LoginForm> {
}, },
onSaved: (value) { onSaved: (value) {
userInfo.Password = value; userInfo.Password = value;
}), },
onFieldSubmitted: (_) {
FocusScope.of(context).requestFocus(focusProject);
helpers.showCupertinoPicker(
context, projectsList, 'Name', onSelectProject);
},
),
buildSizedBox(), buildSizedBox(),
TextFormField( TextFormField(
focusNode: focusProject,
controller: projectIdController, controller: projectIdController,
onTap: () { onTap: () {
helpers.showCupertinoPicker( helpers.showCupertinoPicker(
@ -312,7 +328,7 @@ class _LoginFormState extends State<LoginForm> {
onSelectProject(index) { onSelectProject(index) {
setState(() { setState(() {
userInfo.ProjectID = projectsList[index]["ID"]; userInfo.ProjectID = projectsList[index]["ID"];
projectIdController.text = projectsList[index]['Desciption']; projectIdController.text = projectsList[index]['Name'];
}); });
} }
} }

@ -51,7 +51,10 @@ class _VerifyAccountState extends State<VerifyAccount> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
authProv = Provider.of<AuthProvider>(context); authProv = Provider.of<AuthProvider>(context);
final focusD1 = FocusNode();
final focusD2 = FocusNode();
final focusD3 = FocusNode();
final focusD4 = FocusNode();
return FutureBuilder( return FutureBuilder(
future: Future.wait([_loggedUserFuture]), future: Future.wait([_loggedUserFuture]),
builder: (BuildContext context, AsyncSnapshot snapshot) { builder: (BuildContext context, AsyncSnapshot snapshot) {
@ -78,6 +81,7 @@ class _VerifyAccountState extends State<VerifyAccount> {
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
textInputAction: TextInputAction.next,
style: buildTextStyle(), style: buildTextStyle(),
maxLength: 1, maxLength: 1,
textAlign: TextAlign.center, textAlign: TextAlign.center,
@ -89,10 +93,16 @@ class _VerifyAccountState extends State<VerifyAccount> {
val; val;
}, },
validator: validateCodeDigit, validator: validateCodeDigit,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD2);
},
)), )),
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
focusNode: focusD2,
textInputAction: TextInputAction.next,
maxLength: 1, maxLength: 1,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: buildTextStyle(), style: buildTextStyle(),
@ -103,10 +113,17 @@ class _VerifyAccountState extends State<VerifyAccount> {
verifyAccountFormValue['digit2'] = verifyAccountFormValue['digit2'] =
val; val;
}, },
validator: validateCodeDigit)), onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD3);
},
validator: validateCodeDigit),
),
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
focusNode: focusD3,
textInputAction: TextInputAction.next,
maxLength: 1, maxLength: 1,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: buildTextStyle(), style: buildTextStyle(),
@ -116,11 +133,15 @@ class _VerifyAccountState extends State<VerifyAccount> {
onSaved: (val) { onSaved: (val) {
verifyAccountFormValue['digit3'] = verifyAccountFormValue['digit3'] =
val; val;
},onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD4);
}, },
validator: validateCodeDigit)), validator: validateCodeDigit)),
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
focusNode: focusD4,
maxLength: 1, maxLength: 1,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: buildTextStyle(), style: buildTextStyle(),
@ -294,7 +315,8 @@ class _VerifyAccountState extends State<VerifyAccount> {
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
sharedPref.setString(TOKEN, res['AuthenticationTokenID']); sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
if (res['List_DoctorProfile'] != null) { if (res['List_DoctorProfile'] != null) {
loginProcessCompleted(res['List_DoctorProfile'][0],changeLoadingStata); loginProcessCompleted(
res['List_DoctorProfile'][0], changeLoadingStata);
} else { } else {
_asyncSimpleDialog(context, res['List_DoctorsClinic'], 'ClinicName', _asyncSimpleDialog(context, res['List_DoctorsClinic'], 'ClinicName',
'Please Select Clinic') 'Please Select Clinic')
@ -319,7 +341,6 @@ class _VerifyAccountState extends State<VerifyAccount> {
} }
} }
/* /*
*@author: Elham Rababah *@author: Elham Rababah
*@Date:17/5/2020 *@Date:17/5/2020
@ -327,7 +348,8 @@ class _VerifyAccountState extends State<VerifyAccount> {
*@return: *@return:
*@desc: loginProcessCompleted *@desc: loginProcessCompleted
*/ */
loginProcessCompleted(Map<String, dynamic> profile, Function changeLoadingStata) { loginProcessCompleted(
Map<String, dynamic> profile, Function changeLoadingStata) {
changeLoadingStata(false); changeLoadingStata(false);
sharedPref.setObj(DOCTOR_PROFILE, profile); sharedPref.setObj(DOCTOR_PROFILE, profile);
Navigator.of(context).pushNamed(HOME); Navigator.of(context).pushNamed(HOME);

@ -150,7 +150,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
top: SizeConfig.heightMultiplier * 0.5), top: SizeConfig.heightMultiplier * 0.5),
child: Image.asset( child: Image.asset(
url, url,
height: SizeConfig.heightMultiplier * 11, height: SizeConfig.heightMultiplier * 10,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),

Loading…
Cancel
Save