changed color theme to be black and added the ability to enter the amount in the recipient’s currency
This commit is contained in:
@@ -2,36 +2,49 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/balance_mask/wallets.dart';
|
||||
import 'package:pshared/models/currency.dart';
|
||||
import 'package:pshared/utils/currency.dart';
|
||||
|
||||
import 'package:pweb/controllers/payments/amount_field.dart';
|
||||
import 'package:pweb/models/payment/amount/mode.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/amount/mode/selector.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaymentAmountField extends StatelessWidget {
|
||||
const PaymentAmountField();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final currency = context.select<WalletsController, Currency?>(
|
||||
(c) => c.selectedWallet?.currency,
|
||||
);
|
||||
final symbol = currency == null ? null : currencyCodeToSymbol(currency);
|
||||
|
||||
final ui = context.watch<PaymentAmountFieldController>();
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
final symbol = currencySymbolFromCode(ui.activeCurrencyCode);
|
||||
|
||||
return TextField(
|
||||
controller: ui.textController,
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context)!.amount,
|
||||
border: const OutlineInputBorder(),
|
||||
prefixText: symbol == null ? null : '$symbol\u00A0',
|
||||
),
|
||||
onChanged: ui.handleChanged,
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (ui.isReverseModeAvailable) ...[
|
||||
PaymentAmountModeSelector(
|
||||
selectedMode: ui.mode,
|
||||
onModeChanged: ui.handleModeChanged,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
],
|
||||
TextField(
|
||||
controller: ui.textController,
|
||||
focusNode: ui.focusNode,
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.amount,
|
||||
border: const OutlineInputBorder(),
|
||||
prefixText: symbol == null ? null : '$symbol\u00A0',
|
||||
helperText: switch (ui.mode) {
|
||||
PaymentAmountMode.debit => loc.debitAmountLabel,
|
||||
PaymentAmountMode.settlement => loc.expectedSettlementAmountLabel,
|
||||
},
|
||||
),
|
||||
onChanged: ui.handleChanged,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class ModeButton extends StatelessWidget {
|
||||
final String label;
|
||||
final bool isSelected;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const ModeButton({
|
||||
required this.label,
|
||||
required this.isSelected,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Material(
|
||||
color: isSelected
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.onSecondary,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
|
||||
child: Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isSelected
|
||||
? theme.colorScheme.onSecondary
|
||||
: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pweb/models/payment/amount/mode.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/amount/mode/button.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaymentAmountModeSelector extends StatelessWidget {
|
||||
final PaymentAmountMode selectedMode;
|
||||
final ValueChanged<PaymentAmountMode> onModeChanged;
|
||||
|
||||
const PaymentAmountModeSelector({
|
||||
super.key,
|
||||
required this.selectedMode,
|
||||
required this.onModeChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onSecondary,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ModeButton(
|
||||
label: loc.debitAmountLabel,
|
||||
isSelected: selectedMode == PaymentAmountMode.debit,
|
||||
onTap: () => onModeChanged(PaymentAmountMode.debit),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
Expanded(
|
||||
child: ModeButton(
|
||||
label: loc.expectedSettlementAmountLabel,
|
||||
isSelected: selectedMode == PaymentAmountMode.settlement,
|
||||
onTap: () => onModeChanged(PaymentAmountMode.settlement),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,31 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/balance_mask/wallets.dart';
|
||||
import 'package:pshared/provider/payment/amount.dart';
|
||||
|
||||
import 'package:pweb/controllers/payments/amount_field.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/amount/feild.dart';
|
||||
|
||||
|
||||
class PaymentAmountWidget extends StatelessWidget {
|
||||
const PaymentAmountWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProxyProvider<PaymentAmountProvider, PaymentAmountFieldController>(
|
||||
return ChangeNotifierProxyProvider2<
|
||||
PaymentAmountProvider,
|
||||
WalletsController,
|
||||
PaymentAmountFieldController
|
||||
>(
|
||||
create: (ctx) {
|
||||
final initialAmount = ctx.read<PaymentAmountProvider>().amount;
|
||||
return PaymentAmountFieldController(initialAmount: initialAmount);
|
||||
},
|
||||
update: (ctx, amountProvider, controller) {
|
||||
controller!.update(amountProvider);
|
||||
update: (ctx, amountProvider, wallets, controller) {
|
||||
controller!.update(amountProvider, wallets);
|
||||
return controller;
|
||||
},
|
||||
child: const PaymentAmountField(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,18 @@ class PaymentFormWidget extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
detailsHeader,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: const PaymentAmountWidget(),
|
||||
),
|
||||
const SizedBox(width: _columnSpacing),
|
||||
Expanded(flex: 2, child: quoteCard),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: _smallSpacing),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -109,28 +121,16 @@ class PaymentFormWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const PaymentAmountWidget(),
|
||||
const SizedBox(height: _smallSpacing),
|
||||
FeePayerSwitch(
|
||||
spacing: _smallSpacing,
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: _mediumSpacing),
|
||||
const PaymentSummary(spacing: _extraSpacing),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: _columnSpacing),
|
||||
Expanded(flex: 2, child: quoteCard),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: _mediumSpacing),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Expanded(
|
||||
flex: 3,
|
||||
child: PaymentSummary(spacing: _extraSpacing),
|
||||
),
|
||||
const SizedBox(width: _columnSpacing),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
|
||||
@@ -6,25 +6,42 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
class FileFormatSampleDownloadButton extends StatelessWidget {
|
||||
const FileFormatSampleDownloadButton({
|
||||
super.key,
|
||||
required this.theme,
|
||||
required this.l10n,
|
||||
required this.onPressed,
|
||||
});
|
||||
|
||||
final ThemeData theme;
|
||||
final AppLocalizations l10n;
|
||||
final VoidCallback onPressed;
|
||||
final double buttonWidth = 220;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final linkStyle = theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
final theme = Theme.of(context);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final textStyle = theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontWeight: FontWeight.w500,
|
||||
);
|
||||
|
||||
return TextButton(
|
||||
onPressed: onPressed,
|
||||
style: TextButton.styleFrom(padding: EdgeInsets.zero),
|
||||
child: Text(l10n.downloadSampleCSV, style: linkStyle),
|
||||
return Align(
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(
|
||||
width: buttonWidth,
|
||||
child: FilledButton(
|
||||
onPressed: onPressed,
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
foregroundColor: theme.colorScheme.onPrimary,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
l10n.downloadSampleCSV,
|
||||
textAlign: TextAlign.center,
|
||||
style: textStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,12 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
class FileFormatSampleHeader extends StatelessWidget {
|
||||
const FileFormatSampleHeader({
|
||||
super.key,
|
||||
required this.theme,
|
||||
required this.l10n,
|
||||
});
|
||||
|
||||
final ThemeData theme;
|
||||
final AppLocalizations l10n;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final titleStyle = theme.textTheme.bodyLarge?.copyWith(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
|
||||
@@ -8,15 +8,14 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
class FileFormatSampleTable extends StatelessWidget {
|
||||
const FileFormatSampleTable({
|
||||
super.key,
|
||||
required this.l10n,
|
||||
required this.rows,
|
||||
});
|
||||
|
||||
final AppLocalizations l10n;
|
||||
final List<CsvPayoutRow> rows;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return DataTable(
|
||||
columnSpacing: 20,
|
||||
columns: [
|
||||
|
||||
@@ -9,29 +9,20 @@ import 'package:pweb/pages/dashboard/payouts/multiple/sections/sample/header.dar
|
||||
import 'package:pweb/pages/dashboard/payouts/multiple/sections/sample/table.dart';
|
||||
import 'package:pweb/utils/download.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class FileFormatSampleSection extends StatelessWidget {
|
||||
const FileFormatSampleSection({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
FileFormatSampleHeader(theme: theme, l10n: l10n),
|
||||
FileFormatSampleHeader(),
|
||||
const SizedBox(height: 12),
|
||||
FileFormatSampleTable(l10n: l10n, rows: sampleRows),
|
||||
FileFormatSampleTable(rows: sampleRows),
|
||||
const SizedBox(height: 10),
|
||||
FileFormatSampleDownloadButton(
|
||||
theme: theme,
|
||||
l10n: l10n,
|
||||
onPressed: _downloadSampleCsv,
|
||||
),
|
||||
FileFormatSampleDownloadButton(onPressed: _downloadSampleCsv),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class QuoteStatusCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final foregroundColor = _resolveForegroundColor(theme, statusType);
|
||||
final statusStyle = theme.textTheme.bodyMedium?.copyWith(color: foregroundColor);
|
||||
final elementColor = _resolveElementColor(theme, statusType);
|
||||
final statusStyle = theme.textTheme.bodyMedium?.copyWith(color: elementColor);
|
||||
final helperStyle = theme.textTheme.bodySmall?.copyWith(
|
||||
color: foregroundColor.withValues(alpha: 0.8),
|
||||
);
|
||||
@@ -43,6 +44,9 @@ class QuoteStatusCard extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: _resolveCardColor(theme, statusType),
|
||||
borderRadius: BorderRadius.circular(_cardRadius),
|
||||
border: Border.all(
|
||||
color: elementColor.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -61,7 +65,7 @@ class QuoteStatusCard extends StatelessWidget {
|
||||
: Icon(
|
||||
_resolveIcon(statusType),
|
||||
size: _iconSize,
|
||||
color: foregroundColor,
|
||||
color: elementColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: _cardSpacing),
|
||||
@@ -98,28 +102,36 @@ class QuoteStatusCard extends StatelessWidget {
|
||||
Color _resolveCardColor(ThemeData theme, QuoteStatusType status) {
|
||||
switch (status) {
|
||||
case QuoteStatusType.loading:
|
||||
return theme.colorScheme.secondaryContainer;
|
||||
case QuoteStatusType.active:
|
||||
case QuoteStatusType.missing:
|
||||
return theme.colorScheme.onSecondary;
|
||||
case QuoteStatusType.error:
|
||||
case QuoteStatusType.expired:
|
||||
return theme.colorScheme.errorContainer;
|
||||
case QuoteStatusType.active:
|
||||
return theme.colorScheme.primaryContainer;
|
||||
case QuoteStatusType.missing:
|
||||
return theme.colorScheme.surfaceContainerHighest;
|
||||
}
|
||||
}
|
||||
|
||||
Color _resolveForegroundColor(ThemeData theme, QuoteStatusType status) {
|
||||
switch (status) {
|
||||
case QuoteStatusType.active:
|
||||
case QuoteStatusType.missing:
|
||||
case QuoteStatusType.loading:
|
||||
return theme.colorScheme.onSecondaryContainer;
|
||||
return theme.colorScheme.onSecondary;
|
||||
case QuoteStatusType.error:
|
||||
case QuoteStatusType.expired:
|
||||
return theme.colorScheme.onErrorContainer;
|
||||
}
|
||||
}
|
||||
|
||||
Color _resolveElementColor(ThemeData theme, QuoteStatusType status) {
|
||||
switch (status) {
|
||||
case QuoteStatusType.active:
|
||||
return theme.colorScheme.onPrimaryContainer;
|
||||
case QuoteStatusType.missing:
|
||||
return theme.colorScheme.onSurfaceVariant;
|
||||
case QuoteStatusType.loading:
|
||||
return theme.colorScheme.primary;
|
||||
case QuoteStatusType.error:
|
||||
case QuoteStatusType.expired:
|
||||
return theme.colorScheme.onErrorContainer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/models/recipient/recipient.dart';
|
||||
import 'package:pshared/provider/recipient/provider.dart';
|
||||
|
||||
import 'package:pweb/app/router/payout_routes.dart';
|
||||
import 'package:pweb/pages/address_book/page/search.dart';
|
||||
import 'package:pweb/pages/payout_page/send/widgets/add_recipient_tile.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';
|
||||
@@ -63,6 +67,10 @@ class _AddressBookPayoutState extends State<AddressBookPayout> {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
final provider = context.watch<RecipientsProvider>();
|
||||
final recipients = provider.recipients;
|
||||
void onAddRecipient() {
|
||||
provider.setCurrentObject(null);
|
||||
context.pushNamed(PayoutRoutes.addRecipient);
|
||||
}
|
||||
final filteredRecipients = filterRecipients(
|
||||
recipients: recipients,
|
||||
query: _query,
|
||||
@@ -97,7 +105,12 @@ class _AddressBookPayoutState extends State<AddressBookPayout> {
|
||||
const SizedBox(height: _spacingBetween),
|
||||
Expanded(
|
||||
child: recipients.isEmpty
|
||||
? AddressBookPlaceholder(text: loc.noRecipientsYet)
|
||||
? Center(
|
||||
child: AddRecipientTile(
|
||||
label: loc.addRecipient,
|
||||
onTap: onAddRecipient,
|
||||
),
|
||||
)
|
||||
: _isExpanded && filteredRecipients.isEmpty
|
||||
? AddressBookPlaceholder(text: loc.noRecipientsFound)
|
||||
: _isExpanded
|
||||
@@ -108,6 +121,10 @@ class _AddressBookPayoutState extends State<AddressBookPayout> {
|
||||
: ShortListAddressBookPayout(
|
||||
recipients: recipients,
|
||||
onSelected: widget.onSelected,
|
||||
trailing: AddRecipientTile(
|
||||
label: loc.addRecipient,
|
||||
onTap: onAddRecipient,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user