new login type

merge-requests/193/head
Elham Rababah 5 years ago
parent 89729e4537
commit 4eee5cd9d8

@ -71,6 +71,9 @@ const SELECT_DEVICE_IMEI =
const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE =
'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType';
const SEND_ACTIVATION_CODE_FOR_DOCTOR_APP =
'Services/DoctorApplication.svc/REST/SendActivationCodeForDoctorApp';
const MEMBER_CHECK_ACTIVATION_CODE_NEW =
'Services/Sentry.svc/REST/MemberCheckActivationCode_New';
const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles';

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
@ -119,6 +120,22 @@ class AuthViewModel with ChangeNotifier {
}
}
Future sendActivationCodeForDoctorApp(ActivationCodeModel activationCodeModel) async {
try {
var localRes;
await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_DOCTOR_APP,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: activationCodeModel.toJson());
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<dynamic> memberCheckActivationCodeNew(activationCodeModel) async {
try {
dynamic localRes;

@ -69,7 +69,7 @@ class ProjectProvider with ChangeNotifier {
sharedPref.setString(APP_Language, 'ar');
} else if (lan != "ar" && currentLanguage != lan) {
_appLocale = Locale("en");
_isArabic = false;
_isArabic = false;
currentLanguage = 'en';
sharedPref.setString(APP_Language, 'en');
}

@ -0,0 +1,48 @@
class ActivationCodeModel {
String mobileNumber;
String zipCode;
int channel;
int languageID;
double versionID;
int memberID;
String password;
int facilityId;
String generalid;
ActivationCodeModel(
{this.mobileNumber,
this.zipCode,
this.channel,
this.languageID,
this.versionID,
this.memberID,
this.password,
this.facilityId,
this.generalid});
ActivationCodeModel.fromJson(Map<String, dynamic> json) {
mobileNumber = json['MobileNumber'];
zipCode = json['ZipCode'];
channel = json['Channel'];
languageID = json['LanguageID'];
versionID = json['VersionID'];
memberID = json['MemberID'];
password = json['Password'];
facilityId = json['facilityId'];
generalid = json['generalid'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['MobileNumber'] = this.mobileNumber;
data['ZipCode'] = this.zipCode;
data['Channel'] = this.channel;
data['LanguageID'] = this.languageID;
data['VersionID'] = this.versionID;
data['MemberID'] = this.memberID;
data['Password'] = this.password;
data['facilityId'] = this.facilityId;
data['generalid'] = this.generalid;
return data;
}
}

@ -13,9 +13,13 @@ import '../../widgets/auth/verification_methods.dart';
*@desc: Verification Methods screen
*/
class VerificationMethodsScreen extends StatefulWidget {
const VerificationMethodsScreen({Key key, this.password}) : super(key: key);
@override
_VerificationMethodsScreenState createState() =>
_VerificationMethodsScreenState();
final password;
}
class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
@ -47,6 +51,7 @@ class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
children: <Widget>[
AuthHeader(loginType.verificationMethods),
VerificationMethods(
password: widget.password,
changeLoadingStata: changeLoadingStata,
),
],

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/lookups/hospital_lookup.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@ -240,8 +241,8 @@ class _LoginFormState extends State<LoginForm> {
saveObjToString(LOGGED_IN_USER, res);
sharedPref.setString(TOKEN, res['LogInTokenID']);
print("token" + res['LogInTokenID']);
Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS);
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context) => VerificationMethodsScreen(password: userInfo.password,)));
// Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS);
} else {
// handel error
// widget.showCenterShortLoadingToast("watting");
@ -279,7 +280,8 @@ class _LoginFormState extends State<LoginForm> {
if (res['MessageStatus'] == 1) {
setSharedPref('platformImei', _platformImei);
saveObjToString(LOGGED_IN_USER, preRes);
Navigator.of(context).pushNamed(VERIFICATION_METHODS);
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context) => VerificationMethodsScreen(password: userInfo.password,)));
// save imei on shared preferance
} else {
// handel error

@ -1,6 +1,9 @@
import 'dart:io' show Platform;
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
@ -11,7 +14,6 @@ import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/helpers.dart';
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
@ -24,8 +26,11 @@ Helpers helpers = Helpers();
*@desc: Verification Methods widget
*/
class VerificationMethods extends StatefulWidget {
VerificationMethods({this.changeLoadingStata});
VerificationMethods({this.changeLoadingStata, this.password});
final password;
final Function changeLoadingStata;
@override
_VerificationMethodsState createState() => _VerificationMethodsState();
}
@ -267,40 +272,79 @@ class _VerificationMethodsState extends State<VerificationMethods> {
if (oTPSendType == 1 || oTPSendType == 2) {
widget.changeLoadingStata(true);
ActivationCodeModel activationCodeModel = ActivationCodeModel(
facilityId: 15,
generalid: "Cs2020@2016\$2958",
memberID: _loggedUser['List_MemberInformation'][0]['MemberID'],
zipCode: _loggedUser['ZipCode'],
mobileNumber: _loggedUser['MobileNumber'],
password: widget.password);
Map<String, dynamic> model = {
"LogInTokenID": _loggedUser['LogInTokenID'],
"Channel": 9,
"MobileNumber": _loggedUser['MobileNumber'],
"IPAdress": "11.11.11.11",
"LanguageID": 2,
"ProjectID": 15, //TODO : this should become daynamci
"ZipCode": _loggedUser['ZipCode'],
"UserName": _loggedUser['List_MemberInformation'][0]['MemberID'],
"OTP_SendType": oTPSendType
};
authProv.sendActivationCodeByOtpNotificationType(model).then((res) {
widget.changeLoadingStata(false);
if (res['MessageStatus'] == 1) {
Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT,
arguments: {'model': model});
} else {
print(res['ErrorEndUserMessage']);
helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
print('$err');
widget.changeLoadingStata(false);
try {
authProv
.sendActivationCodeForDoctorApp(activationCodeModel)
.then((res) {
widget.changeLoadingStata(false);
if (res['MessageStatus'] == 1) {
Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT,
arguments: {'model': model});
} else {
print(res['ErrorEndUserMessage']);
helpers.showErrorToast(res['ErrorEndUserMessage']);
}
})
.catchError((err) {
print('$err');
widget.changeLoadingStata(false);
helpers.showErrorToast();
});
helpers.showErrorToast();
});
} catch (e) {}
// Map<String, dynamic> model = {
// "LogInTokenID": _loggedUser['LogInTokenID'],
// "Channel": 9,
// "MobileNumber": _loggedUser['MobileNumber'],
// "IPAdress": "11.11.11.11",
// "LanguageID": 2,
// "ProjectID": 15, //TODO : this should become daynamci
// "ZipCode": _loggedUser['ZipCode'],
// "UserName": _loggedUser['List_MemberInformation'][0]['MemberID'],
// "OTP_SendType": oTPSendType
// };
// authProv.sendActivationCodeByOtpNotificationType(model).then((res) {
// widget.changeLoadingStata(false);
//
// if (res['MessageStatus'] == 1) {
// Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT,
// arguments: {'model': model});
// } else {
// print(res['ErrorEndUserMessage']);
// helpers.showErrorToast(res['ErrorEndUserMessage']);
// }
// }).catchError((err) {
// print('$err');
// widget.changeLoadingStata(false);
//
// helpers.showErrorToast();
// });
} else {
// TODO route to this page with parameters to inicate we should present 2 option
if (Platform.isAndroid && oTPSendType == 3) {
helpers.showErrorToast('Your device not support this feature');
} else {
Navigator.of(context).pushNamed(VERIFICATION_METHODS,
arguments: {'verificationMethod': oTPSendType});
Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) =>
VerificationMethodsScreen(password: widget.password,)));
// Navigator.of(context).pushNamed(VERIFICATION_METHODS,
// arguments: {'verificationMethod': oTPSendType});
}
}
}

Loading…
Cancel
Save