fingerprint auth added
This commit is contained in:
@@ -1,19 +1,33 @@
|
||||
// Bloc
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:tanami_app/core/utils/secure/secure_storage_service.dart';
|
||||
|
||||
import 'toggle_event.dart';
|
||||
import 'toggle_state.dart';
|
||||
|
||||
class ToggleBloc extends Bloc<ToggleEvent, ToggleState> {
|
||||
ToggleBloc() : super(ToggleInitial()) {
|
||||
final String type;
|
||||
|
||||
final SecureStorageService secureStorageService = SecureStorageService();
|
||||
|
||||
ToggleBloc(this.type) : super(ToggleInitial()) {
|
||||
on<ToggleSwitch>(_onToggleSwitch);
|
||||
_initializeToggleState();
|
||||
}
|
||||
|
||||
void _onToggleSwitch(ToggleSwitch event, Emitter<ToggleState> emit) {
|
||||
void _onToggleSwitch(ToggleSwitch event, Emitter<ToggleState> emit) async {
|
||||
if (state is ToggleOn) {
|
||||
emit(ToggleOff());
|
||||
await secureStorageService.write(type, 'off');
|
||||
} else {
|
||||
emit(ToggleOn());
|
||||
await secureStorageService.write(type, 'on');
|
||||
}
|
||||
}
|
||||
|
||||
void _initializeToggleState() async {
|
||||
final toggleValue = await secureStorageService.read(type);
|
||||
if (toggleValue == 'on') {
|
||||
add(ToggleSwitch()); // Initializing the state by adding an event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ class CheckBoxWidget extends StatelessWidget {
|
||||
return Checkbox(
|
||||
activeColor: AppColor.checkBoxActiveColor,
|
||||
checkColor: Colors.white,
|
||||
side: MaterialStateBorderSide.resolveWith(
|
||||
side: WidgetStateBorderSide.resolveWith(
|
||||
(states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return const BorderSide(
|
||||
color: AppColor.checkBoxActiveColor, width: 2);
|
||||
}
|
||||
|
||||
138
lib/shared/components/device_locked_dialog.dart
Normal file
138
lib/shared/components/device_locked_dialog.dart
Normal file
@@ -0,0 +1,138 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:tanami_app/core/routes/routes.dart';
|
||||
import 'package:tanami_app/core/styles/app_color.dart';
|
||||
import 'package:tanami_app/core/styles/app_text.dart';
|
||||
import 'package:tanami_app/core/utils/biometric/biometric_bloc.dart';
|
||||
|
||||
import '../../core/utils/biometric/biometric_event.dart';
|
||||
import '../../core/utils/biometric/biometric_state.dart';
|
||||
import 'text_widget.dart';
|
||||
|
||||
deviceLockedDialog(
|
||||
context,
|
||||
) {
|
||||
return showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (context) => WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: BlocBuilder<BiometricBloc, BiometricState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AlertDialog(
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
backgroundColor: AppColor.plainWhite,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
side: BorderSide(
|
||||
color: AppColor.plainWhite,
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Align(
|
||||
alignment: Alignment.center,
|
||||
child: CircleAvatar(
|
||||
radius: 25,
|
||||
backgroundColor: AppColor.inactiveBtnColor,
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.lock,
|
||||
size: 25,
|
||||
color: AppColor.primaryColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Gap(22.h),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||
child: TextWidget().text17W700(
|
||||
AppText.tanamiAppIsLocked,
|
||||
clr: AppColor.textLabelColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Gap(5),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Container(
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||
child: TextWidget().text14W400(
|
||||
AppText.securityMssgText,
|
||||
clr: AppColor.textLabelColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
Gap(21.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
SystemNavigator.pop();
|
||||
},
|
||||
child: Container(
|
||||
height: 48.h,
|
||||
width: 140.w,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: AppColor.primaryColor,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10.h),
|
||||
color: AppColor.plainWhite,
|
||||
),
|
||||
child: Center(
|
||||
child: TextWidget().text18W700(
|
||||
AppText.cancelText,
|
||||
clr: AppColor.primaryColor2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Gap(15.w),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
goRouter.pop();
|
||||
context
|
||||
.read<BiometricBloc>()
|
||||
.add(AuthenticateBiometricEvent());
|
||||
},
|
||||
child: Container(
|
||||
height: 48.h,
|
||||
width: 140.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.h),
|
||||
color: AppColor.primaryColor),
|
||||
child: Center(
|
||||
child: TextWidget().text18W700(
|
||||
AppText.unlockText,
|
||||
clr: AppColor.plainWhite,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
138
lib/shared/components/permission_dialog.dart
Normal file
138
lib/shared/components/permission_dialog.dart
Normal file
@@ -0,0 +1,138 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:tanami_app/core/styles/app_color.dart';
|
||||
|
||||
import '../../core/routes/route_name.dart';
|
||||
import '../../core/routes/routes.dart';
|
||||
import '../../core/styles/app_text.dart';
|
||||
import '../../core/utils/secure/secure_storage_service.dart';
|
||||
import 'text_widget.dart';
|
||||
import 'toast_message.dart';
|
||||
|
||||
permissionDialog(
|
||||
context,
|
||||
) {
|
||||
final SecureStorageService secureStorageService = SecureStorageService();
|
||||
|
||||
return showDialog(
|
||||
barrierDismissible: true,
|
||||
context: context,
|
||||
builder: (context) => WillPopScope(
|
||||
onWillPop: () async {
|
||||
return true;
|
||||
},
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AlertDialog(
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
// insetPadding: const EdgeInsets.all(0),
|
||||
backgroundColor: AppColor.plainWhite,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(14)),
|
||||
side: BorderSide(
|
||||
color: AppColor.plainWhite,
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(20),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||
child: TextWidget().text17W600(
|
||||
AppText.biometricText,
|
||||
clr: AppColor.plainBlack,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Gap(5),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 30),
|
||||
child: TextWidget().text13W400(
|
||||
AppText.appAskPermissionText,
|
||||
txtAlign: TextAlign.center,
|
||||
clr: AppColor.plainBlack,
|
||||
),
|
||||
),
|
||||
),
|
||||
Gap(21.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 1.sw,
|
||||
height: 1,
|
||||
decoration: const BoxDecoration(color: Color(0x5B3C3C43)),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
successToastMessage(context, "successful !");
|
||||
goRouter.pop();
|
||||
|
||||
goRouter.goNamed(RouteName.pinScreen, pathParameters: {
|
||||
"fromScreen": "register",
|
||||
});
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 48.h,
|
||||
width: 140.w,
|
||||
child: Center(
|
||||
child: TextWidget().text17W600(
|
||||
AppText.declineText,
|
||||
clr: AppColor.permissionTextClr,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
height: 50,
|
||||
decoration: const BoxDecoration(color: Color(0x5B3C3C43)),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await secureStorageService.write("biometric", 'on');
|
||||
successToastMessage(
|
||||
context, "Biometric/Face Id Enabled Sucessfully !");
|
||||
// successToastMessage(context, "successful !");
|
||||
goRouter.pop();
|
||||
|
||||
goRouter.goNamed(RouteName.pinScreen, pathParameters: {
|
||||
"fromScreen": "register",
|
||||
});
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 48.h,
|
||||
width: 140.w,
|
||||
child: Center(
|
||||
child: TextWidget().text17W600(
|
||||
AppText.allowText,
|
||||
clr: AppColor.permissionTextClr,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -76,6 +76,18 @@ class TextWidget {
|
||||
}
|
||||
|
||||
//Text Size 13
|
||||
Widget text13W400(String text, {Color? clr, TextAlign? txtAlign}) {
|
||||
return Text(
|
||||
text,
|
||||
textAlign: txtAlign ?? TextAlign.start,
|
||||
style: GoogleFonts.dmSans(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: clr ?? AppColor.plainWhite,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget text13W500(String text, {Color? clr}) {
|
||||
return Text(
|
||||
text,
|
||||
|
||||
Reference in New Issue
Block a user