2021-11-22 11:49:52 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
|
|
|
import '../../app/models.dart';
|
|
|
|
import '../state.dart';
|
|
|
|
import 'account_list.dart';
|
|
|
|
|
|
|
|
class OathScreen extends ConsumerWidget {
|
|
|
|
final DeviceNode device;
|
|
|
|
const OathScreen(this.device, {Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final state = ref.watch(oathStateProvider(device.path));
|
|
|
|
|
|
|
|
if (state == null) {
|
2021-12-07 16:22:28 +03:00
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: const [
|
|
|
|
Center(child: CircularProgressIndicator()),
|
|
|
|
],
|
|
|
|
);
|
2021-11-22 11:49:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state.locked) {
|
2021-12-07 16:22:28 +03:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
2021-11-22 11:49:52 +03:00
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
2021-11-25 17:39:09 +03:00
|
|
|
const Text('YubiKey locked'),
|
|
|
|
TextField(
|
|
|
|
obscureText: true,
|
|
|
|
decoration: const InputDecoration(labelText: 'Password'),
|
|
|
|
onSubmitted: (value) {
|
|
|
|
ref.read(oathStateProvider(device.path).notifier).unlock(value);
|
|
|
|
},
|
|
|
|
),
|
2021-11-22 11:49:52 +03:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
final accounts = ref.watch(credentialListProvider(device.path));
|
|
|
|
if (accounts == null) {
|
|
|
|
return Column(
|
2021-12-07 16:22:28 +03:00
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
2021-11-22 11:49:52 +03:00
|
|
|
children: const [
|
2021-12-07 16:22:28 +03:00
|
|
|
Center(child: CircularProgressIndicator()),
|
2021-11-22 11:49:52 +03:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2021-12-02 13:44:17 +03:00
|
|
|
return AccountList(
|
|
|
|
device,
|
|
|
|
ref.watch(filteredCredentialsProvider(accounts)),
|
2021-12-03 17:15:00 +03:00
|
|
|
ref.watch(favoritesProvider),
|
2021-11-22 11:49:52 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|