Skip to content

Commit 6401a9d

Browse files
committed
Create verification_dialog.dart
1 parent cf5cc29 commit 6401a9d

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import 'package:cardabase/util/vibration_provider.dart';
2+
import 'package:cardabase/util/widgets/custom_snack_bar.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:hive_ce_flutter/hive_ce_flutter.dart';
5+
6+
Future<bool> showPasswordVerificationDialog(BuildContext context) async {
7+
final theme = Theme.of(context);
8+
final TextEditingController controller = TextEditingController();
9+
final passwordbox = Hive.box('password');
10+
11+
final result = await showDialog<bool>(
12+
context: context,
13+
builder: (context) => AlertDialog(
14+
title: Text(
15+
'Enter Password',
16+
style: theme.textTheme.bodyLarge?.copyWith(
17+
color: theme.colorScheme.inverseSurface,
18+
fontSize: 30,
19+
),
20+
),
21+
content: Column(
22+
mainAxisSize: MainAxisSize.min,
23+
children: [
24+
TextFormField(
25+
controller: controller,
26+
obscureText: true,
27+
decoration: InputDecoration(
28+
border: OutlineInputBorder(
29+
borderRadius: BorderRadius.circular(10),
30+
borderSide: const BorderSide(width: 2.0),
31+
),
32+
focusColor: theme.colorScheme.primary,
33+
enabledBorder: OutlineInputBorder(
34+
borderSide: BorderSide(
35+
color: theme.colorScheme.primary,
36+
),
37+
borderRadius: BorderRadius.circular(10),
38+
),
39+
labelStyle: theme.textTheme.bodyLarge?.copyWith(
40+
color: theme.colorScheme.secondary,
41+
),
42+
prefixIcon: Icon(
43+
Icons.password,
44+
color: theme.colorScheme.secondary,
45+
),
46+
labelText: 'Password',
47+
),
48+
style: theme.textTheme.bodyLarge?.copyWith(
49+
color: theme.colorScheme.tertiary,
50+
fontWeight: FontWeight.bold,
51+
),
52+
),
53+
const SizedBox(height: 20),
54+
Center(
55+
child: OutlinedButton(
56+
onPressed: () {
57+
if (controller.text == passwordbox.get('PW')) {
58+
FocusScope.of(context).unfocus();
59+
60+
Future.delayed(const Duration(milliseconds: 100), () {
61+
Navigator.pop(context, true);
62+
});
63+
} else {
64+
VibrationProvider.vibrateSuccess();
65+
ScaffoldMessenger.of(context).showSnackBar(
66+
buildCustomSnackBar('Incorrect password!', false),
67+
);
68+
}
69+
},
70+
style: OutlinedButton.styleFrom(
71+
elevation: 0.0,
72+
side: BorderSide(
73+
color: theme.colorScheme.primary,
74+
width: 2.0,
75+
),
76+
shape: RoundedRectangleBorder(
77+
borderRadius: BorderRadius.circular(11),
78+
),
79+
),
80+
child: Text(
81+
'VERIFY',
82+
style: theme.textTheme.bodyLarge?.copyWith(
83+
fontWeight: FontWeight.bold,
84+
fontSize: 15,
85+
),
86+
),
87+
),
88+
),
89+
],
90+
),
91+
),
92+
);
93+
94+
return result ?? false;
95+
}

0 commit comments

Comments
 (0)