refactoring for recipient addition page

This commit is contained in:
Arseni
2026-01-29 19:22:30 +03:00
parent da8da04ae9
commit efa69b43b2
47 changed files with 1376 additions and 532 deletions

View File

@@ -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,
),
],