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,24 +86,24 @@ 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,
children: items.map((item) {
return Text(
'${item["$decKey"]}',
style: TextStyle(fontSize: SizeConfig.textMultiplier *3),
);
}).toList(),
itemExtent: 25, //height of each item // backgroundColor: Colors.black87,
looping: true, children: items.map((item) {
onSelectedItemChanged: (int index) { return Text(
// selectitem =index; '${item["$decKey"]}',
onSelectFun(index); style: TextStyle(fontSize: SizeConfig.textMultiplier * 3),
}, );
), }).toList(),
itemExtent: 25, //height of each item
looping: true,
onSelectedItemChanged: (int index) {
// selectitem =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,23 +83,35 @@ 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(
obscureText: true, focusNode: focusPass,
decoration: buildInputDecoration(context, 'Enter Password', obscureText: true,
'assets/images/password_icon.png'), textInputAction: TextInputAction.next,
validator: (value) { decoration: buildInputDecoration(
if (value.isEmpty) { context, 'Enter Password', 'assets/images/password_icon.png'),
return 'Please enter your Password'; validator: (value) {
} if (value.isEmpty) {
return null; return 'Please enter your Password';
}, }
onSaved: (value) { return null;
userInfo.Password = value; },
}), onSaved: (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,24 +93,37 @@ 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(
maxLength: 1, focusNode: focusD2,
textAlign: TextAlign.center, textInputAction: TextInputAction.next,
style: buildTextStyle(), maxLength: 1,
keyboardType: TextInputType.number, textAlign: TextAlign.center,
decoration: style: buildTextStyle(),
buildInputDecoration(context), keyboardType: TextInputType.number,
onSaved: (val) { decoration:
verifyAccountFormValue['digit2'] = buildInputDecoration(context),
val; onSaved: (val) {
}, verifyAccountFormValue['digit2'] =
validator: validateCodeDigit)), val;
},
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,18 +315,19 @@ 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')
.then((clinicInfo) { .then((clinicInfo) {
ClinicModel clinic = ClinicModel.fromJson(clinicInfo); ClinicModel clinic = ClinicModel.fromJson(clinicInfo);
print(clinicInfo); print(clinicInfo);
getDocProfiles(clinic, changeLoadingStata); getDocProfiles(clinic, changeLoadingStata);
}); });
} }
} else { } else {
changeLoadingStata(false); changeLoadingStata(false);
helpers.showErrorToast(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']);
} }
}).catchError((err) { }).catchError((err) {
@ -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);
@ -375,7 +397,7 @@ class _VerifyAccountState extends State<VerifyAccount> {
print("DoctorProfileList ${res['DoctorProfileList'][0]}"); print("DoctorProfileList ${res['DoctorProfileList'][0]}");
loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata); loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata);
} else { } else {
changeLoadingStata(false); changeLoadingStata(false);
helpers.showErrorToast(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']);
} }
}).catchError((err) { }).catchError((err) {

@ -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