yubioath-flutter/lib/fido/views/fingerprint_page.dart

81 lines
2.8 KiB
Dart
Raw Normal View History

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';
import '../models.dart';
import '../state.dart';
2022-03-23 11:49:20 +03:00
import 'add_fingerprint_dialog.dart';
import 'delete_fingerprint_dialog.dart';
import 'rename_fingerprint_dialog.dart';
class FingerprintPage extends ConsumerWidget {
final DevicePath devicePath;
final FidoState state;
const FingerprintPage(this.devicePath, this.state, {Key? key})
: super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
return ref.watch(fingerprintProvider(devicePath)).when(
loading: () => const Center(child: CircularProgressIndicator()),
2022-03-24 14:39:49 +03:00
error: (error, _) => AppFailureScreen('$error'),
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) =>
RenameFingerprintDialog(devicePath, fp),
2022-03-23 19:50:49 +03:00
);
},
icon: const Icon(Icons.edit)),
IconButton(
onPressed: () {
showDialog(
context: context,
builder: (context) =>
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'),
onPressed: () {
showDialog(
context: context,
builder: (context) =>
AddFingerprintDialog(devicePath),
);
},
2022-03-23 19:50:49 +03:00
)
],
),
),
2022-03-23 11:49:20 +03:00
],
),
2022-03-23 19:50:49 +03:00
);
}
}