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

54 lines
1.4 KiB
Dart
Raw Normal View History

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;
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})
: 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));
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),
),
],
);
}
}