73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
import '../../../../core/routes/route_name.dart';
|
|
import '../../../../core/routes/routes.dart';
|
|
import '../../../../core/styles/app_images.dart';
|
|
import '../../../../shared/components/device_locked_dialog.dart';
|
|
import '../bloc/biometric_bloc.dart';
|
|
import '../bloc/biometric_event.dart';
|
|
import '../bloc/biometric_state.dart';
|
|
|
|
class BiometricLayout extends StatelessWidget {
|
|
const BiometricLayout({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
String biometricImage = "";
|
|
if (Platform.isIOS) {
|
|
biometricImage = AppImages.biometricFace;
|
|
} else {
|
|
biometricImage = AppImages.biometricFingerprint;
|
|
}
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
body: BlocConsumer<BiometricBloc, BiometricState>(
|
|
listener: (context, state) {
|
|
if (state is BiometricChecked && state.canAuthenticate) {
|
|
context.read<BiometricBloc>().add(AuthenticateBiometricEvent());
|
|
} else if (state is BiometricFailed) {
|
|
deviceLockedDialog(context);
|
|
} else if (state is BiometricAuthenticated) {
|
|
goRouter.goNamed(RouteName.pinScreen, pathParameters: {
|
|
"fromScreen": "LoginedInUser",
|
|
});
|
|
}
|
|
},
|
|
builder: (context, state) {
|
|
return SizedBox(
|
|
width: 1.sw,
|
|
height: 1.sh,
|
|
child: Stack(
|
|
children: [
|
|
Positioned.fill(
|
|
child: SvgPicture.asset(
|
|
height: 1.sh,
|
|
width: 1.sw,
|
|
AppImages.biometricBg,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
Positioned.fill(
|
|
child: Align(
|
|
alignment: Alignment.center,
|
|
child: Image.asset(
|
|
biometricImage,
|
|
width: 133,
|
|
height: 155,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|