first step from refactoring auth part
parent
607da6af66
commit
663d2a942f
@ -0,0 +1,48 @@
|
||||
class GetHospitalsRequestModel {
|
||||
int languageID;
|
||||
String stamp;
|
||||
String iPAdress;
|
||||
double versionID;
|
||||
int channel;
|
||||
String tokenID;
|
||||
String sessionID;
|
||||
bool isLoginForDoctorApp;
|
||||
String memberID;
|
||||
|
||||
GetHospitalsRequestModel(
|
||||
{this.languageID,
|
||||
this.stamp,
|
||||
this.iPAdress,
|
||||
this.versionID,
|
||||
this.channel,
|
||||
this.tokenID,
|
||||
this.sessionID,
|
||||
this.isLoginForDoctorApp,
|
||||
this.memberID});
|
||||
|
||||
GetHospitalsRequestModel.fromJson(Map<String, dynamic> json) {
|
||||
languageID = json['LanguageID'];
|
||||
stamp = json['stamp'];
|
||||
iPAdress = json['IPAdress'];
|
||||
versionID = json['VersionID'];
|
||||
channel = json['Channel'];
|
||||
tokenID = json['TokenID'];
|
||||
sessionID = json['SessionID'];
|
||||
isLoginForDoctorApp = json['IsLoginForDoctorApp'];
|
||||
memberID = json['MemberID'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['LanguageID'] = this.languageID;
|
||||
data['stamp'] = this.stamp;
|
||||
data['IPAdress'] = this.iPAdress;
|
||||
data['VersionID'] = this.versionID;
|
||||
data['Channel'] = this.channel;
|
||||
data['TokenID'] = this.tokenID;
|
||||
data['SessionID'] = this.sessionID;
|
||||
data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp;
|
||||
data['MemberID'] = this.memberID;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
import 'package:doctor_app_flutter/config/config.dart';
|
||||
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart';
|
||||
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
||||
|
||||
class HospitalsService extends BaseService {
|
||||
|
||||
List<dynamic> hospitals;
|
||||
|
||||
Future getHospitals(GetHospitalsRequestModel getHospitalsRequestModel) async {
|
||||
hasError = false;
|
||||
await baseAppClient.post(
|
||||
GET_PROJECTS,
|
||||
onSuccess: (dynamic response, int statusCode) {
|
||||
hospitals = response['ProjectInfo'];
|
||||
},
|
||||
onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
},
|
||||
body: getHospitalsRequestModel.toJson(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
import 'package:doctor_app_flutter/client/base_app_client.dart';
|
||||
import 'package:doctor_app_flutter/config/config.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
// TODO change it when change login
|
||||
class HospitalViewModel with ChangeNotifier {
|
||||
BaseAppClient baseAppClient = BaseAppClient();
|
||||
|
||||
Future<Map> getProjectsList(memberID) async {
|
||||
const url = GET_PROJECTS;
|
||||
// TODO create model or remove it if no info need
|
||||
var info = {
|
||||
"LanguageID": 1,
|
||||
"stamp": "2020-02-26T13:51:44.111Z",
|
||||
"IPAdress": "11.11.11.11",
|
||||
"VersionID": 5.8,
|
||||
"Channel": 9,
|
||||
"TokenID": "",
|
||||
"SessionID": "i1UJwCTSqt",
|
||||
"IsLoginForDoctorApp": true,
|
||||
"MemberID": memberID
|
||||
};
|
||||
dynamic localRes;
|
||||
|
||||
await baseAppClient.post(url, onSuccess: (response, statusCode) async {
|
||||
localRes = response;
|
||||
}, onFailure: (String error, int statusCode) {
|
||||
throw error;
|
||||
}, body: info);
|
||||
return Future.value(localRes);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
import 'package:doctor_app_flutter/client/base_app_client.dart';
|
||||
import 'package:doctor_app_flutter/config/config.dart';
|
||||
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
||||
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart';
|
||||
import 'package:doctor_app_flutter/core/service/hospitals/hospitals_service.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import '../../locator.dart';
|
||||
import 'base_view_model.dart';
|
||||
|
||||
|
||||
class HospitalViewModel extends BaseViewModel {
|
||||
HospitalsService _hospitalsService = locator<HospitalsService>();
|
||||
// List<GetIMEIDetailsModel> get imeiDetails => _authService.dashboardItemsList;
|
||||
// get loginInfo => _authService.loginInfo;
|
||||
Future getHospitalsList(memberID) async {
|
||||
GetHospitalsRequestModel getHospitalsRequestModel =GetHospitalsRequestModel();
|
||||
getHospitalsRequestModel.memberID = memberID;
|
||||
setState(ViewState.Busy);
|
||||
await _hospitalsService.getHospitals(getHospitalsRequestModel);
|
||||
if (_hospitalsService.hasError) {
|
||||
error = _hospitalsService.error;
|
||||
setState(ViewState.Error);
|
||||
} else
|
||||
setState(ViewState.Idle);
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
import 'package:doctor_app_flutter/lookups/auth_lookup.dart';
|
||||
import 'package:doctor_app_flutter/widgets/auth/auth_header.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../widgets/auth/change_password.dart';
|
||||
|
||||
class ChangePasswordScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return AppScaffold(
|
||||
isShowAppBar: false,
|
||||
body: SafeArea(
|
||||
child: ListView(children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 0, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
AuthHeader(loginType.changePassword),
|
||||
ChangePassword(),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -1,159 +0,0 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
|
||||
class ChangePassword extends StatelessWidget {
|
||||
final changePassFormKey = GlobalKey<FormState>();
|
||||
var changePassFormValues = {
|
||||
'currentPass': null,
|
||||
'newPass': null,
|
||||
'repeatedPass': null
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Form(
|
||||
key: changePassFormKey,
|
||||
child: Container(
|
||||
width: SizeConfig.realScreenWidth * 0.90,
|
||||
child:
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: <
|
||||
Widget>[
|
||||
buildSizedBox(),
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
// ts/images/password_icon.png
|
||||
prefixIcon: Image.asset('assets/images/password_icon.png'),
|
||||
hintText: 'Current Password',
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
borderSide: BorderSide(color: HexColor('#CCCCCC')),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide:
|
||||
BorderSide(color: Theme.of(context).primaryColor),
|
||||
)
|
||||
//BorderRadius.all(Radius.circular(20));
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter your Current Password';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (value) {
|
||||
// changePassFormValues. = value;
|
||||
},
|
||||
),
|
||||
buildSizedBox(40),
|
||||
// buildSizedBox(),
|
||||
Text(
|
||||
"New Password",
|
||||
style: TextStyle(
|
||||
fontSize: 2.8 * SizeConfig.textMultiplier,
|
||||
fontWeight: FontWeight.w800),
|
||||
),
|
||||
buildSizedBox(10.0),
|
||||
// Text()
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
// ts/images/password_icon.png
|
||||
prefixIcon: Image.asset('assets/images/password_icon.png'),
|
||||
hintText: 'New Password',
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
borderSide: BorderSide(color: HexColor('#CCCCCC')),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide:
|
||||
BorderSide(color: Theme.of(context).primaryColor),
|
||||
)
|
||||
//BorderRadius.all(Radius.circular(20));
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter your New Password';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (value) {
|
||||
// userInfo.UserID = value;
|
||||
},
|
||||
),
|
||||
buildSizedBox(),
|
||||
TextFormField(
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Image.asset('assets/images/password_icon.png'),
|
||||
hintText: 'Repeat Password',
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
borderSide: BorderSide(color: HexColor('#CCCCCC')),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide:
|
||||
BorderSide(color: Theme.of(context).primaryColor),
|
||||
)
|
||||
//BorderRadius.all(Radius.circular(20));
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter your Repeat Password';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (value) {
|
||||
// userInfo.UserID = value;
|
||||
},
|
||||
),
|
||||
buildSizedBox(),
|
||||
RaisedButton(
|
||||
onPressed:changePass,
|
||||
elevation: 0.0,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Change Password'
|
||||
.toUpperCase(),
|
||||
// textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 2.5 * SizeConfig.textMultiplier),
|
||||
),
|
||||
),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
])));
|
||||
}
|
||||
|
||||
SizedBox buildSizedBox([double height = 20]) {
|
||||
return SizedBox(
|
||||
height: height,
|
||||
);
|
||||
}
|
||||
changePass(){
|
||||
if(changePassFormKey.currentState.validate()){
|
||||
changePassFormKey.currentState.save();
|
||||
// call Api
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,328 +0,0 @@
|
||||
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:local_auth/error_codes.dart' as auth_error;
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../config/size_config.dart';
|
||||
import '../../core/viewModel/auth_view_model.dart';
|
||||
import '../../routes.dart';
|
||||
import '../../util/dr_app_shared_pref.dart';
|
||||
import '../../util/dr_app_toast_msg.dart';
|
||||
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
|
||||
|
||||
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
||||
|
||||
class KnownUserLogin extends StatefulWidget {
|
||||
@override
|
||||
_KnownUserLoginState createState() => _KnownUserLoginState();
|
||||
}
|
||||
|
||||
class _KnownUserLoginState extends State<KnownUserLogin> {
|
||||
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
||||
final LocalAuthentication auth = LocalAuthentication();
|
||||
|
||||
String _authorized = "not Authorized";
|
||||
bool _isAuthenticating = false;
|
||||
Future _loggedUserFuture;
|
||||
var _loggedUser;
|
||||
int _loginType = 1;
|
||||
String _platformImei;
|
||||
Future _loginTypeFuture;
|
||||
|
||||
Map _loginTypeMap = {
|
||||
1: {
|
||||
"name": "SMS",
|
||||
'imageUrl': 'assets/images/verification_sms_lg_icon.png',
|
||||
},
|
||||
2: {
|
||||
"name": "FingerPrint",
|
||||
'imageUrl': 'assets/images/verification_fingerprint_lg_icon.png'
|
||||
},
|
||||
3: {
|
||||
"name": "Face",
|
||||
'imageUrl': 'assets/images/verification_faceid_lg_icon.png'
|
||||
},
|
||||
4: {
|
||||
"name": "WhatsApp",
|
||||
'imageUrl': 'assets/images/verification_whatsapp_lg_icon.png'
|
||||
}
|
||||
};
|
||||
|
||||
Future<void> getSharedPref() async {
|
||||
sharedPref.getObj(LOGGED_IN_USER).then((userInfo) {
|
||||
_loggedUser = userInfo;
|
||||
});
|
||||
sharedPref.getString('platformImei').then((imei) {
|
||||
_platformImei = imei;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loggedUserFuture = getSharedPref();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AuthViewModel authProv = Provider.of<AuthViewModel>(context);
|
||||
// var imeiModel = {'IMEI': _platformImei};
|
||||
// _loginTypeFuture = authProv.selectDeviceImei(imeiModel);
|
||||
return FutureBuilder(
|
||||
future: Future.wait([_loggedUserFuture, _loginTypeFuture]),
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
_loginTypeFuture.then((res) {
|
||||
_loginType =
|
||||
2; //res['SELECTDeviceIMEIbyIMEI_List'][0]['LogInType'];
|
||||
}).catchError((err) {
|
||||
print('${err}');
|
||||
DrAppToastMsg.showErrorToast(err);
|
||||
});
|
||||
switch (snapshot.connectionState) {
|
||||
case ConnectionState.waiting:
|
||||
return DrAppCircularProgressIndeicator();
|
||||
default:
|
||||
if (snapshot.hasError) {
|
||||
DrAppToastMsg.showErrorToast('Error: ${snapshot.error}');
|
||||
return Text('Error: ${snapshot.error}');
|
||||
} else {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Stack(children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: HexColor('#CCCCCC'),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(50)),
|
||||
margin: const EdgeInsets.fromLTRB(0, 20.0, 30, 0),
|
||||
child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
height: 100,
|
||||
width: 100,
|
||||
decoration: new BoxDecoration(
|
||||
// color: Colors.green, // border color
|
||||
shape: BoxShape.circle,
|
||||
border:
|
||||
Border.all(color: HexColor('#CCCCCC'))),
|
||||
child: CircleAvatar(
|
||||
child: Image.asset(
|
||||
'assets/images/dr_avatar.png',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
vertical: 3, horizontal: 15),
|
||||
child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
_loggedUser['List_MemberInformation'][0]
|
||||
['MemberName'],
|
||||
style: TextStyle(
|
||||
color: HexColor('515A5D'),
|
||||
fontSize:
|
||||
2.5 * SizeConfig.textMultiplier,
|
||||
fontWeight: FontWeight.w800),
|
||||
),
|
||||
Text(
|
||||
'ENT Spec',
|
||||
style: TextStyle(
|
||||
color: HexColor('515A5D'),
|
||||
fontSize:
|
||||
1.5 * SizeConfig.textMultiplier),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 7,
|
||||
right: 70,
|
||||
child: Image.asset(
|
||||
'assets/images/close_icon.png',
|
||||
fit: BoxFit.cover,
|
||||
))
|
||||
]),
|
||||
buildVerificationTypeImageContainer(),
|
||||
buildButtonsContainer(context)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Container buildVerificationTypeImageContainer() {
|
||||
print('${_loginTypeMap[_loginType]}');
|
||||
return Container(
|
||||
height: 200,
|
||||
width: 200,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
_loginTypeMap[_loginType]['imageUrl'],
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
Container buildButtonsContainer(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsetsDirectional.fromSTEB(0, 0, 30, 0),
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
onPressed: _authenticate,
|
||||
elevation: 0.0,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Verify using ${_loginTypeMap[_loginType]['name']}"
|
||||
.toUpperCase(),
|
||||
// textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 2.5 * SizeConfig.textMultiplier),
|
||||
),
|
||||
),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: FlatButton(
|
||||
onPressed: () {
|
||||
navigateToMoreOption();
|
||||
},
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
side: BorderSide(
|
||||
width: 1, color: Theme.of(context).primaryColor)),
|
||||
child: Text(
|
||||
"More verification Options".toUpperCase(),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 2.5 * SizeConfig.textMultiplier),
|
||||
)),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
navigateToMoreOption() {
|
||||
Navigator.of(context).pushNamed(VERIFICATION_METHODS);
|
||||
}
|
||||
|
||||
_authenticate() {
|
||||
if (_loginType == 1) {
|
||||
_authenticateBySMS();
|
||||
}
|
||||
if (_loginType == 2) {
|
||||
_authenticateByFingerPrint();
|
||||
}
|
||||
if (_loginType == 3) {
|
||||
_authenticateByFace();
|
||||
}
|
||||
if (_loginType == 4) {
|
||||
_authenticateByWhatsApp();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _authenticateByFingerPrint() async {
|
||||
_getAvailableBiometrics();
|
||||
bool authenticated = false;
|
||||
try {
|
||||
setState(() {
|
||||
_isAuthenticating = true;
|
||||
_authorized = 'Authenticating';
|
||||
});
|
||||
authenticated = await auth.authenticateWithBiometrics(
|
||||
localizedReason: 'Scan your fingerprint to authenticate',
|
||||
useErrorDialogs: true,
|
||||
stickyAuth: false);
|
||||
setState(() {
|
||||
_isAuthenticating = false;
|
||||
_authorized = 'Authenticating';
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print(e);
|
||||
}
|
||||
if (!mounted) return;
|
||||
|
||||
final String message = authenticated ? 'Authorized' : 'Not Authorized';
|
||||
if (message == 'Authorized') {
|
||||
navigateToHome();
|
||||
}
|
||||
setState(() {
|
||||
print('_authorized' + _authorized);
|
||||
_authorized = message;
|
||||
print('_authorized' + _authorized);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _authenticateBySMS() {
|
||||
print('_authenticateBySMS');
|
||||
}
|
||||
|
||||
Future<void> _authenticateByFace() {
|
||||
print('_authenticateByFace');
|
||||
}
|
||||
|
||||
Future<void> _authenticateByWhatsApp() {
|
||||
print('_authenticateByWhatsApp');
|
||||
}
|
||||
|
||||
Future<void> _getAvailableBiometrics() async {
|
||||
List<BiometricType> availableBiometrics;
|
||||
try {
|
||||
availableBiometrics = await auth.getAvailableBiometrics();
|
||||
} on PlatformException catch (e) {
|
||||
print(e);
|
||||
if (e.code == auth_error.notAvailable) {
|
||||
showErorrMsg("Auth Methods Not Available");
|
||||
} else if (e.code == auth_error.passcodeNotSet) {
|
||||
showErorrMsg("Auth Methods Not passcodeNotSet");
|
||||
} else if (e.code == auth_error.permanentlyLockedOut) {
|
||||
showErorrMsg("Auth Methods Not permanentlyLockedOut");
|
||||
}
|
||||
}
|
||||
if (!mounted) return;
|
||||
|
||||
setState(() {
|
||||
print('availableBiometrics $availableBiometrics');
|
||||
});
|
||||
}
|
||||
|
||||
navigateToHome() {
|
||||
Navigator.of(context).pushReplacementNamed(HOME);
|
||||
}
|
||||
|
||||
showErorrMsg(localMsg) {
|
||||
DrAppToastMsg.showErrorToast(localMsg);
|
||||
}
|
||||
}
|
||||
@ -1,312 +0,0 @@
|
||||
import 'package:doctor_app_flutter/config/config.dart';
|
||||
import 'package:doctor_app_flutter/core/viewModel/imei_view_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:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
|
||||
import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../config/shared_pref_kay.dart';
|
||||
import '../../config/size_config.dart';
|
||||
import '../../core/viewModel/hospital_view_model.dart';
|
||||
import '../../models/doctor/user_model.dart';
|
||||
import '../../util/dr_app_shared_pref.dart';
|
||||
import '../../util/dr_app_toast_msg.dart';
|
||||
import '../../util/helpers.dart';
|
||||
|
||||
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
|
||||
DrAppToastMsg toastMsg = DrAppToastMsg();
|
||||
Helpers helpers = Helpers();
|
||||
|
||||
class LoginForm extends StatefulWidget with DrAppToastMsg {
|
||||
LoginForm({this.model});
|
||||
|
||||
final IMEIViewModel model;
|
||||
|
||||
@override
|
||||
_LoginFormState createState() => _LoginFormState();
|
||||
}
|
||||
|
||||
class _LoginFormState extends State<LoginForm> {
|
||||
final loginFormKey = GlobalKey<FormState>();
|
||||
var projectIdController = TextEditingController();
|
||||
var projectsList = [];
|
||||
FocusNode focusPass = FocusNode();
|
||||
FocusNode focusProject = FocusNode();
|
||||
HospitalViewModel projectsProv;
|
||||
var userInfo = UserModel();
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
projectsProv = Provider.of<HospitalViewModel>(context);
|
||||
return Form(
|
||||
key: loginFormKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: SizeConfig.realScreenWidth * 0.90,
|
||||
height: SizeConfig.realScreenHeight * 0.65,
|
||||
child:
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
buildSizedBox(),
|
||||
Padding(
|
||||
child: AppText(
|
||||
TranslationBase.of(context).enterCredentials,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
padding: EdgeInsets.only(top: 10, bottom: 10)),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6.0)),
|
||||
border: Border.all(
|
||||
width: 1.0,
|
||||
color: HexColor("#CCCCCC"),
|
||||
),
|
||||
color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 10, top: 10),
|
||||
child: AppText(
|
||||
TranslationBase.of(context).enterId,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 14,
|
||||
)),
|
||||
AppTextFormField(
|
||||
labelText: '',
|
||||
borderColor: Colors.white,
|
||||
// keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
|
||||
validator: (value) {
|
||||
if (value != null && value.isEmpty) {
|
||||
return TranslationBase.of(context)
|
||||
.pleaseEnterYourID;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (value) {
|
||||
if (value != null) userInfo.userID = value.trim();
|
||||
},
|
||||
onChanged: (value) {
|
||||
if (value != null) userInfo.userID = value.trim();
|
||||
},
|
||||
onFieldSubmitted: (_) {
|
||||
focusPass.nextFocus();
|
||||
},
|
||||
)
|
||||
])),
|
||||
buildSizedBox(),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6.0)),
|
||||
border: Border.all(
|
||||
width: 1.0,
|
||||
color: HexColor("#CCCCCC"),
|
||||
),
|
||||
color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 10, top: 10),
|
||||
child: AppText(
|
||||
TranslationBase.of(context).enterPassword,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 14,
|
||||
)),
|
||||
AppTextFormField(
|
||||
focusNode: focusPass,
|
||||
obscureText: true,
|
||||
borderColor: Colors.white,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value != null && value.isEmpty) {
|
||||
return TranslationBase.of(context)
|
||||
.pleaseEnterPassword;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (value) {
|
||||
userInfo.password = value;
|
||||
},
|
||||
onFieldSubmitted: (_) {
|
||||
focusPass.nextFocus();
|
||||
Helpers.showCupertinoPicker(context, projectsList,
|
||||
'facilityName', onSelectProject);
|
||||
},
|
||||
onTap: () {
|
||||
this.getProjects(userInfo.userID);
|
||||
},
|
||||
)
|
||||
])),
|
||||
buildSizedBox(),
|
||||
projectsList.length > 0
|
||||
? Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6.0)),
|
||||
border: Border.all(
|
||||
width: 1.0,
|
||||
color: HexColor("#CCCCCC"),
|
||||
),
|
||||
color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 10, top: 10),
|
||||
child: AppText(
|
||||
TranslationBase.of(context).selectYourProject,
|
||||
fontWeight: FontWeight.w600,
|
||||
)),
|
||||
AppTextFormField(
|
||||
focusNode: focusProject,
|
||||
controller: projectIdController,
|
||||
borderColor: Colors.white,
|
||||
suffixIcon: Icons.arrow_drop_down,
|
||||
onTap: () {
|
||||
Helpers.showCupertinoPicker(
|
||||
context,
|
||||
projectsList,
|
||||
'facilityName',
|
||||
onSelectProject);
|
||||
},
|
||||
validator: (value) {
|
||||
if (value != null && value.isEmpty) {
|
||||
return TranslationBase.of(context)
|
||||
.pleaseEnterYourProject;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
]))
|
||||
: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6.0)),
|
||||
border: Border.all(
|
||||
width: 1.0,
|
||||
color: HexColor("#CCCCCC"),
|
||||
),
|
||||
color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 10, top: 10),
|
||||
child: AppText(
|
||||
TranslationBase.of(context).selectYourProject,
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 14,
|
||||
)),
|
||||
AppTextFormField(
|
||||
readOnly: true,
|
||||
borderColor: Colors.white,
|
||||
prefix: IconButton(
|
||||
icon: Icon(Icons.arrow_drop_down),
|
||||
iconSize: 30,
|
||||
padding: EdgeInsets.only(bottom: 30),
|
||||
),
|
||||
)
|
||||
])),
|
||||
]),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: AppButton(
|
||||
title: TranslationBase.of(context).login,
|
||||
color: HexColor('#D02127'),
|
||||
fontWeight: FontWeight.bold,
|
||||
onPressed: () {
|
||||
login(context, this.widget.model);
|
||||
},
|
||||
)),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
//));
|
||||
}
|
||||
|
||||
SizedBox buildSizedBox() {
|
||||
return SizedBox(
|
||||
height: 20,
|
||||
);
|
||||
}
|
||||
|
||||
login(
|
||||
context,
|
||||
model,
|
||||
) {
|
||||
if (loginFormKey.currentState.validate()) {
|
||||
loginFormKey.currentState.save();
|
||||
sharedPref.setInt(PROJECT_ID, userInfo.projectID);
|
||||
model.login(userInfo).then((res) {
|
||||
if (model.loginInfo['MessageStatus'] == 1) {
|
||||
saveObjToString(LOGGED_IN_USER, model.loginInfo);
|
||||
sharedPref.remove(LAST_LOGIN_USER);
|
||||
sharedPref.setString(TOKEN, model.loginInfo['LogInTokenID']);
|
||||
Navigator.of(AppGlobal.CONTEX).pushReplacement(MaterialPageRoute(
|
||||
builder: (BuildContext context) => VerificationMethodsScreen(
|
||||
password: userInfo.password,
|
||||
)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setSharedPref(key, value) async {
|
||||
sharedPref.setString(key, value).then((success) {
|
||||
print("sharedPref.setString" + success.toString());
|
||||
});
|
||||
}
|
||||
|
||||
getProjectsList(memberID) {
|
||||
projectsProv.getProjectsList(memberID).then((res) {
|
||||
if (res['MessageStatus'] == 1) {
|
||||
projectsList = res['ProjectInfo'];
|
||||
setState(() {
|
||||
userInfo.projectID = projectsList[0]["facilityId"];
|
||||
projectIdController.text = projectsList[0]['facilityName'];
|
||||
});
|
||||
} else {
|
||||
print(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveObjToString(String key, value) async {
|
||||
sharedPref.setObj(key, value);
|
||||
}
|
||||
|
||||
onSelectProject(index) {
|
||||
setState(() {
|
||||
userInfo.projectID = projectsList[index]["facilityId"];
|
||||
projectIdController.text = projectsList[index]['facilityName'];
|
||||
});
|
||||
|
||||
primaryFocus.unfocus();
|
||||
}
|
||||
|
||||
getProjects(value) {
|
||||
if (value != null && value != '') {
|
||||
if (projectsList.length == 0) {
|
||||
getProjectsList(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,105 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:doctor_app_flutter/config/config.dart';
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
|
||||
import 'package:doctor_app_flutter/routes.dart';
|
||||
import 'package:doctor_app_flutter/util/helpers.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
Helpers helpers = Helpers();
|
||||
|
||||
class ShowTimerText extends StatefulWidget {
|
||||
ShowTimerText({Key key, this.model});
|
||||
final model;
|
||||
|
||||
@override
|
||||
_ShowTimerTextState createState() => _ShowTimerTextState();
|
||||
}
|
||||
|
||||
class _ShowTimerTextState extends State<ShowTimerText> {
|
||||
String timerText = (TIMER_MIN - 1).toString() + ':59';
|
||||
int min = TIMER_MIN - 1;
|
||||
int sec = 59;
|
||||
Timer _timer;
|
||||
|
||||
AuthViewModel authProv;
|
||||
|
||||
resendCode() {
|
||||
min = TIMER_MIN - 1;
|
||||
sec = 59;
|
||||
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
|
||||
if (min <= 0 && sec <= 0) {
|
||||
timer.cancel();
|
||||
} else {
|
||||
setState(() {
|
||||
sec = sec - 1;
|
||||
if (sec == 0 && min == 0) {
|
||||
Navigator.of(context).pushNamed(LOGIN);
|
||||
|
||||
min = 0;
|
||||
sec = 0;
|
||||
} else if (sec == 0) {
|
||||
min = min - 1;
|
||||
sec = 59;
|
||||
}
|
||||
timerText = min.toString() + ':' + sec.toString();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
resendCode();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
authProv = Provider.of<AuthViewModel>(context);
|
||||
return Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: min != 0 || sec != 0
|
||||
? null
|
||||
: () {
|
||||
resendActivatioinCode();
|
||||
},
|
||||
child: Text(
|
||||
timerText,
|
||||
style: TextStyle(
|
||||
fontSize: 3.0 * SizeConfig.textMultiplier,
|
||||
color: HexColor('#B8382C'),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
resendActivatioinCode() {
|
||||
authProv
|
||||
.sendActivationCodeByOtpNotificationType(widget.model)
|
||||
.then((res) => {
|
||||
// print('$value')
|
||||
if (res['MessageStatus'] == 1)
|
||||
{resendCode()}
|
||||
else
|
||||
{Helpers.showErrorToast(res['ErrorEndUserMessage'])}
|
||||
})
|
||||
.catchError((err) {
|
||||
Helpers.showErrorToast();
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,386 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
||||
import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.dart';
|
||||
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
|
||||
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
|
||||
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
|
||||
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
||||
import 'package:doctor_app_flutter/widgets/auth/show_timer_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hexcolor/hexcolor.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../config/size_config.dart';
|
||||
import '../../core/viewModel/auth_view_model.dart';
|
||||
import '../../routes.dart';
|
||||
import '../../util/dr_app_shared_pref.dart';
|
||||
import '../../util/dr_app_toast_msg.dart';
|
||||
import '../../util/helpers.dart';
|
||||
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
|
||||
|
||||
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
||||
Helpers helpers = Helpers();
|
||||
|
||||
class VerifyAccount extends StatefulWidget {
|
||||
VerifyAccount({this.changeLoadingStata});
|
||||
|
||||
final Function changeLoadingStata;
|
||||
|
||||
@override
|
||||
_VerifyAccountState createState() => _VerifyAccountState();
|
||||
}
|
||||
|
||||
class _VerifyAccountState extends State<VerifyAccount> {
|
||||
final verifyAccountForm = GlobalKey<FormState>();
|
||||
Map verifyAccountFormValue = {
|
||||
'digit1': null,
|
||||
'digit2': null,
|
||||
'digit3': null,
|
||||
'digit4': null,
|
||||
};
|
||||
Future _loggedUserFuture;
|
||||
var _loggedUser;
|
||||
AuthViewModel authProv;
|
||||
bool _isInit = true;
|
||||
var model;
|
||||
TextEditingController digit1 = TextEditingController(text: "");
|
||||
TextEditingController digit2 = TextEditingController(text: "");
|
||||
TextEditingController digit3 = TextEditingController(text: "");
|
||||
TextEditingController digit4 = TextEditingController(text: "");
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loggedUserFuture = getSharedPref();
|
||||
}
|
||||
|
||||
Future<void> getSharedPref() async {
|
||||
sharedPref.getObj(LOGGED_IN_USER).then((userInfo) {
|
||||
_loggedUser = userInfo;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (_isInit) {
|
||||
authProv = Provider.of<AuthViewModel>(context);
|
||||
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
|
||||
model = routeArgs['model'];
|
||||
}
|
||||
_isInit = false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
authProv = Provider.of<AuthViewModel>(context);
|
||||
final focusD1 = FocusNode();
|
||||
final focusD2 = FocusNode();
|
||||
final focusD3 = FocusNode();
|
||||
final focusD4 = FocusNode();
|
||||
return FutureBuilder(
|
||||
future: Future.wait([_loggedUserFuture]),
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
switch (snapshot.connectionState) {
|
||||
case ConnectionState.waiting:
|
||||
return DrAppCircularProgressIndeicator();
|
||||
default:
|
||||
if (snapshot.hasError) {
|
||||
DrAppToastMsg.showErrorToast('Error: ${snapshot.error}');
|
||||
return Text('Error: ${snapshot.error}');
|
||||
} else {
|
||||
return Form(
|
||||
key: verifyAccountForm,
|
||||
child: Container(
|
||||
width: SizeConfig.realScreenWidth * 0.95,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
buildSizedBox(30),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: SizeConfig.realScreenWidth * 0.20,
|
||||
child: TextFormField(
|
||||
textInputAction: TextInputAction.next,
|
||||
style: buildTextStyle(),
|
||||
autofocus: true,
|
||||
maxLength: 1,
|
||||
controller: digit1,
|
||||
textAlign: TextAlign.center,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: buildInputDecoration(context),
|
||||
onSaved: (val) {
|
||||
verifyAccountFormValue['digit1'] = val;
|
||||
},
|
||||
validator: validateCodeDigit,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(focusD2);
|
||||
},
|
||||
onChanged: (val) {
|
||||
if (val.length == 1) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(focusD2);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: SizeConfig.realScreenWidth * 0.20,
|
||||
child: TextFormField(
|
||||
focusNode: focusD2,
|
||||
controller: digit2,
|
||||
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);
|
||||
},
|
||||
onChanged: (val) {
|
||||
if (val.length == 1) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(focusD3);
|
||||
}
|
||||
},
|
||||
validator: validateCodeDigit),
|
||||
),
|
||||
Container(
|
||||
width: SizeConfig.realScreenWidth * 0.20,
|
||||
child: TextFormField(
|
||||
focusNode: focusD3,
|
||||
controller: digit3,
|
||||
textInputAction: TextInputAction.next,
|
||||
maxLength: 1,
|
||||
textAlign: TextAlign.center,
|
||||
style: buildTextStyle(),
|
||||
keyboardType: TextInputType.number,
|
||||
decoration:
|
||||
buildInputDecoration(context),
|
||||
onSaved: (val) {
|
||||
verifyAccountFormValue['digit3'] =
|
||||
val;
|
||||
},
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(focusD4);
|
||||
},
|
||||
onChanged: (val) {
|
||||
if (val.length == 1) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(focusD4);
|
||||
}
|
||||
},
|
||||
validator: validateCodeDigit)),
|
||||
Container(
|
||||
width: SizeConfig.realScreenWidth * 0.20,
|
||||
child: TextFormField(
|
||||
focusNode: focusD4,
|
||||
controller: digit4,
|
||||
maxLength: 1,
|
||||
textAlign: TextAlign.center,
|
||||
style: buildTextStyle(),
|
||||
keyboardType: TextInputType.number,
|
||||
decoration:
|
||||
buildInputDecoration(context),
|
||||
onSaved: (val) {
|
||||
verifyAccountFormValue['digit4'] =
|
||||
val;
|
||||
},
|
||||
validator: validateCodeDigit))
|
||||
],
|
||||
),
|
||||
buildSizedBox(20),
|
||||
buildText(),
|
||||
buildSizedBox(40),
|
||||
RaisedButton(
|
||||
onPressed: () {
|
||||
verifyAccount(
|
||||
authProv, widget.changeLoadingStata);
|
||||
},
|
||||
elevation: 0.0,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: Center(
|
||||
child: Text(
|
||||
TranslationBase.of(context).verify,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize:
|
||||
3 * SizeConfig.textMultiplier),
|
||||
),
|
||||
),
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
side: BorderSide(
|
||||
width: 0.5,
|
||||
color: HexColor('#CCCCCC'))),
|
||||
),
|
||||
buildSizedBox(20),
|
||||
ShowTimerText(model: model),
|
||||
buildSizedBox(10),
|
||||
])));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
TextStyle buildTextStyle() {
|
||||
return TextStyle(
|
||||
fontSize: SizeConfig.textMultiplier * 3,
|
||||
);
|
||||
}
|
||||
|
||||
String validateCodeDigit(value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Please enter your Password';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
InputDecoration buildInputDecoration(BuildContext context) {
|
||||
return InputDecoration(
|
||||
contentPadding: EdgeInsets.only(top: 30, bottom: 30),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide: BorderSide(color: Theme.of(context).primaryColor),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide: BorderSide(color: Theme.of(context).errorColor),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderSide: BorderSide(color: Theme.of(context).errorColor),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
RichText buildText() {
|
||||
String medthodName;
|
||||
switch (model['OTP_SendType']) {
|
||||
case 1:
|
||||
medthodName = TranslationBase.of(context).smsBy;
|
||||
break;
|
||||
case 2:
|
||||
medthodName = TranslationBase.of(context).whatsAppBy;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
var text = RichText(
|
||||
text: new TextSpan(
|
||||
style: new TextStyle(
|
||||
fontSize: 3.0 * SizeConfig.textMultiplier, color: Colors.black),
|
||||
children: <TextSpan>[
|
||||
new TextSpan(text: TranslationBase.of(context).youWillReceiveA),
|
||||
new TextSpan(
|
||||
text: TranslationBase.of(context).loginCode,
|
||||
style: TextStyle(fontWeight: FontWeight.w700)),
|
||||
new TextSpan(text: ' ${medthodName},'),
|
||||
TextSpan(text: TranslationBase.of(context).pleaseEnterTheCode)
|
||||
]));
|
||||
return text;
|
||||
}
|
||||
|
||||
SizedBox buildSizedBox([double height = 20]) {
|
||||
return SizedBox(
|
||||
height: height,
|
||||
);
|
||||
}
|
||||
|
||||
verifyAccount(AuthViewModel authProv, Function changeLoadingStata) async {
|
||||
if (verifyAccountForm.currentState.validate()) {
|
||||
changeLoadingStata(true);
|
||||
|
||||
verifyAccountForm.currentState.save();
|
||||
final activationCode = verifyAccountFormValue['digit1'] +
|
||||
verifyAccountFormValue['digit2'] +
|
||||
verifyAccountFormValue['digit3'] +
|
||||
verifyAccountFormValue['digit4'];
|
||||
|
||||
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp =
|
||||
new CheckActivationCodeRequestModel(
|
||||
zipCode: _loggedUser['ZipCode'],
|
||||
mobileNumber: _loggedUser['MobileNumber'],
|
||||
projectID: await sharedPref.getInt(PROJECT_ID),
|
||||
logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID),
|
||||
activationCode: activationCode,
|
||||
generalid: "Cs2020@2016\$2958");
|
||||
|
||||
authProv
|
||||
.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp)
|
||||
.then((res) async {
|
||||
if (res['MessageStatus'] == 1) {
|
||||
sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
|
||||
if (res['List_DoctorProfile'] != null) {
|
||||
loginProcessCompleted(
|
||||
res['List_DoctorProfile'][0], changeLoadingStata);
|
||||
} else {
|
||||
ClinicModel clinic =
|
||||
ClinicModel.fromJson(res['List_DoctorsClinic'][0]);
|
||||
getDocProfiles(clinic, changeLoadingStata);
|
||||
}
|
||||
} else {
|
||||
changeLoadingStata(false);
|
||||
Helpers.showErrorToast(res['ErrorEndUserMessage']);
|
||||
}
|
||||
}).catchError((err) {
|
||||
changeLoadingStata(false);
|
||||
Helpers.showErrorToast(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loginProcessCompleted(
|
||||
Map<String, dynamic> profile, Function changeLoadingStata) {
|
||||
var doctor = DoctorProfileModel.fromJson(profile);
|
||||
authProv.setDoctorProfile(doctor);
|
||||
sharedPref.setObj(DOCTOR_PROFILE, profile);
|
||||
this.getDashboard(doctor, changeLoadingStata);
|
||||
}
|
||||
|
||||
getDashboard(doctor, Function changeLoadingStata) {
|
||||
changeLoadingStata(false);
|
||||
Navigator.of(context).pushReplacementNamed(HOME);
|
||||
}
|
||||
|
||||
getDocProfiles(ClinicModel clinicInfo, Function changeLoadingStata) {
|
||||
ProfileReqModel docInfo = new ProfileReqModel(
|
||||
doctorID: clinicInfo.doctorID,
|
||||
clinicID: clinicInfo.clinicID,
|
||||
license: true,
|
||||
projectID: clinicInfo.projectID,
|
||||
tokenID: '',
|
||||
languageID: 2);
|
||||
authProv.getDocProfiles(docInfo.toJson()).then((res) {
|
||||
if (res['MessageStatus'] == 1) {
|
||||
loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata);
|
||||
} else {
|
||||
changeLoadingStata(false);
|
||||
Helpers.showErrorToast(res['ErrorEndUserMessage']);
|
||||
}
|
||||
}).catchError((err) {
|
||||
changeLoadingStata(false);
|
||||
Helpers.showErrorToast(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue