2022-03-22 16:23:12 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
|
|
|
import '../../app/models.dart';
|
2022-03-24 14:39:49 +03:00
|
|
|
import '../../app/views/app_failure_screen.dart';
|
2022-03-22 16:23:12 +03:00
|
|
|
import '../models.dart';
|
|
|
|
import '../state.dart';
|
2022-03-23 11:49:20 +03:00
|
|
|
import 'add_fingerprint_dialog.dart';
|
2022-03-22 16:23:12 +03:00
|
|
|
import 'delete_fingerprint_dialog.dart';
|
|
|
|
import 'rename_fingerprint_dialog.dart';
|
|
|
|
|
|
|
|
class FingerprintPage extends ConsumerWidget {
|
2022-03-28 13:58:45 +03:00
|
|
|
final DevicePath devicePath;
|
2022-03-22 16:23:12 +03:00
|
|
|
final FidoState state;
|
|
|
|
|
2022-03-28 13:58:45 +03:00
|
|
|
const FingerprintPage(this.devicePath, this.state, {Key? key})
|
|
|
|
: super(key: key);
|
2022-03-22 16:23:12 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2022-03-28 13:58:45 +03:00
|
|
|
return ref.watch(fingerprintProvider(devicePath)).when(
|
2022-03-24 00:55:18 +03:00
|
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
2022-03-24 14:39:49 +03:00
|
|
|
error: (error, _) => AppFailureScreen('$error'),
|
2022-03-24 00:55:18 +03:00
|
|
|
data: (fingerprints) => ListView(
|
2022-03-23 19:50:49 +03:00
|
|
|
children: [
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
'FINGERPRINTS',
|
|
|
|
style: Theme.of(context).textTheme.bodyText2,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
...fingerprints.map((fp) => ListTile(
|
|
|
|
title: Text(fp.label),
|
|
|
|
trailing: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) =>
|
2022-03-28 13:58:45 +03:00
|
|
|
RenameFingerprintDialog(devicePath, fp),
|
2022-03-23 19:50:49 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.edit)),
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) =>
|
2022-03-28 13:58:45 +03:00
|
|
|
DeleteFingerprintDialog(devicePath, fp),
|
2022-03-23 19:50:49 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.delete)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
child: Wrap(
|
|
|
|
children: [
|
|
|
|
OutlinedButton.icon(
|
|
|
|
icon: const Icon(Icons.fingerprint),
|
|
|
|
label: const Text('Add fingerprint'),
|
2022-03-22 16:23:12 +03:00
|
|
|
onPressed: () {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
2022-03-28 13:58:45 +03:00
|
|
|
builder: (context) =>
|
|
|
|
AddFingerprintDialog(devicePath),
|
2022-03-22 16:23:12 +03:00
|
|
|
);
|
|
|
|
},
|
2022-03-23 19:50:49 +03:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2022-03-22 16:23:12 +03:00
|
|
|
),
|
2022-03-23 11:49:20 +03:00
|
|
|
],
|
|
|
|
),
|
2022-03-23 19:50:49 +03:00
|
|
|
);
|
2022-03-22 16:23:12 +03:00
|
|
|
}
|
|
|
|
}
|