|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
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/utils/translations_delegate_base_utils.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, required this.onShowMore, this.authenticationViewModel}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_VerificationMethodsListState createState() => _VerificationMethodsListState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _VerificationMethodsListState extends State<VerificationMethodsList> {
|
|
|
|
|
final LocalAuthentication auth = LocalAuthentication();
|
|
|
|
|
late 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(Platform.isIOS ? BiometricType.fingerprint : BiometricType.strong)) {
|
|
|
|
|
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(Platform.isIOS ? BiometricType.face : BiometricType.strong)) {
|
|
|
|
|
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,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|