implement basic verifecation type

merge-requests/1/merge
Elham Rababah 6 years ago
parent 5bdae16684
commit cfa0162109

@ -9,7 +9,7 @@ const LOGIN_URL =
'https://hmgwebservices.com/Services/Sentry.svc/REST/MemberLogIN_New';
const INSERT_DEVICE_IMEI =
'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI';
const SELECT_DEVICE_IMEI ='https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI';
class AuthProvider with ChangeNotifier {
Future<Map> login(UserModel userInfo) async {
Map<String, String> requestHeaders = {
@ -54,4 +54,21 @@ class AuthProvider with ChangeNotifier {
throw error;
}
}
Future<Map> selectDeviceImei(imei) async {
Map<String, String> requestHeaders = {
'Content-type': 'application/json',
'Accept': 'application/json',
};
const url = SELECT_DEVICE_IMEI;
try {
final response = await http.post(url,
headers: requestHeaders, body: json.encode(imei));
return Future.value(json.decode(response.body));
} catch (error) {
print(error);
throw error;
}
}
}

@ -1,20 +1,22 @@
import 'dart:collection';
import 'dart:ffi';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:doctor_app_flutter/lookups/auth_lookup.dart';
import 'package:doctor_app_flutter/providers/auth_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../config/config.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();
DrAppToastMsg toastMsg = DrAppToastMsg();
class KnownUserLogin extends StatefulWidget {
@override
_KnownUserLoginState createState() => _KnownUserLoginState();
@ -23,32 +25,49 @@ class KnownUserLogin extends StatefulWidget {
class _KnownUserLoginState extends State<KnownUserLogin> {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
final LocalAuthentication auth = LocalAuthentication();
String _authorized = "not Authorized";
bool _isAuthenticating = false;
Future<String> loggedUserFuture;
var loggedUser;
Future<String> _loggedUserFuture;
var _loggedUser;
int _loginType;
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('loggedUser').then((userInfo) {
// if(loggedUser == null){}
loggedUser = userInfo;
// print('dddddddddddddddd${loggedUser}');
_loggedUser = userInfo;
});
}
@override
void initState() {
super.initState();
loggedUserFuture = _prefs.then((SharedPreferences prefs) {
_loggedUserFuture = _prefs.then((SharedPreferences prefs) {
return (prefs.getString('platformImei'));
});
}
@override
Widget build(BuildContext context) {
getSharedPref();
AuthProvider authProv = Provider.of<AuthProvider>(context);
selectDeviceImei(authProv);
return FutureBuilder(
future: loggedUserFuture,
future: _loggedUserFuture,
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
@ -99,7 +118,7 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
CrossAxisAlignment.start,
children: <Widget>[
Text(
loggedUser['List_MemberInformation'][0]
_loggedUser['List_MemberInformation'][0]
['MemberName'],
style: TextStyle(
color: Hexcolor('515A5D'),
@ -130,15 +149,7 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
fit: BoxFit.cover,
))
]),
Container(
height: 200,
width: 200,
child: Center(
child: Image.asset(
'assets/images/verification_fingerprint_lg_icon.png',
fit: BoxFit.cover,
),
)),
buildVerificationTypeImageContainer(),
buildButtonsContainer(
isSmallScreen, constraints, context)
],
@ -150,6 +161,19 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
});
}
Container buildVerificationTypeImageContainer() {
print('${_loginTypeMap[_loginType]}');
return Container(
height: 200,
width: 200,
child: Center(
child: Image.asset(
_loginTypeMap[_loginType]['imageUrl'],
fit: BoxFit.cover,
),
));
}
//
Container buildButtonsContainer(
bool isSmallScreen, BoxConstraints constraints, BuildContext context) {
@ -159,14 +183,15 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
child: Column(
children: <Widget>[
RaisedButton(
onPressed: _silentLogin,
onPressed: _authenticate,
elevation: 0.0,
child: Container(
width: double.infinity,
height: 50,
child: Center(
child: Text(
"Verify using FingerPRint".toUpperCase(),
"Verify using ${_loginTypeMap[_loginType]['name']}"
.toUpperCase(),
// textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
@ -213,14 +238,22 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
Navigator.of(context).pushNamed('routeName');
}
_silentLogin() {
_authenticate().then((_) {
// print('$val');
print(_authorized);
});
_authenticate(){
if(_loginType ==1) {
_authenticateBySMS();
}
if(_loginType ==2) {
_authenticateByFingerPrint();
}
if(_loginType ==3) {
_authenticateByFace();
}
if(_loginType ==4) {
_authenticateByWhatsApp();
}
}
Future<void> _authenticate() async {
Future<void> _authenticateByFingerPrint() async {
_getAvailableBiometrics();
bool authenticated = false;
try {
@ -252,6 +285,17 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
});
}
Future<void> _authenticateBySMS(){
print('_authenticateBySMS');
}
Future<void> _authenticateByFace(){
print('_authenticateByFace');
}
Future<void> _authenticateByWhatsApp(){
print('_authenticateByWhatsApp');
}
Future<void> _getAvailableBiometrics() async {
List<BiometricType> availableBiometrics;
try {
@ -273,4 +317,19 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
showErorrMsg(localMsg) {
toastMsg.showErrorToast(localMsg);
}
selectDeviceImei(AuthProvider authProv) {
sharedPref.getString('platformImei').then((imei) {
var imeiModel = {'IMEI': imei};
authProv.selectDeviceImei(imeiModel).then((res) {
// setState(() {
_loginType = 4;//res['SELECTDeviceIMEIbyIMEI_List'][0]['LogInType'];
// });
print(_loginType.toString());
}).catchError((err) {
print('${err}');
});
});
}
}

@ -63,6 +63,9 @@ flutter:
- assets/images/login_btn_arrow_icon.png
- assets/images/dr_avatar.png
- assets/images/verification_fingerprint_lg_icon.png
- assets/images/verification_faceid_lg_icon.png
- assets/images/verification_sms_lg_icon.png
- assets/images/verification_whatsapp_lg_icon.png
- assets/images/close_icon.png
# - images/a_dot_ham.jpeg

Loading…
Cancel
Save