Empty state for Recipient Adress Book

This commit is contained in:
Arseni
2025-12-12 19:29:10 +03:00
parent 67b52af150
commit 28d74d058b
4 changed files with 89 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'package:pshared/models/recipient/recipient.dart';
import 'package:pshared/models/recipient/filter.dart';
import 'package:pshared/provider/recipient/provider.dart';
import 'package:pweb/pages/address_book/page/empty.dart';
import 'package:pweb/pages/address_book/page/filter_button.dart';
import 'package:pweb/pages/address_book/page/header.dart';
@@ -72,6 +73,7 @@ class _RecipientAddressBookPageState extends State<RecipientAddressBookPage> {
final loc = AppLocalizations.of(context)!;
final provider = context.watch<RecipientsProvider>();
_syncSearchField(provider);
final filteredRecipients = provider.filteredRecipients;
if (provider.isLoading) {
return const Center(child: CircularProgressIndicator());
@@ -124,15 +126,23 @@ class _RecipientAddressBookPageState extends State<RecipientAddressBookPage> {
height: RecipientAddressBookPage._expandedHeight,
child: Padding(
padding: const EdgeInsets.all(RecipientAddressBookPage._paddingAll),
child: RecipientAddressBookList(
filteredRecipients: provider.filteredRecipients,
onEdit: (recipient) => widget.onEditRecipient?.call(recipient),
onDelete: (recipient) => widget.onDeleteRecipient?.call(recipient),
onSelected: widget.onRecipientSelected,
),
child: provider.recipients.isEmpty
? RecipientAddressBookEmptyState(
message: loc.noRecipientsYet,
actionLabel: loc.addRecipient,
onAction: widget.onAddRecipient,
)
: filteredRecipients.isEmpty
? Center(child: Text(loc.noRecipientsFound))
: RecipientAddressBookList(
filteredRecipients: filteredRecipients,
onEdit: (recipient) => widget.onEditRecipient?.call(recipient),
onDelete: (recipient) => widget.onDeleteRecipient?.call(recipient),
onSelected: widget.onRecipientSelected,
),
),
),
],
);
}
}
}