-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpasskey_verify.dart
More file actions
65 lines (61 loc) · 2.12 KB
/
passkey_verify.dart
File metadata and controls
65 lines (61 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import 'package:corbado_auth/corbado_auth.dart';
import 'package:corbado_auth_example/screens/helper.dart';
import 'package:corbado_auth_example/widgets/filled_text_button.dart';
import 'package:corbado_auth_example/widgets/generic_error.dart';
import 'package:corbado_auth_example/widgets/outlined_text_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class PasskeyVerifyScreen extends HookWidget implements CorbadoScreen<PasskeyVerifyBlock> {
final PasskeyVerifyBlock block;
PasskeyVerifyScreen(this.block);
Widget build(BuildContext context) {
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((_) {
final maybeError = block.error;
if (maybeError != null) {
showNotificationError(context, maybeError.translatedError);
}
});
}, [block.error]);
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
MaybeGenericError(message: block.error?.translatedError),
const SizedBox(height: 10),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
child: Text(
'Login with your passkey',
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
height: 50,
child:
FilledTextButton(
isLoading: block.data.primaryLoading,
onTap: () async {
await block.passkeyVerify();
},
content: 'Login with passkey',
),
),
const SizedBox(height: 10),
if (block.data.preferredFallback != null) SizedBox(
width: double.infinity,
height: 50,
child: OutlinedTextButton(
onTap: () => block.data.preferredFallback!.onTap(),
content: block.data.preferredFallback!.label,
),
) else Container(),
const SizedBox(height: 10),
],
);
}
}