Merge pull request 'Empty state for Recipient Address Book' (#110) from SEND007 into main
Reviewed-on: #110
This commit was merged in pull request #110.
This commit is contained in:
@@ -92,7 +92,7 @@ RouteBase payoutShellRoute() => ShellRoute(
|
||||
pageBuilder: (context, _) {
|
||||
final recipient = context.read<RecipientsProvider>().currentObject;
|
||||
return NoTransitionPage(
|
||||
child: AdressBookRecipientForm(
|
||||
child: AddressBookRecipientForm(
|
||||
recipient: recipient,
|
||||
onSaved: (_) => context.goToPayout(PayoutDestination.recipients),
|
||||
),
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:pweb/pages/payment_methods/form.dart';
|
||||
import 'package:pweb/pages/payment_methods/icon.dart';
|
||||
|
||||
|
||||
class AdressBookPaymentMethodTile extends StatefulWidget {
|
||||
class AddressBookPaymentMethodTile extends StatefulWidget {
|
||||
final PaymentType type;
|
||||
final String title;
|
||||
final MethodMap methods;
|
||||
@@ -18,7 +18,7 @@ class AdressBookPaymentMethodTile extends StatefulWidget {
|
||||
final double sizeM;
|
||||
final TextStyle? titleTextStyle;
|
||||
|
||||
const AdressBookPaymentMethodTile({
|
||||
const AddressBookPaymentMethodTile({
|
||||
super.key,
|
||||
required this.type,
|
||||
required this.title,
|
||||
@@ -31,10 +31,10 @@ class AdressBookPaymentMethodTile extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
State<AdressBookPaymentMethodTile> createState() => _AdressBookPaymentMethodTileState();
|
||||
State<AddressBookPaymentMethodTile> createState() => _AddressBookPaymentMethodTileState();
|
||||
}
|
||||
|
||||
class _AdressBookPaymentMethodTileState extends State<AdressBookPaymentMethodTile> {
|
||||
class _AddressBookPaymentMethodTileState extends State<AddressBookPaymentMethodTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
@@ -21,17 +21,17 @@ import 'package:pweb/utils/snackbar.dart';
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class AdressBookRecipientForm extends StatefulWidget {
|
||||
class AddressBookRecipientForm extends StatefulWidget {
|
||||
final Recipient? recipient;
|
||||
final ValueChanged<Recipient?>? onSaved;
|
||||
|
||||
const AdressBookRecipientForm({super.key, this.recipient, this.onSaved});
|
||||
const AddressBookRecipientForm({super.key, this.recipient, this.onSaved});
|
||||
|
||||
@override
|
||||
State<AdressBookRecipientForm> createState() => _AdressBookRecipientFormState();
|
||||
State<AddressBookRecipientForm> createState() => _AddressBookRecipientFormState();
|
||||
}
|
||||
|
||||
class _AdressBookRecipientFormState extends State<AdressBookRecipientForm> {
|
||||
class _AddressBookRecipientFormState extends State<AddressBookRecipientForm> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late TextEditingController _nameCtrl;
|
||||
late TextEditingController _emailCtrl;
|
||||
|
||||
@@ -103,7 +103,7 @@ class FormView extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: spacingFields),
|
||||
...PaymentType.values.map(
|
||||
(p) => AdressBookPaymentMethodTile(
|
||||
(p) => AddressBookPaymentMethodTile(
|
||||
type: p,
|
||||
title: getPaymentTypeLabel(context, p),
|
||||
methods: methods,
|
||||
|
||||
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,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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import 'package:pweb/pages/address_book/page/recipient/actions.dart';
|
||||
import 'package:pweb/pages/address_book/page/recipient/info_column.dart';
|
||||
import 'package:pweb/pages/address_book/page/recipient/payment_row.dart';
|
||||
import 'package:pweb/pages/address_book/page/recipient/status.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/avatar.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/avatar.dart';
|
||||
|
||||
|
||||
class RecipientAddressBookItem extends StatefulWidget {
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:pshared/models/recipient/recipient.dart';
|
||||
import 'package:pshared/provider/organizations.dart';
|
||||
import 'package:pshared/provider/recipient/pmethods.dart';
|
||||
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/avatar.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/long_list/info_row.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/avatar.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/long_list/info_row.dart';
|
||||
import 'package:pweb/utils/payment/label.dart';
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/recipient/recipient.dart';
|
||||
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/long_list/item.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/long_list/item.dart';
|
||||
|
||||
|
||||
class LongListAdressBookPayout extends StatelessWidget {
|
||||
class LongListAddressBookPayout extends StatelessWidget {
|
||||
final List<Recipient> filteredRecipients;
|
||||
final ValueChanged<Recipient>? onSelected;
|
||||
|
||||
const LongListAdressBookPayout({
|
||||
const LongListAddressBookPayout({
|
||||
super.key,
|
||||
required this.filteredRecipients,
|
||||
this.onSelected,
|
||||
@@ -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,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/recipient/recipient.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/avatar.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/avatar.dart';
|
||||
|
||||
|
||||
class ShortListAdressBookPayout extends StatelessWidget {
|
||||
class ShortListAddressBookPayout extends StatelessWidget {
|
||||
final List<Recipient> recipients;
|
||||
final ValueChanged<Recipient> onSelected;
|
||||
|
||||
const ShortListAdressBookPayout({
|
||||
const ShortListAddressBookPayout({
|
||||
super.key,
|
||||
required this.recipients,
|
||||
required this.onSelected,
|
||||
@@ -6,25 +6,26 @@ import 'package:pshared/models/recipient/recipient.dart';
|
||||
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/short_list.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/long_list/widget.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/placeholder.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/short_list.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class AdressBookPayout extends StatefulWidget {
|
||||
class AddressBookPayout extends StatefulWidget {
|
||||
final ValueChanged<Recipient> onSelected;
|
||||
|
||||
const AdressBookPayout({
|
||||
const AddressBookPayout({
|
||||
super.key,
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AdressBookPayout> createState() => _AdressBookPayoutState();
|
||||
State<AddressBookPayout> createState() => _AddressBookPayoutState();
|
||||
}
|
||||
|
||||
class _AdressBookPayoutState extends State<AdressBookPayout> {
|
||||
class _AddressBookPayoutState extends State<AddressBookPayout> {
|
||||
static const double _expandedHeight = 400;
|
||||
static const double _collapsedHeight = 200;
|
||||
static const double _cardMargin = 1;
|
||||
@@ -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,15 +90,19 @@ class _AdressBookPayoutState extends State<AdressBookPayout> {
|
||||
),
|
||||
const SizedBox(height: _spacingBetween),
|
||||
Expanded(
|
||||
child: _isExpanded
|
||||
? LongListAdressBookPayout(
|
||||
filteredRecipients: provider.filteredRecipients,
|
||||
onSelected: widget.onSelected,
|
||||
)
|
||||
: ShortListAdressBookPayout(
|
||||
recipients: provider.recipients,
|
||||
onSelected: widget.onSelected,
|
||||
),
|
||||
child: recipients.isEmpty
|
||||
? AddressBookPlaceholder(text: loc.noRecipientsYet)
|
||||
: _isExpanded && filteredRecipients.isEmpty
|
||||
? AddressBookPlaceholder(text: loc.noRecipientsFound)
|
||||
: _isExpanded
|
||||
? LongListAddressBookPayout(
|
||||
filteredRecipients: filteredRecipients,
|
||||
onSelected: widget.onSelected,
|
||||
)
|
||||
: ShortListAddressBookPayout(
|
||||
recipients: recipients,
|
||||
onSelected: widget.onSelected,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -103,4 +110,4 @@ class _AdressBookPayoutState extends State<AdressBookPayout> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/recipient/recipient.dart';
|
||||
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/avatar.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/avatar.dart';
|
||||
|
||||
|
||||
class RecipientHeader extends StatelessWidget{
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:pshared/models/payment/type.dart';
|
||||
import 'package:pshared/models/recipient/recipient.dart';
|
||||
|
||||
import 'package:pweb/pages/dashboard/payouts/single/adress_book/widget.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/address_book/widget.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/single/new_recipient/payout.dart';
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class SinglePayoutForm extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AdressBookPayout(onSelected: onRecipientSelected),
|
||||
AddressBookPayout(onSelected: onRecipientSelected),
|
||||
const SizedBox(height: _spacingBetweenAddressAndForm),
|
||||
SinglePayout(onGoToPayment: onGoToPayment),
|
||||
const SizedBox(height: _bottomSpacing),
|
||||
|
||||
Reference in New Issue
Block a user