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.
142 lines
4.6 KiB
Dart
142 lines
4.6 KiB
Dart
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
import 'package:hmg_nurses/classes/colors.dart';
|
|
import 'package:hmg_nurses/classes/enums.dart';
|
|
import 'package:hmg_nurses/classes/size_config.dart';
|
|
import 'package:hmg_nurses/generated/locale_keys.g.dart';
|
|
|
|
import 'package:local_auth/local_auth.dart';
|
|
|
|
class VerificationMethodsList extends StatelessWidget {
|
|
final AuthMethodTypes authMethodType;
|
|
final Function(AuthMethodTypes type, bool isActive)? authenticateUser;
|
|
final Function? onShowMore;
|
|
final bool isBioAvailable;
|
|
|
|
const VerificationMethodsList({
|
|
Key? key,
|
|
required this.authMethodType,
|
|
this.authenticateUser,
|
|
this.onShowMore,
|
|
this.isBioAvailable = true,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
switch (authMethodType) {
|
|
case AuthMethodTypes.whatsApp:
|
|
return MethodTypeCard(
|
|
assetPath: 'assets/images/login/verify_whatsapp.svg',
|
|
onTap: () => {authenticateUser!(AuthMethodTypes.whatsApp, true)},
|
|
label: LocaleKeys.verifyThroughWhatsapp.tr(),
|
|
isBioAvailable: isBioAvailable,
|
|
);
|
|
case AuthMethodTypes.sms:
|
|
return MethodTypeCard(
|
|
assetPath: "assets/images/login/verify_sms.svg",
|
|
onTap: () => {authenticateUser!(AuthMethodTypes.sms, true)},
|
|
label: LocaleKeys.verifyThroughSMS.tr(),
|
|
isBioAvailable: isBioAvailable,
|
|
);
|
|
case AuthMethodTypes.fingerPrint:
|
|
return MethodTypeCard(
|
|
assetPath: 'assets/images/login/verify_thumb.svg',
|
|
onTap: () => {authenticateUser!(AuthMethodTypes.fingerPrint, true)},
|
|
label: LocaleKeys.verifyThroughFingerprint.tr(),
|
|
isBioAvailable: isBioAvailable,
|
|
);
|
|
case AuthMethodTypes.faceID:
|
|
return MethodTypeCard(
|
|
assetPath: 'assets/images/login/verify_face.svg',
|
|
onTap: () => {authenticateUser!(AuthMethodTypes.faceID, true)},
|
|
label: LocaleKeys.verifyThroughFace.tr(),
|
|
isBioAvailable: isBioAvailable,
|
|
);
|
|
|
|
default:
|
|
return MethodTypeCard(
|
|
assetPath: 'assets/images/login/more_icon.png',
|
|
onTap: () {
|
|
onShowMore!();
|
|
},
|
|
isSvg: false,
|
|
label: LocaleKeys.moreVerificationOpts.tr(),
|
|
height: 0,
|
|
isBioAvailable: isBioAvailable,
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
class MethodTypeCard extends StatelessWidget {
|
|
const MethodTypeCard({
|
|
Key? key,
|
|
required this.assetPath,
|
|
required this.onTap,
|
|
required this.label,
|
|
this.height = 20,
|
|
this.isSvg = true,
|
|
required this.isBioAvailable,
|
|
}) : super(key: key);
|
|
final String assetPath;
|
|
final GestureTapCallback onTap;
|
|
final String label;
|
|
final double height;
|
|
final bool isSvg;
|
|
final bool isBioAvailable;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
double cardHeight = SizeConfig.heightMultiplier! *
|
|
(SizeConfig.isHeightVeryShort
|
|
? 22
|
|
: SizeConfig.isHeightLarge
|
|
? 25
|
|
: 20);
|
|
return InkWell(
|
|
onTap: onTap,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: isBioAvailable ? Colors.white : Colors.grey[400],
|
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
|
border: Border.all(color: HexColor('#707070'), width: 0.1),
|
|
),
|
|
height: cardHeight,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
isSvg
|
|
? SvgPicture.asset(assetPath, width: SizeConfig.widthMultiplier! * (14), height: cardHeight * 0.20)
|
|
: Image.asset(
|
|
assetPath,
|
|
width: SizeConfig.widthMultiplier! * (12),
|
|
height: cardHeight * 0.35,
|
|
// height: ,
|
|
),
|
|
SizedBox(
|
|
height: height,
|
|
),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isHeightVeryShort ? 3 : 3.7),
|
|
color: MyColors.darkTextColor,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.48,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|