Refresh button for balance

This commit is contained in:
Arseni
2025-12-30 18:36:29 +03:00
parent 202582626a
commit b157522fdb
8 changed files with 148 additions and 17 deletions

View File

@@ -8,6 +8,7 @@ import 'package:pweb/pages/dashboard/buttons/balance/amount.dart';
import 'package:pweb/pages/dashboard/buttons/balance/config.dart';
import 'package:pweb/pages/dashboard/buttons/balance/header.dart';
import 'package:pshared/provider/payment/wallets.dart';
import 'package:pweb/widgets/wallet_balance_refresh_button.dart';
class WalletCard extends StatelessWidget {
@@ -37,11 +38,18 @@ class WalletCard extends StatelessWidget {
walletNetwork: wallet.network,
tokenSymbol: wallet.tokenSymbol,
),
BalanceAmount(
wallet: wallet,
onToggleVisibility: () {
context.read<WalletsProvider>().toggleVisibility(wallet.id);
},
Row(
children: [
BalanceAmount(
wallet: wallet,
onToggleVisibility: () {
context.read<WalletsProvider>().toggleVisibility(wallet.id);
},
),
WalletBalanceRefreshButton(
walletId: wallet.id,
),
],
),
BalanceAddFunds(
onTopUp: () {

View File

@@ -1,7 +1,10 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pshared/models/payment/wallet.dart';
import 'package:pshared/models/recipient/recipient.dart';
import 'package:pshared/provider/payment/wallets.dart';
import 'package:pshared/provider/recipient/provider.dart';
import 'package:pweb/pages/payment_methods/payment_page/back_button.dart';
@@ -14,6 +17,7 @@ import 'package:pweb/pages/payment_methods/widgets/recipient_section.dart';
import 'package:pweb/pages/payment_methods/widgets/section_title.dart';
import 'package:pweb/utils/dimensions.dart';
import 'package:pweb/widgets/sidebar/destinations.dart';
import 'package:pweb/widgets/wallet_balance_refresh_button.dart';
import 'package:pweb/generated/i18n/app_localizations.dart';
@@ -74,7 +78,20 @@ class PaymentPageContent extends StatelessWidget {
SizedBox(height: dimensions.paddingSmall),
PaymentHeader(),
SizedBox(height: dimensions.paddingXXLarge),
SectionTitle(loc.sourceOfFunds),
Row(
children: [
Expanded(child: SectionTitle(loc.sourceOfFunds)),
Consumer<WalletsProvider>(
builder: (context, provider, _) {
final selectedWalletId = provider.selectedWallet?.id;
if (selectedWalletId == null) {
return const SizedBox.shrink();
}
return WalletBalanceRefreshButton(walletId: selectedWalletId);
},
),
],
),
SizedBox(height: dimensions.paddingSmall),
PaymentMethodSelector(
onMethodChanged: onWalletSelected,

View File

@@ -5,8 +5,10 @@ import 'package:provider/provider.dart';
import 'package:pshared/utils/currency.dart';
import 'package:pshared/models/payment/wallet.dart';
import 'package:pshared/provider/payment/wallets.dart';
import 'package:pweb/models/visibility.dart';
import 'package:pweb/pages/dashboard/buttons/balance/amount.dart';
import 'package:pweb/widgets/wallet_balance_refresh_button.dart';
import 'package:pweb/generated/i18n/app_localizations.dart';
@@ -43,11 +45,20 @@ class WalletCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BalanceAmount(
wallet: wallet,
onToggleVisibility: () {
context.read<WalletsProvider>().toggleVisibility(wallet.id);
},
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BalanceAmount(
wallet: wallet,
onToggleVisibility: () {
context.read<WalletsProvider>().toggleVisibility(wallet.id);
},
),
WalletBalanceRefreshButton(
walletId: wallet.id,
iconOnly: VisibilityState.hidden,
),
],
),
Text(
AppLocalizations.of(context)!.paymentTypeCryptoWallet,

View File

@@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
import 'package:pshared/provider/payment/wallets.dart';
import 'package:pweb/pages/dashboard/buttons/balance/amount.dart';
import 'package:pweb/widgets/wallet_balance_refresh_button.dart';
class WalletEditFields extends StatelessWidget {
@@ -26,12 +27,15 @@ class WalletEditFields extends StatelessWidget {
children: [
Row(
children: [
BalanceAmount(
wallet: wallet,
onToggleVisibility: () {
context.read<WalletsProvider>().toggleVisibility(wallet.id);
},
Expanded(
child: BalanceAmount(
wallet: wallet,
onToggleVisibility: () {
context.read<WalletsProvider>().toggleVisibility(wallet.id);
},
),
),
WalletBalanceRefreshButton(walletId: wallet.id),
],
),
const SizedBox(height: 8),
@@ -51,4 +55,4 @@ class WalletEditFields extends StatelessWidget {
},
);
}
}
}