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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user