yubioath-flutter/lib/oath/views/reset_dialog.dart

55 lines
1.8 KiB
Dart
Raw Normal View History

2022-01-21 13:30:14 +03:00
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../app/views/responsive_dialog.dart';
2022-01-21 17:45:04 +03:00
import '../state.dart';
2022-01-21 13:30:14 +03:00
import '../../app/models.dart';
import '../../app/state.dart';
class ResetDialog extends ConsumerWidget {
final DeviceNode device;
const ResetDialog(this.device, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
// If current device changes, we need to pop back to the main Page.
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
Navigator.of(context).pop();
});
return ResponsiveDialog(
title: const Text('Factory reset'),
child: Column(
2022-01-21 13:30:14 +03:00
children: [
const Text(
'Warning! This will irrevocably delete all OATH TOTP/HOTP accounts from your YubiKey.'),
Text(
2022-02-22 15:15:49 +03:00
'Your OATH credentials, as well as any password set, will be removed from this YubiKey. Make sure to first disable these from their respective web sites to avoid being locked out of your accounts.',
2022-01-21 13:30:14 +03:00
style: Theme.of(context).textTheme.bodyText1,
),
]
.map((e) => Padding(
child: e,
padding: const EdgeInsets.symmetric(vertical: 8.0),
))
.toList(),
2022-01-21 13:30:14 +03:00
),
actions: [
TextButton(
2022-01-21 13:30:14 +03:00
onPressed: () async {
await ref.read(oathStateProvider(device.path).notifier).reset();
Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('OATH application reset'),
duration: Duration(seconds: 2),
),
);
},
child: const Text('Reset'),
2022-01-21 13:30:14 +03:00
),
],
);
}
}