|
|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
import 'dart:collection';
|
|
|
|
|
import 'dart:ffi';
|
|
|
|
|
|
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.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:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
|
|
DrAppSharedPreferances SharedPref = new DrAppSharedPreferances();
|
|
|
|
|
@ -16,13 +19,16 @@ 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<void> getSharedPref() async {
|
|
|
|
|
SharedPref.getObj('loggedUser').then((userInfo) {
|
|
|
|
|
// if(loggedUser == null){}
|
|
|
|
|
loggedUser = userInfo;
|
|
|
|
|
print('dddddddddddddddd${loggedUser}');
|
|
|
|
|
// print('dddddddddddddddd${loggedUser}');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -41,7 +47,6 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
|
|
|
|
|
return FutureBuilder(
|
|
|
|
|
future: loggedUserFuture,
|
|
|
|
|
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
|
|
|
|
print('SnapShot ${snapshot}');
|
|
|
|
|
switch (snapshot.connectionState) {
|
|
|
|
|
case ConnectionState.waiting:
|
|
|
|
|
return DrAppCircularProgressIndeicator();
|
|
|
|
|
@ -151,16 +156,14 @@ 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 FingerPRint ${_authorized}".toUpperCase(),
|
|
|
|
|
// textAlign: TextAlign.center,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
@ -207,7 +210,50 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
|
|
|
|
|
Navigator.of(context).pushNamed('routeName');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
silentLogin(){
|
|
|
|
|
|
|
|
|
|
silentLogin() {
|
|
|
|
|
_authenticate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> _authenticate() async {
|
|
|
|
|
_getAvailableBiometrics();
|
|
|
|
|
bool authenticated = false;
|
|
|
|
|
try {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isAuthenticating = true;
|
|
|
|
|
_authorized = 'Authenticating';
|
|
|
|
|
});
|
|
|
|
|
authenticated = await auth.authenticateWithBiometrics(
|
|
|
|
|
localizedReason: 'Scan your fingerprint to authenticate',
|
|
|
|
|
useErrorDialogs: true,
|
|
|
|
|
stickyAuth: true);
|
|
|
|
|
setState(() {
|
|
|
|
|
_isAuthenticating = false;
|
|
|
|
|
_authorized = 'Authenticating';
|
|
|
|
|
});
|
|
|
|
|
} on PlatformException catch (e) {
|
|
|
|
|
print(e);
|
|
|
|
|
}
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
|
|
final String message = authenticated ? 'Authorized' : 'Not Authorized';
|
|
|
|
|
setState(() {
|
|
|
|
|
print('_authorized'+_authorized);
|
|
|
|
|
_authorized = message;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _getAvailableBiometrics() async {
|
|
|
|
|
List<BiometricType> availableBiometrics;
|
|
|
|
|
try {
|
|
|
|
|
availableBiometrics = await auth.getAvailableBiometrics();
|
|
|
|
|
} on PlatformException catch (e) {
|
|
|
|
|
print(e);
|
|
|
|
|
}
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
print('availableBiometrics $availableBiometrics');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|