Merge branch 'fix_login' into 'diplomatic-quarter-live'

Fix login

See merge request Cloud_Solution/diplomatic-quarter!94
merge-update-with-lab-changes
Mohammad Aljammal 5 years ago
commit 55e25fade8

@ -5,13 +5,13 @@ class AppointmentDetails {
int appointmentNo;
int clinicID;
int doctorID;
String startTime;
String endTime;
String appointmentDate;
String clinicName;
String doctorImageURL;
String doctorName;
String projectName;
dynamic startTime;
dynamic endTime;
dynamic appointmentDate;
dynamic clinicName;
dynamic doctorImageURL;
dynamic doctorName;
dynamic projectName;
AppointmentDetails(
{this.setupID,

@ -52,6 +52,7 @@ class MyApp extends StatelessWidget {
TranslationBaseDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('ar', ''), // Arabic

@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/parking_page.da
import 'package:diplomaticquarterapp/pages/Blood/blood_donation.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/BookingOptions.dart';
import 'package:diplomaticquarterapp/pages/ChildVaccines/child_vaccines_page.dart';
import 'package:diplomaticquarterapp/pages/ContactUs/findus/findus_page.dart';
import 'package:diplomaticquarterapp/pages/ErService/ErOptions.dart';
import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart';
import 'package:diplomaticquarterapp/pages/family/my-family.dart';
@ -317,7 +318,7 @@ class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
onTap: () => Navigator.push(
context,
FadePage(
page: ParkingPage(),
page: FindUsPage(),
),
),
imageLocation: 'assets/images/new-design/find_us_icon.png',

@ -179,8 +179,7 @@ class _AddMember extends State<AddMember> {
request.regionID = 1;
}
loading(true);
this
.familyFileProvider
familyFileProvider
.insertNewMember(request)
.then((value) => sendActivationCode(value));
}
@ -189,8 +188,7 @@ class _AddMember extends State<AddMember> {
// var request = this.getCommonRequest();
loading(true);
patientShareRequestID = result['PatientShareRequestID'];
this
.familyFileProvider
familyFileProvider
.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text)
.then((result) => {
if (result != null && result['isSMSSent'] == true)
@ -203,11 +201,13 @@ class _AddMember extends State<AddMember> {
startSMSService(type, result) {
loading(false);
new SMSOTP(
SMSOTP(
context,
type,
this.mobileNo,
(value) => {this.checkActivationCode(value, result)},
mobileNo,
(value) {
this.checkActivationCode(value, result);
},
() => {
print('Faild..'),
},
@ -215,8 +215,7 @@ class _AddMember extends State<AddMember> {
}
checkActivationCode(value, result) {
this
.familyFileProvider
familyFileProvider
.checkActivationCode(
result['LogInTokenID'], value, nationalIDorFile.text, mobileNo)
.then((result) => {
@ -226,8 +225,7 @@ class _AddMember extends State<AddMember> {
}
handleFamilyRequests(id, stauts) {
this
.familyFileProvider
familyFileProvider
.acceptAndRejectRecievedRequests(id, stauts)
.then((result) => {
sharedPref.remove(FAMILY_FILE),

@ -19,7 +19,7 @@ class InsuranceCard extends StatefulWidget {
@override
_InsuranceCardState createState() => _InsuranceCardState();
}
//TODO fix it
class _InsuranceCardState extends State<InsuranceCard> {
@override
Widget build(BuildContext context) {
@ -29,6 +29,7 @@ class _InsuranceCardState extends State<InsuranceCard> {
AppScaffold(
isShowAppBar: true,
baseViewModel: model,
image: 'assets/images/medical/insurance_card_icon.png',
appBarTitle: TranslationBase.of(context).insuranceCards,
body: Container(
margin: EdgeInsets.only(

@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart';
@ -86,8 +87,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
flex: 3,
child: user != null && isMoreOption == false
? Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
@ -112,14 +112,13 @@ class _ConfirmLogin extends State<ConfirmLogin> {
Expanded(
child: ListTile(
title: Text(
TranslationBase.of(context)
.lastLoginAt,
TranslationBase.of(context).lastLoginAt,
textAlign: TextAlign.center,
),
subtitle: Text(
user.editedOn != null
? formatDate(DateUtil
.convertStringToDate(
? formatDate(
DateUtil.convertStringToDate(
user.editedOn))
: '--',
textAlign: TextAlign.center),
@ -131,8 +130,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
.lastLoginWith,
textAlign: TextAlign.center),
subtitle: Text(
getType(
user.logInType, context),
getType(user.logInType, context),
textAlign: TextAlign.center),
))
],
@ -140,8 +138,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
],
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
@ -153,15 +150,13 @@ class _ConfirmLogin extends State<ConfirmLogin> {
? AppText(
TranslationBase.of(context)
.verifyLoginWith,
fontSize:
SizeConfig.textMultiplier * 3.5,
fontSize: SizeConfig.textMultiplier * 3.5,
textAlign: TextAlign.left,
)
: AppText(
TranslationBase.of(context)
.verifyFingerprint2,
fontSize:
SizeConfig.textMultiplier * 2.5,
fontSize: SizeConfig.textMultiplier * 2.5,
textAlign: TextAlign.start,
),
])),
@ -173,19 +168,15 @@ class _ConfirmLogin extends State<ConfirmLogin> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment:
MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: InkWell(
onTap: () => {
authenticateUser(
3,
BiometricType
.face.index)
3, BiometricType.face.index)
},
child:
getButton(user.logInType))),
child: getButton(user.logInType))),
Expanded(child: getButton(5))
])
]))
@ -197,8 +188,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
children: <Widget>[
onlySMSBox == false
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(child: getButton(3)),
Expanded(child: getButton(2))
@ -224,8 +214,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
children: <Widget>[
Expanded(
child: DefaultButton(
TranslationBase.of(context)
.useAnotherAccount,
TranslationBase.of(context).useAnotherAccount,
() => {
Navigator.of(context).pushNamed(
LOGIN_TYPE,
@ -236,9 +225,13 @@ class _ConfirmLogin extends State<ConfirmLogin> {
)
: SizedBox(),
],
))
),
)
],
))));
),
),
),
);
}
Future<void> _getAvailableBiometrics() async {
@ -300,6 +293,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
showLoader(true);
var req = getCommonRequest();
var request = CheckPatientAuthenticationReq.fromJson(req.toJson());
GifLoaderDialogUtils.showMyDialog(context);
sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request);
authService
@ -321,17 +315,22 @@ class _ConfirmLogin extends State<ConfirmLogin> {
})
.catchError((err) {
print(err);
}).showProgressBar(
text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6));
GifLoaderDialogUtils.hideDialog(context);
});
}
sendActivationCode(type) async {
var request = this.getCommonRequest();
// loading(true);
await this.authService.sendActivationCode(request).then((result) => {
if (result != null && result['isSMSSent'] == true)
{this.startSMSService(type), print(result)}
GifLoaderDialogUtils.showMyDialog(context);
await this.authService.sendActivationCode(request).then((result) {
GifLoaderDialogUtils.hideDialog(context);
if (result != null && result['isSMSSent'] == true) {
this.startSMSService(type);
}
}).catchError((r) {
GifLoaderDialogUtils.hideDialog(context);
});
// SMSOTP.showLoadingDialog(context, false),
@ -479,11 +478,10 @@ class _ConfirmLogin extends State<ConfirmLogin> {
}
checkActivationCode({value}) async {
SMSOTP.showLoadingDialog(context, true);
GifLoaderDialogUtils.showMyDialog(context);
var request = this.getCommonRequest().toJson();
this
.authService
authService
.checkActivationCode(request, value)
.then((result) => {
if (result is Map)
@ -498,25 +496,20 @@ class _ConfirmLogin extends State<ConfirmLogin> {
}
else
{
this.userData = result
.list, //AuthenticatedUser.fromJson(result['List'][0]),
this.sharedPref.setObject(USER_PROFILE, result.list),
this.loginTokenID = result.logInTokenID,
this
.sharedPref
.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
this
.sharedPref
.setString(TOKEN, result.authenticationTokenID),
this.checkIfUserAgreedBefore(result),
// Navigator.of(context).pop(),
SMSOTP.showLoadingDialog(context, false),
userData = result.list,
//AuthenticatedUser.fromJson(result['List'][0]),
sharedPref.setObject(USER_PROFILE, result.list),
loginTokenID = result.logInTokenID,
sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
sharedPref.setString(TOKEN, result.authenticationTokenID),
checkIfUserAgreedBefore(result),
}
}
else
{
// Navigator.of(context).pop(),
SMSOTP.showLoadingDialog(context, false),
GifLoaderDialogUtils.hideDialog(context),
Future.delayed(Duration(seconds: 1), () {
AppToast.showErrorToast(message: result);
}),
@ -524,8 +517,8 @@ class _ConfirmLogin extends State<ConfirmLogin> {
})
.catchError((err) {
print(err);
}).showProgressBar(
text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6));
GifLoaderDialogUtils.hideDialog(context);
});
}
checkIfUserAgreedBefore(CheckActivationCode result) {

@ -11,7 +11,6 @@ import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doct
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
@ -19,10 +18,12 @@ import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/input/text_field.dart';
import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:smart_progress_bar/smart_progress_bar.dart';
class Login extends StatefulWidget {
@override
@ -68,7 +69,8 @@ class _Login extends State<Login> {
padding: EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30),
height: SizeConfig.realScreenHeight * .9,
width: SizeConfig.realScreenWidth,
child: Column(children: <Widget>[
child: Column(
children: <Widget>[
Expanded(
flex: 2,
child: AppText(
@ -124,8 +126,11 @@ class _Login extends State<Login> {
),
],
))
]),
)));
],
),
),
),
);
}
startLogin() {
@ -136,8 +141,10 @@ class _Login extends State<Login> {
void validateForm() {
//TODO fix login
if (util.validateIDBox(nationalIDorFile.text, loginType) == true &&
mobileNo.length >= 9 &&
if (util.validateIDBox(nationalIDorFile.text, loginType) ==
true /*&&
mobileNo.length >= 9 */
&&
util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) {
setState(() {
isButtonDisabled = false;
@ -151,7 +158,6 @@ class _Login extends State<Login> {
checkUserAuthentication() {
// showLoader(true);
GifLoaderDialogUtils.showMyDialog(context);
var request = CheckPatientAuthenticationReq();
request.isRegister = false;
request.patientMobileNumber = int.parse(mobileNo);
@ -166,15 +172,16 @@ class _Login extends State<Login> {
request.patientID = int.parse(nationalIDorFile.text);
}
sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request);
GifLoaderDialogUtils.showMyDialog(context);
authService
.checkPatientAuthentication(request)
.then((value) => {
//showLoader(false),
GifLoaderDialogUtils.hideDialog(context),
if (value['isSMSSent'])
{
sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']),
sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request),
GifLoaderDialogUtils.hideDialog(context),
Navigator.of(context).pushNamed(CONFIRM_LOGIN)
}
else
@ -183,10 +190,10 @@ class _Login extends State<Login> {
}
})
.catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
AppToast.showErrorToast(message: err);
GifLoaderDialogUtils.hideDialog(context);
});
// SMSOTP.showLoadingDialog(context, false),
}
checkActivationCode({code}) async {
@ -207,7 +214,6 @@ class _Login extends State<Login> {
request['PatientIdentificationID'] = '';
request['PatientID'] = int.parse(nationalIDorFile.text);
}
GifLoaderDialogUtils.showMyDialog(context);
// request.isRegister = false;
this.authService.checkActivationCode(request, code).then((result) => {
result = CheckActivationCode.fromJson(result),
@ -215,15 +221,11 @@ class _Login extends State<Login> {
this.sharedPref.setObject(USER_PROFILE, result.list),
this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
this.sharedPref.setString(TOKEN, result.authenticationTokenID),
GifLoaderDialogUtils.hideDialog(context),
//this.checkIfUserAgreedBefore(result),
Navigator.of(context).pushNamed(
HOME,
),
//showLoader(false),
appointmentRateViewModel
.getIsLastAppointmentRatedList()
.then((value) => {
GifLoaderDialogUtils.hideDialog(context),
if (appointmentRateViewModel.isHaveAppointmentNotRate)
{
Navigator.pushReplacement(
@ -244,10 +246,10 @@ class _Login extends State<Login> {
}
})
.catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
AppToast.showErrorToast(message: err);
})
GifLoaderDialogUtils.hideDialog(context);
}),
// SMSOTP.showLoadingDialog(context, false),
});
}

@ -172,7 +172,7 @@ class FamilyFilesProvider with ChangeNotifier {
throw error;
}
}
//TODO
Future<dynamic> checkActivationCode(
loginTokenID, activationCode, indentification, mobileNo) async {
try {

@ -16,7 +16,7 @@ class _GifLoaderContainerState extends State<GifLoaderContainer>
WidgetsBinding.instance.addPostFrameCallback((_) {
controller1.repeat(
min: 0, max: 12, period: Duration(milliseconds: 750), reverse: true);
min: 0, max: 11, period: Duration(milliseconds: 750), reverse: true);
});
super.initState();
}

@ -243,7 +243,7 @@ class _TextFieldsState extends State<TextFields> {
onSaved: widget.onSaved,
style: Theme.of(context)
.textTheme
.body2
.bodyText1
.copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight),
inputFormatters: widget.keyboardType == TextInputType.phone

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
@ -35,6 +36,7 @@ class AppScaffold extends StatelessWidget {
final Widget floatingActionButton;
final String title;
final String description;
final String image;
final bool isShowDecPage;
AuthenticatedUserObject authenticatedUserObject =
@ -52,7 +54,7 @@ class AppScaffold extends StatelessWidget {
this.title,
this.description,
this.isShowDecPage = true,
this.isBottomBar});
this.isBottomBar, this.image});
@override
Widget build(BuildContext context) {
@ -78,7 +80,17 @@ class AppScaffold extends StatelessWidget {
),
centerTitle: true,
actions: <Widget>[
IconButton(
image!=null? InkWell(
onTap: ()=> Navigator.pop(context),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
image,
height: SizeConfig.heightMultiplier * 5,
width: SizeConfig.heightMultiplier * 5,
color: Colors.white,
),
),): IconButton(
icon: Icon(FontAwesomeIcons.home),
color: Colors.white,
onPressed: () {

@ -29,6 +29,13 @@ class SMSOTP {
this.onFailure,
);
final verifyAccountForm = GlobalKey<FormState>();
TextEditingController digit1 = TextEditingController(text: "");
TextEditingController digit2 = TextEditingController(text: "");
TextEditingController digit3 = TextEditingController(text: "");
TextEditingController digit4 = TextEditingController(text: "");
Map verifyAccountFormValue = {
'digit1': '',
'digit2': '',
@ -42,6 +49,7 @@ class SMSOTP {
String errorMsg;
String displayTime = '';
displayDialog(BuildContext context) async {
return showDialog(
context: context,
@ -83,7 +91,9 @@ class SMSOTP {
.substring(mobileNo.toString().length - 3),
textAlign: TextAlign.center,
)),
Padding(
Form(
key: verifyAccountForm,
child: Padding(
padding: EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@ -95,6 +105,7 @@ class SMSOTP {
style: buildTextStyle(),
autofocus: true,
maxLength: 1,
controller: digit1,
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
decoration: buildInputDecoration(context),
@ -105,8 +116,10 @@ class SMSOTP {
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context).requestFocus(focusD2);
verifyAccountFormValue['digit1'] = val.trim();
FocusScope.of(context)
.requestFocus(focusD2);
verifyAccountFormValue['digit1'] =
val.trim();
checkValue();
}
},
@ -118,19 +131,22 @@ class SMSOTP {
focusNode: focusD2,
textInputAction: TextInputAction.next,
maxLength: 1,
controller: digit2,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration: buildInputDecoration(context),
onSaved: (val) {},
onFieldSubmitted: (_) {
FocusScope.of(context).requestFocus(focusD3);
FocusScope.of(context)
.requestFocus(focusD3);
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(focusD3);
verifyAccountFormValue['digit2'] = val.trim();
verifyAccountFormValue['digit2'] =
val.trim();
checkValue();
}
},
@ -142,6 +158,7 @@ class SMSOTP {
focusNode: focusD3,
textInputAction: TextInputAction.next,
maxLength: 1,
controller: digit3,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
@ -155,7 +172,8 @@ class SMSOTP {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(focusD4);
verifyAccountFormValue['digit3'] = val.trim();
verifyAccountFormValue['digit3'] =
val.trim();
checkValue();
}
},
@ -167,6 +185,7 @@ class SMSOTP {
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
controller: digit4,
keyboardType: TextInputType.number,
decoration: buildInputDecoration(context),
onFieldSubmitted: (_) {
@ -175,7 +194,8 @@ class SMSOTP {
},
onChanged: (val) {
if (val.length == 1) {
verifyAccountFormValue['digit4'] = val.trim();
verifyAccountFormValue['digit4'] =
val.trim();
checkValue();
}
},
@ -183,6 +203,7 @@ class SMSOTP {
],
),
),
),
Padding(
padding: EdgeInsets.only(top: 10),
child: AppText(
@ -231,7 +252,7 @@ class SMSOTP {
String validateCodeDigit(value) {
if (value.isEmpty) {
return 'Please enter your Password';
return ' ';
} else if (value.length == 3) {
print(value);
} else {
@ -241,15 +262,10 @@ class SMSOTP {
checkValue() {
//print(verifyAccountFormValue);
if (verifyAccountFormValue['digit1'] != ''&&
verifyAccountFormValue['digit2'] != '' &&
verifyAccountFormValue['digit3'] != '' &&
verifyAccountFormValue['digit4'] != '') {
onSuccess(verifyAccountFormValue['digit1'] +
verifyAccountFormValue['digit2'] +
verifyAccountFormValue['digit3'] +
verifyAccountFormValue['digit4']);
if (verifyAccountForm.currentState.validate()) {
onSuccess(digit1.text.toString()+digit2.text.toString()+digit3.text.toString()+digit4.text.toString());
}
}
getSecondsAsDigitalClock(int inputSeconds) {

Loading…
Cancel
Save