2021-11-22 11:49:52 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../../app/models.dart';
|
|
|
|
import '../models.dart';
|
|
|
|
import 'account_view.dart';
|
|
|
|
|
|
|
|
class AccountList extends StatelessWidget {
|
2022-01-18 17:46:42 +03:00
|
|
|
final YubiKeyData deviceData;
|
2021-11-22 11:49:52 +03:00
|
|
|
final List<OathPair> credentials;
|
2021-12-03 17:15:00 +03:00
|
|
|
final List<String> favorites;
|
2022-01-18 17:46:42 +03:00
|
|
|
const AccountList(this.deviceData, this.credentials, this.favorites,
|
|
|
|
{Key? key})
|
2021-11-22 11:49:52 +03:00
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
if (credentials.isEmpty) {
|
|
|
|
return const Center(
|
|
|
|
child: Text('No credentials'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-03 17:15:00 +03:00
|
|
|
final favCreds =
|
|
|
|
credentials.where((entry) => favorites.contains(entry.credential.id));
|
|
|
|
final creds =
|
|
|
|
credentials.where((entry) => !favorites.contains(entry.credential.id));
|
|
|
|
|
2021-11-22 11:49:52 +03:00
|
|
|
return ListView(
|
|
|
|
children: [
|
2021-12-03 17:15:00 +03:00
|
|
|
if (favCreds.isNotEmpty)
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
'FAVORITES',
|
|
|
|
style: Theme.of(context).textTheme.bodyText2,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
...favCreds.map(
|
2022-01-18 17:46:42 +03:00
|
|
|
(entry) => AccountView(deviceData, entry.credential, entry.code),
|
2021-12-03 17:15:00 +03:00
|
|
|
),
|
|
|
|
if (creds.isNotEmpty)
|
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
'ACCOUNTS',
|
|
|
|
style: Theme.of(context).textTheme.bodyText2,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
...creds.map(
|
2022-01-18 17:46:42 +03:00
|
|
|
(entry) => AccountView(deviceData, entry.credential, entry.code),
|
2021-11-22 11:49:52 +03:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|