fix login

merge-requests/709/head
Elham Rababah 5 years ago
parent 362d9425cd
commit 8f6de2e02b

@ -13,7 +13,6 @@ import 'package:provider/provider.dart';
import '../../widgets/shared/app_scaffold_widget.dart';
class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
@ -35,6 +34,7 @@ class _LoginScreenState extends State<LoginScreen> {
@override
Widget build(BuildContext context) {
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
double textFieldHeight = SizeConfig.heightMultiplier * (SizeConfig.isHeightShort ?10:6);
return AppScaffold(
isShowAppBar: false,
backgroundColor: HexColor('#F8F8F8'),
@ -49,124 +49,100 @@ class _LoginScreenState extends State<LoginScreen> {
//TODO Use App Text rather than text
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
SizedBox(
height: 30,
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 10,
),
Text(
TranslationBase
.of(context)
.welcomeTo,
TranslationBase.of(context).welcomeTo,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight
.w600,
fontSize: SizeConfig
.getTextMultiplierBasedOnWidth() *
4,
fontWeight: FontWeight.w600,
fontFamily: 'Poppins'),
),
Text(
TranslationBase
.of(context)
.drSulaimanAlHabib,
TranslationBase.of(context).drSulaimanAlHabib,
style: TextStyle(
color: Color(0xFF2B353E),
fontWeight: FontWeight
.bold,
fontSize: 24,
fontWeight: FontWeight.bold,
fontSize: SizeConfig
.getTextMultiplierBasedOnWidth() *
6,
fontFamily: 'Poppins'),
),
Text(
"Doctor App",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight
.w600,
fontSize: SizeConfig
.getTextMultiplierBasedOnWidth() *
4,
fontWeight: FontWeight.w600,
color: Color(0xFFD02127)),
),
]),
],
)),
])),
SizedBox(
height: 40,
),
Form(
key: loginFormKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
buildSizedBox(),
AppTextFieldCustom(
hintText: TranslationBase.of(context).enterId,
hasBorder: true,
controller: userIdController,
onChanged: (value){
if (value != null)
setState(() {
authenticationViewModel.userInfo
.userID =
value
.trim();
});
},
),
buildSizedBox(),
AppTextFieldCustom(
hintText: TranslationBase.of(context).enterPassword,
hasBorder: true,
isSecure: true,
controller: passwordController,
onChanged: (value){
if (value != null)
setState(() {
authenticationViewModel.userInfo
.password =
value
.trim();
});
this.getProjects(
authenticationViewModel.userInfo
.userID);
},
onClick: (){
},
),
buildSizedBox(),
AppTextFieldCustom(
hintText: TranslationBase.of(context).selectYourProject,
hasBorder: true,
controller: projectIdController,
isTextFieldHasSuffix: true,
enabled: false,
onClick: (){
Helpers
.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject,
authenticationViewModel);
},
),
buildSizedBox(),
]),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildSizedBox(),
AppTextFieldCustom(
height: textFieldHeight,
hintText: TranslationBase.of(context).enterId,
hasBorder: true,
controller: userIdController,
onChanged: (value) {
if (value != null)
setState(() {
authenticationViewModel.userInfo.userID =
value.trim();
});
},
),
buildSizedBox(),
AppTextFieldCustom(
height: textFieldHeight,
hintText: TranslationBase.of(context).enterPassword,
hasBorder: true,
isSecure: true,
controller: passwordController,
onChanged: (value) {
if (value != null)
setState(() {
authenticationViewModel.userInfo.password =
value.trim();
});
this.getProjects(
authenticationViewModel.userInfo.userID);
},
onClick: () {},
),
buildSizedBox(),
AppTextFieldCustom(
height: textFieldHeight,
hintText:
TranslationBase.of(context).selectYourProject,
hasBorder: true,
controller: projectIdController,
isTextFieldHasSuffix: true,
enabled: false,
onClick: projectsList.isEmpty== null ? null:() {
Helpers.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject,
authenticationViewModel);
},
),
buildSizedBox(),
]),
),
SizedBox(
height: 40,
@ -176,46 +152,47 @@ class _LoginScreenState extends State<LoginScreen> {
),
),
bottomSheet: Container(
height: 85,
// color: Colors.green,
height: SizeConfig.heightMultiplier * 10,
width: double.infinity,
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AppButton(
title: TranslationBase
.of(context)
.login,
height: SizeConfig.heightMultiplier *
(SizeConfig.isHeightShort ? 8 : 6),
hPadding: 1,
title: TranslationBase.of(context).login,
color: Color(0xFFD02127),
fontWeight: FontWeight.w700,
disabled: authenticationViewModel.userInfo
.userID == null ||
authenticationViewModel.userInfo
.password ==
null,
disabled: authenticationViewModel.userInfo.userID == null ||
authenticationViewModel.userInfo.password == null,
onPressed: () {
login(context);
},
),
SizedBox(height: 25,)
// SizedBox(height: SizeConfig.heightMultiplier * (SizeConfig.isHeightShort? 1 : 3),)
],
),
),
),),
),
),
);
}
SizedBox buildSizedBox() {
return SizedBox(
height: 20,
height: SizeConfig.heightMultiplier * 2,
);
}
login(context,) async {
login(
context,
) async {
if (loginFormKey.currentState.validate()) {
loginFormKey.currentState.save();
GifLoaderDialogUtils.showMyDialog(context);
@ -225,29 +202,32 @@ class _LoginScreenState extends State<LoginScreen> {
Helpers.showErrorToast(authenticationViewModel.error);
} else {
GifLoaderDialogUtils.hideDialog(context);
authenticationViewModel.setUnverified(true,isFromLogin: true);
authenticationViewModel.setUnverified(true, isFromLogin: true);
}
}
}
onSelectProject(index) {
setState(() {
authenticationViewModel.userInfo.projectID = projectsList[index].facilityId;
authenticationViewModel.userInfo.projectID =
projectsList[index].facilityId;
projectIdController.text = projectsList[index].facilityName;
});
primaryFocus.unfocus();
}
String memberID ="";
getProjects(memberID)async {
String memberID = "";
getProjects(memberID) async {
if (memberID != null && memberID != '') {
if (this.memberID !=memberID) {
if (this.memberID != memberID) {
this.memberID = memberID;
await authenticationViewModel.getHospitalsList(memberID);
if(authenticationViewModel.state == ViewState.Idle) {
if (authenticationViewModel.state == ViewState.Idle) {
projectsList = authenticationViewModel.hospitals;
setState(() {
authenticationViewModel.userInfo.projectID = projectsList[0].facilityId;
authenticationViewModel.userInfo.projectID =
projectsList[0].facilityId;
projectIdController.text = projectsList[0].facilityName;
});
}

Loading…
Cancel
Save