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
*/
class Helpers {
int cupertinoPickerIndex = 0;
/*
*@author: Elham Rababah
*@Date:12/4/2020
@ -25,14 +26,58 @@ class Helpers {
*/
showCupertinoPicker(context, items, decKey, onSelectFun) {
showModalBottomSheet(
isDismissible: false,
context: context,
builder: (BuildContext builder) {
return Container(
height: SizeConfig.realScreenHeight * .3,
child: buildPickerItems(context, items, decKey, onSelectFun));
// height: 500,
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
*@Date:12/4/2020
@ -41,24 +86,24 @@ class Helpers {
*@desc: buildPickerIterm this function will build the items of the cupertino
*/
buildPickerItems(context, List items, decKey, onSelectFun) {
return Container(
child: CupertinoPicker(
magnification: 1.5,
// backgroundColor: Colors.black87,
children: items.map((item) {
return Text(
'${item["$decKey"]}',
style: TextStyle(fontSize: SizeConfig.textMultiplier *3),
);
}).toList(),
return CupertinoPicker(
magnification: 1.5,
scrollController: FixedExtentScrollController(initialItem: cupertinoPickerIndex),
itemExtent: 25, //height of each item
looping: true,
onSelectedItemChanged: (int index) {
// selectitem =index;
onSelectFun(index);
},
),
// backgroundColor: Colors.black87,
children: items.map((item) {
return Text(
'${item["$decKey"]}',
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;
}
}
/*
*@author: Elham Rababah
*@Date:12/5/2020
@ -103,15 +149,11 @@ class Helpers {
*@return: String
*@desc: generate Contact Admin Msg
*/
generateContactAdminMsg([err = null]) {
String localMsg = 'Something wrong happened, please contact the admin';
generateContactAdminMsg([err = null]) {
String localMsg = 'Something wrong happened, please contact the admin';
if (err != null) {
localMsg = localMsg +'\n \n'+ err.toString();
localMsg = localMsg + '\n \n' + err.toString();
}
return localMsg;
}
}
}

@ -53,6 +53,9 @@ class _LoginFormState extends State<LoginForm> {
@override
Widget build(BuildContext context) {
final focusPass = FocusNode();
final focusProject = FocusNode();
if (projectsList.length == 0) {
getProjectsList();
}
@ -68,6 +71,7 @@ class _LoginFormState extends State<LoginForm> {
buildSizedBox(),
TextFormField(
keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
decoration: buildInputDecoration(
context, 'Enter ID', 'assets/images/user_id_icon.png'),
validator: (value) {
@ -79,23 +83,35 @@ class _LoginFormState extends State<LoginForm> {
onSaved: (value) {
userInfo.UserID = value;
},
onFieldSubmitted: (_) {
FocusScope.of(context).requestFocus(focusPass);
},
),
buildSizedBox(),
TextFormField(
obscureText: true,
decoration: buildInputDecoration(context, 'Enter Password',
'assets/images/password_icon.png'),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your Password';
}
return null;
},
onSaved: (value) {
userInfo.Password = value;
}),
focusNode: focusPass,
obscureText: true,
textInputAction: TextInputAction.next,
decoration: buildInputDecoration(
context, 'Enter Password', 'assets/images/password_icon.png'),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your Password';
}
return null;
},
onSaved: (value) {
userInfo.Password = value;
},
onFieldSubmitted: (_) {
FocusScope.of(context).requestFocus(focusProject);
helpers.showCupertinoPicker(
context, projectsList, 'Name', onSelectProject);
},
),
buildSizedBox(),
TextFormField(
focusNode: focusProject,
controller: projectIdController,
onTap: () {
helpers.showCupertinoPicker(
@ -312,7 +328,7 @@ class _LoginFormState extends State<LoginForm> {
onSelectProject(index) {
setState(() {
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
Widget build(BuildContext context) {
authProv = Provider.of<AuthProvider>(context);
final focusD1 = FocusNode();
final focusD2 = FocusNode();
final focusD3 = FocusNode();
final focusD4 = FocusNode();
return FutureBuilder(
future: Future.wait([_loggedUserFuture]),
builder: (BuildContext context, AsyncSnapshot snapshot) {
@ -78,6 +81,7 @@ class _VerifyAccountState extends State<VerifyAccount> {
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
textInputAction: TextInputAction.next,
style: buildTextStyle(),
maxLength: 1,
textAlign: TextAlign.center,
@ -89,24 +93,37 @@ class _VerifyAccountState extends State<VerifyAccount> {
val;
},
validator: validateCodeDigit,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD2);
},
)),
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration:
buildInputDecoration(context),
onSaved: (val) {
verifyAccountFormValue['digit2'] =
val;
},
validator: validateCodeDigit)),
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
focusNode: focusD2,
textInputAction: TextInputAction.next,
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration:
buildInputDecoration(context),
onSaved: (val) {
verifyAccountFormValue['digit2'] =
val;
},
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD3);
},
validator: validateCodeDigit),
),
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
focusNode: focusD3,
textInputAction: TextInputAction.next,
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
@ -116,11 +133,15 @@ class _VerifyAccountState extends State<VerifyAccount> {
onSaved: (val) {
verifyAccountFormValue['digit3'] =
val;
},
},onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD4);
},
validator: validateCodeDigit)),
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
focusNode: focusD4,
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
@ -294,18 +315,19 @@ class _VerifyAccountState extends State<VerifyAccount> {
if (res['MessageStatus'] == 1) {
sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
if (res['List_DoctorProfile'] != null) {
loginProcessCompleted(res['List_DoctorProfile'][0],changeLoadingStata);
loginProcessCompleted(
res['List_DoctorProfile'][0], changeLoadingStata);
} else {
_asyncSimpleDialog(context, res['List_DoctorsClinic'], 'ClinicName',
'Please Select Clinic')
.then((clinicInfo) {
ClinicModel clinic = ClinicModel.fromJson(clinicInfo);
print(clinicInfo);
getDocProfiles(clinic, changeLoadingStata);
getDocProfiles(clinic, changeLoadingStata);
});
}
} else {
changeLoadingStata(false);
changeLoadingStata(false);
helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
@ -319,7 +341,6 @@ class _VerifyAccountState extends State<VerifyAccount> {
}
}
/*
*@author: Elham Rababah
*@Date:17/5/2020
@ -327,7 +348,8 @@ class _VerifyAccountState extends State<VerifyAccount> {
*@return:
*@desc: loginProcessCompleted
*/
loginProcessCompleted(Map<String, dynamic> profile, Function changeLoadingStata) {
loginProcessCompleted(
Map<String, dynamic> profile, Function changeLoadingStata) {
changeLoadingStata(false);
sharedPref.setObj(DOCTOR_PROFILE, profile);
Navigator.of(context).pushNamed(HOME);
@ -375,7 +397,7 @@ class _VerifyAccountState extends State<VerifyAccount> {
print("DoctorProfileList ${res['DoctorProfileList'][0]}");
loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata);
} else {
changeLoadingStata(false);
changeLoadingStata(false);
helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {

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

Loading…
Cancel
Save