solyanka iz fix for payout page design, ledger wallet now clickable
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
|
||||
import 'package:pshared/models/ledger/account.dart';
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
|
||||
import 'package:pweb/pages/dashboard/buttons/balance/add/card.dart';
|
||||
@@ -10,13 +11,13 @@ import 'package:pweb/pages/dashboard/buttons/balance/config.dart';
|
||||
import 'package:pweb/pages/dashboard/buttons/balance/indicator.dart';
|
||||
import 'package:pweb/pages/dashboard/buttons/balance/ledger.dart';
|
||||
|
||||
|
||||
class BalanceCarousel extends StatefulWidget {
|
||||
final List<BalanceItem> items;
|
||||
final int currentIndex;
|
||||
final ValueChanged<int> onIndexChanged;
|
||||
final ValueChanged<Wallet> onTopUp;
|
||||
final ValueChanged<Wallet> onWalletTap;
|
||||
final ValueChanged<LedgerAccount> onLedgerTap;
|
||||
|
||||
const BalanceCarousel({
|
||||
super.key,
|
||||
@@ -25,6 +26,7 @@ class BalanceCarousel extends StatefulWidget {
|
||||
required this.onIndexChanged,
|
||||
required this.onTopUp,
|
||||
required this.onWalletTap,
|
||||
required this.onLedgerTap,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -105,7 +107,10 @@ class _BalanceCarouselState extends State<BalanceCarousel> {
|
||||
onTopUp: () => widget.onTopUp(item.wallet!),
|
||||
onTap: () => widget.onWalletTap(item.wallet!),
|
||||
),
|
||||
BalanceItemType.ledger => LedgerAccountCard(account: item.account!),
|
||||
BalanceItemType.ledger => LedgerAccountCard(
|
||||
account: item.account!,
|
||||
onTap: () => widget.onLedgerTap(item.account!),
|
||||
),
|
||||
BalanceItemType.addAction => const AddBalanceCard(),
|
||||
};
|
||||
|
||||
@@ -123,19 +128,16 @@ class _BalanceCarouselState extends State<BalanceCarousel> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: safeIndex > 0
|
||||
? () => _goToPage(safeIndex - 1)
|
||||
: null,
|
||||
onPressed: safeIndex > 0 ? () => _goToPage(safeIndex - 1) : null,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
CarouselIndicator(
|
||||
itemCount: widget.items.length,
|
||||
index: safeIndex,
|
||||
),
|
||||
CarouselIndicator(itemCount: widget.items.length, index: safeIndex),
|
||||
const SizedBox(width: 16),
|
||||
IconButton(
|
||||
onPressed: safeIndex < widget.items.length - 1 ? () => _goToPage(safeIndex + 1) : null,
|
||||
onPressed: safeIndex < widget.items.length - 1
|
||||
? () => _goToPage(safeIndex + 1)
|
||||
: null,
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -16,8 +16,9 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
class LedgerAccountCard extends StatelessWidget {
|
||||
final LedgerAccount account;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const LedgerAccountCard({super.key, required this.account});
|
||||
const LedgerAccountCard({super.key, required this.account, this.onTap});
|
||||
|
||||
String _formatBalance() {
|
||||
final money = account.balance?.balance;
|
||||
@@ -73,50 +74,58 @@ class LedgerAccountCard extends StatelessWidget {
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(WalletCardConfig.borderRadius),
|
||||
),
|
||||
child: Padding(
|
||||
padding: WalletCardConfig.contentPadding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BalanceHeader(title: title, subtitle: subtitle, badge: badge),
|
||||
Row(
|
||||
children: [
|
||||
Consumer<LedgerBalanceMaskController>(
|
||||
builder: (context, controller, _) {
|
||||
final isMasked = controller.isBalanceMasked(
|
||||
account.ledgerAccountRef,
|
||||
);
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
isMasked ? _formatMaskedBalance() : _formatBalance(),
|
||||
style: textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.onSurface,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(WalletCardConfig.borderRadius),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: WalletCardConfig.contentPadding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BalanceHeader(title: title, subtitle: subtitle, badge: badge),
|
||||
Row(
|
||||
children: [
|
||||
Consumer<LedgerBalanceMaskController>(
|
||||
builder: (context, controller, _) {
|
||||
final isMasked = controller.isBalanceMasked(
|
||||
account.ledgerAccountRef,
|
||||
);
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
isMasked
|
||||
? _formatMaskedBalance()
|
||||
: _formatBalance(),
|
||||
style: textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GestureDetector(
|
||||
onTap: () => controller.toggleBalanceMask(
|
||||
account.ledgerAccountRef,
|
||||
const SizedBox(width: 12),
|
||||
GestureDetector(
|
||||
onTap: () => controller.toggleBalanceMask(
|
||||
account.ledgerAccountRef,
|
||||
),
|
||||
child: Icon(
|
||||
isMasked
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
size: 24,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
isMasked ? Icons.visibility_off : Icons.visibility,
|
||||
size: 24,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
LedgerBalanceRefreshButton(
|
||||
ledgerAccountRef: account.ledgerAccountRef,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
LedgerBalanceRefreshButton(
|
||||
ledgerAccountRef: account.ledgerAccountRef,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/balance_mask/wallets.dart';
|
||||
import 'package:pshared/models/ledger/account.dart';
|
||||
import 'package:pshared/provider/ledger.dart';
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
|
||||
@@ -11,14 +12,17 @@ import 'package:pweb/pages/dashboard/buttons/balance/controller.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class BalanceWidget extends StatelessWidget {
|
||||
final ValueChanged<Wallet> onTopUp;
|
||||
final ValueChanged<Wallet> onWalletTap;
|
||||
final ValueChanged<LedgerAccount> onLedgerTap;
|
||||
|
||||
const BalanceWidget({
|
||||
super.key,
|
||||
required this.onTopUp,
|
||||
required this.onWalletTap,
|
||||
required this.onLedgerTap,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -46,6 +50,7 @@ class BalanceWidget extends StatelessWidget {
|
||||
onIndexChanged: carousel.onPageChanged,
|
||||
onTopUp: onTopUp,
|
||||
onWalletTap: onWalletTap,
|
||||
onLedgerTap: onLedgerTap,
|
||||
);
|
||||
|
||||
if (wallets.isEmpty && accounts.isEmpty) {
|
||||
|
||||
Reference in New Issue
Block a user