refactoring for recipient addition page
This commit is contained in:
@@ -14,8 +14,11 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
class RecipientSection extends StatelessWidget {
|
||||
final Recipient? recipient;
|
||||
final Recipient? previousRecipient;
|
||||
final AppDimensions dimensions;
|
||||
final RecipientsProvider recipientProvider;
|
||||
final String searchQuery;
|
||||
final List<Recipient> filteredRecipients;
|
||||
final TextEditingController searchController;
|
||||
final FocusNode searchFocusNode;
|
||||
final ValueChanged<String> onSearchChanged;
|
||||
@@ -25,8 +28,11 @@ class RecipientSection extends StatelessWidget {
|
||||
const RecipientSection({
|
||||
super.key,
|
||||
required this.recipient,
|
||||
required this.previousRecipient,
|
||||
required this.dimensions,
|
||||
required this.recipientProvider,
|
||||
required this.searchQuery,
|
||||
required this.filteredRecipients,
|
||||
required this.searchController,
|
||||
required this.searchFocusNode,
|
||||
required this.onSearchChanged,
|
||||
@@ -48,8 +54,8 @@ class RecipientSection extends StatelessWidget {
|
||||
return AnimatedBuilder(
|
||||
animation: recipientProvider,
|
||||
builder: (context, _) {
|
||||
final previousRecipient = recipientProvider.previousRecipient;
|
||||
final hasQuery = recipientProvider.query.isNotEmpty;
|
||||
final hasQuery = searchQuery.isNotEmpty;
|
||||
final prev = previousRecipient;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -61,15 +67,15 @@ class RecipientSection extends StatelessWidget {
|
||||
onChanged: onSearchChanged,
|
||||
focusNode: searchFocusNode,
|
||||
),
|
||||
if (previousRecipient != null) ...[
|
||||
if (prev != null) ...[
|
||||
SizedBox(height: dimensions.paddingSmall),
|
||||
ListTile(
|
||||
dense: true,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const Icon(Icons.undo),
|
||||
title: Text(loc.back),
|
||||
subtitle: Text(previousRecipient.name),
|
||||
onTap: () => onRecipientSelected(previousRecipient),
|
||||
subtitle: Text(prev.name),
|
||||
onTap: () => onRecipientSelected(prev),
|
||||
),
|
||||
],
|
||||
if (hasQuery) ...[
|
||||
@@ -77,6 +83,7 @@ class RecipientSection extends StatelessWidget {
|
||||
RecipientSearchResults(
|
||||
dimensions: dimensions,
|
||||
recipientProvider: recipientProvider,
|
||||
results: filteredRecipients,
|
||||
onRecipientSelected: onRecipientSelected,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user