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

Loading…
Cancel
Save