Added Localizations and ran small fixes
This commit is contained in:
71
frontend/pweb/lib/pages/payment_methods/widgets/search.dart
Normal file
71
frontend/pweb/lib/pages/payment_methods/widgets/search.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/recipient/recipient.dart';
|
||||
|
||||
import 'package:pweb/providers/recipient.dart';
|
||||
import 'package:pweb/utils/dimensions.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class RecipientSearchResults extends StatelessWidget {
|
||||
final AppDimensions dimensions;
|
||||
final RecipientProvider recipientProvider;
|
||||
final ValueChanged<Recipient> onRecipientSelected;
|
||||
|
||||
const RecipientSearchResults({
|
||||
super.key,
|
||||
required this.dimensions,
|
||||
required this.recipientProvider,
|
||||
required this.onRecipientSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
if (recipientProvider.isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (recipientProvider.error != null) {
|
||||
return Text(
|
||||
loc.notificationError(recipientProvider.error ?? loc.noErrorInformation),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
);
|
||||
}
|
||||
|
||||
if (recipientProvider.recipients.isEmpty) {
|
||||
return Text(loc.noRecipientsYet);
|
||||
}
|
||||
|
||||
final results = recipientProvider.filteredRecipients;
|
||||
|
||||
if (results.isEmpty) {
|
||||
return Text(loc.noRecipientsFound);
|
||||
}
|
||||
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 240),
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
itemCount: results.length,
|
||||
separatorBuilder: (_, _) => SizedBox(height: dimensions.paddingSmall),
|
||||
itemBuilder: (context, index) {
|
||||
final recipient = results[index];
|
||||
return ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(dimensions.borderRadiusSmall),
|
||||
),
|
||||
leading: CircleAvatar(
|
||||
child: Text(recipient.name.substring(0, 1).toUpperCase()),
|
||||
),
|
||||
title: Text(recipient.name),
|
||||
subtitle: Text(recipient.email),
|
||||
trailing: const Icon(Icons.arrow_forward_ios_rounded, size: 16),
|
||||
onTap: () => onRecipientSelected(recipient),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user