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 { final LocalAuthentication auth = LocalAuthentication(); ProjectViewModel projectsProvider; @override Widget build(BuildContext context) { projectsProvider = Provider.of(context); switch (widget.authMethodType) { case AuthMethodTypes.WhatsApp: return MethodTypeCard( assetPath: 'assets/images/verify-whtsapp.png', onTap: () => {widget.authenticateUser(AuthMethodTypes.WhatsApp, true)}, label: TranslationBase.of(context).verifyWhatsApp, ); break; case AuthMethodTypes.SMS: return MethodTypeCard( assetPath: "assets/images/verify-sms.png", onTap: () => {widget.authenticateUser(AuthMethodTypes.SMS, true)}, label: TranslationBase.of(context).verifySMS, ); break; case AuthMethodTypes.Fingerprint: return MethodTypeCard( assetPath: 'assets/images/verification_fingerprint_icon.png', onTap: () async { if (await widget.authenticationViewModel .checkIfBiometricAvailable(BiometricType.fingerprint)) { widget.authenticateUser(AuthMethodTypes.Fingerprint, true); } }, label: TranslationBase.of(context).verifyFingerprint, ); break; case AuthMethodTypes.FaceID: return MethodTypeCard( assetPath: 'assets/images/verification_faceid_icon.png', onTap: () async { if (await widget.authenticationViewModel .checkIfBiometricAvailable(BiometricType.face)) { widget.authenticateUser(AuthMethodTypes.FaceID, true); } }, label: TranslationBase.of(context).verifyFaceID, ); break; default: return MethodTypeCard( assetPath: 'assets/images/login/more_icon.png', onTap: widget.onShowMore, label: TranslationBase.of(context).moreVerification, ); } } }