veilidchat/lib/pages/main_pager/account_page.dart

89 lines
2.8 KiB
Dart
Raw Normal View History

2023-08-05 01:00:46 -04:00
import 'package:awesome_extensions/awesome_extensions.dart';
2023-07-28 20:36:05 -04:00
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_translate/flutter_translate.dart';
2023-08-04 01:00:38 -04:00
import '../../components/contact_invitation_list_widget.dart';
2023-07-29 10:55:35 -04:00
import '../../components/contact_list_widget.dart';
2023-07-28 20:36:05 -04:00
import '../../entities/local_account.dart';
import '../../entities/proto.dart' as proto;
2023-08-04 01:00:38 -04:00
import '../../providers/contact.dart';
2023-08-05 23:58:13 -04:00
import '../../providers/contact_invite.dart';
2023-09-23 12:56:54 -04:00
import '../../tools/theme_service.dart';
2023-09-23 22:19:53 -04:00
import '../../tools/tools.dart';
2023-08-01 00:39:50 -04:00
import '../../veilid_support/veilid_support.dart';
2023-07-28 20:36:05 -04:00
class AccountPage extends ConsumerStatefulWidget {
2023-09-23 12:56:54 -04:00
const AccountPage({
required this.localAccounts,
required this.activeUserLogin,
required this.account,
super.key,
});
final IList<LocalAccount> localAccounts;
final TypedKey activeUserLogin;
final proto.Account account;
2023-07-28 20:36:05 -04:00
@override
AccountPageState createState() => AccountPageState();
}
class AccountPageState extends ConsumerState<AccountPage> {
final _unfocusNode = FocusNode();
@override
void initState() {
super.initState();
}
@override
void dispose() {
_unfocusNode.dispose();
super.dispose();
}
2023-09-23 12:56:54 -04:00
@override
2023-07-28 20:36:05 -04:00
// ignore: prefer_expression_function_bodies
2023-09-23 12:56:54 -04:00
Widget build(BuildContext context) {
final theme = Theme.of(context);
final textTheme = theme.textTheme;
final scale = theme.extension<ScaleScheme>()!;
2023-07-28 20:36:05 -04:00
2023-08-04 01:00:38 -04:00
final contactInvitationRecordList =
ref.watch(fetchContactInvitationRecordsProvider).asData?.value ??
const IListConst([]);
final contactList = ref.watch(fetchContactListProvider).asData?.value ??
const IListConst([]);
2023-09-23 22:19:53 -04:00
return SizedBox(
child: Column(children: <Widget>[
2023-08-04 01:00:38 -04:00
if (contactInvitationRecordList.isNotEmpty)
2023-08-05 01:00:46 -04:00
ExpansionTile(
2023-09-23 12:56:54 -04:00
tilePadding: EdgeInsets.fromLTRB(8, 0, 8, 0),
backgroundColor: scale.primaryScale.subtleBorder,
collapsedBackgroundColor: scale.primaryScale.subtleBorder,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
collapsedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
title: Text(
translate('account_page.contact_invitations'),
textAlign: TextAlign.center,
style: textTheme.titleMedium!
.copyWith(color: scale.primaryScale.subtleText),
),
2023-08-05 01:00:46 -04:00
initiallyExpanded: true,
children: [
ContactInvitationListWidget(
contactInvitationRecordList: contactInvitationRecordList)
],
2023-09-23 12:56:54 -04:00
).paddingLTRB(8, 0, 8, 8),
2023-08-05 01:00:46 -04:00
ContactListWidget(contactList: contactList).expanded(),
2023-09-23 22:19:53 -04:00
]));
2023-07-28 20:36:05 -04:00
}
}