You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RSGDoctorApp/lib/widgets/auth/verification_methods_list.dart

98 lines
3.4 KiB
Dart

import 'package:doctor_app_flutter/core/enum/auth_method_types.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/auth/method_type_card.dart';
import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
class VerificationMethodsList extends StatefulWidget {
final AuthMethodTypes authMethodType;
final Function(AuthMethodTypes type, bool isActive) authenticateUser;
final Function onShowMore;
final AuthenticationViewModel authenticationViewModel;
const VerificationMethodsList(
{Key key,
this.authMethodType,
this.authenticateUser,
this.onShowMore,
this.authenticationViewModel})
: super(key: key);
@override
_VerificationMethodsListState createState() =>
_VerificationMethodsListState();
}
class _VerificationMethodsListState extends State<VerificationMethodsList> {
final LocalAuthentication auth = LocalAuthentication();
ProjectViewModel projectsProvider;
@override
Widget build(BuildContext context) {
projectsProvider = Provider.of<ProjectViewModel>(context);
switch (widget.authMethodType) {
case AuthMethodTypes.WhatsApp:
return MethodTypeCard(
assetPath: 'assets/images/svgs/verification/verify-whtsapp.svg',
onTap: () =>
{widget.authenticateUser(AuthMethodTypes.WhatsApp, true)},
label: TranslationBase
.of(context)
.verifyWith+ TranslationBase.of(context).verifyWhatsApp,
);
break;
case AuthMethodTypes.SMS:
return MethodTypeCard(
assetPath: "assets/images/svgs/verification/verify-sms.svg",
onTap: () => {widget.authenticateUser(AuthMethodTypes.SMS, true)},
label:TranslationBase
.of(context)
.verifyWith+ TranslationBase.of(context).verifySMS,
);
break;
case AuthMethodTypes.Fingerprint:
return MethodTypeCard(
assetPath: 'assets/images/svgs/verification/verify-finger.svg',
onTap: () async {
if (await widget.authenticationViewModel
.checkIfBiometricAvailable(BiometricType.fingerprint)) {
widget.authenticateUser(AuthMethodTypes.Fingerprint, true);
}
},
label: TranslationBase
.of(context)
.verifyWith+TranslationBase.of(context).verifyFingerprint,
);
break;
case AuthMethodTypes.FaceID:
return MethodTypeCard(
assetPath: 'assets/images/svgs/verification/verify-face.svg',
onTap: () async {
if (await widget.authenticationViewModel
.checkIfBiometricAvailable(BiometricType.face)) {
widget.authenticateUser(AuthMethodTypes.FaceID, true);
}
},
label: TranslationBase
.of(context)
.verifyWith+TranslationBase.of(context).verifyFaceID,
);
break;
default:
return MethodTypeCard(
assetPath: 'assets/images/login/more_icon.png',
onTap: widget.onShowMore,
isSvg: false,
label: TranslationBase.of(context).moreVerification,
height: 0,
);
}
}
}