Empty state for Recipient Adress Book
This commit is contained in:
37
frontend/pweb/lib/pages/address_book/page/empty.dart
Normal file
37
frontend/pweb/lib/pages/address_book/page/empty.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class RecipientAddressBookEmptyState extends StatelessWidget {
|
||||
final String message;
|
||||
final String actionLabel;
|
||||
final VoidCallback onAction;
|
||||
|
||||
const RecipientAddressBookEmptyState({
|
||||
required this.message,
|
||||
required this.actionLabel,
|
||||
required this.onAction,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.contact_mail_outlined, size: 42),
|
||||
const SizedBox(height: 12),
|
||||
Text(message, style: textTheme.titleMedium),
|
||||
const SizedBox(height: 12),
|
||||
OutlinedButton.icon(
|
||||
onPressed: onAction,
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(actionLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,8 +126,16 @@ class _RecipientAddressBookPageState extends State<RecipientAddressBookPage> {
|
||||
height: RecipientAddressBookPage._expandedHeight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(RecipientAddressBookPage._paddingAll),
|
||||
child: RecipientAddressBookList(
|
||||
filteredRecipients: provider.filteredRecipients,
|
||||
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,
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class AddressBookPlaceholder extends StatelessWidget {
|
||||
final String text;
|
||||
|
||||
const AddressBookPlaceholder({required this.text});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import 'package:pshared/provider/recipient/provider.dart';
|
||||
|
||||
import 'package:pweb/pages/address_book/page/search.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/long_list/widget.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/placeholder.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/short_list.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
@@ -58,6 +59,8 @@ class _AdressBookPayoutState extends State<AdressBookPayout> {
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
final provider = context.watch<RecipientsProvider>();
|
||||
final recipients = provider.recipients;
|
||||
final filteredRecipients = provider.filteredRecipients;
|
||||
|
||||
if (provider.isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
@@ -87,13 +90,17 @@ class _AdressBookPayoutState extends State<AdressBookPayout> {
|
||||
),
|
||||
const SizedBox(height: _spacingBetween),
|
||||
Expanded(
|
||||
child: _isExpanded
|
||||
child: recipients.isEmpty
|
||||
? AddressBookPlaceholder(text: loc.noRecipientsYet)
|
||||
: _isExpanded && filteredRecipients.isEmpty
|
||||
? AddressBookPlaceholder(text: loc.noRecipientsFound)
|
||||
: _isExpanded
|
||||
? LongListAdressBookPayout(
|
||||
filteredRecipients: provider.filteredRecipients,
|
||||
filteredRecipients: filteredRecipients,
|
||||
onSelected: widget.onSelected,
|
||||
)
|
||||
: ShortListAdressBookPayout(
|
||||
recipients: provider.recipients,
|
||||
recipients: recipients,
|
||||
onSelected: widget.onSelected,
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user