ledger top up functionality and few small fixes for project architechture and design

This commit is contained in:
Arseni
2026-03-05 21:49:23 +03:00
parent 39c04beb21
commit 97b16542c2
41 changed files with 764 additions and 455 deletions

View File

@@ -4,18 +4,20 @@ import 'package:flutter/gestures.dart';
import 'package:pshared/models/ledger/account.dart';
import 'package:pshared/models/payment/wallet.dart';
import 'package:pweb/models/dashboard/balance_item.dart';
import 'package:pweb/pages/dashboard/buttons/balance/add/card.dart';
import 'package:pweb/pages/dashboard/buttons/balance/balance_item.dart';
import 'package:pweb/pages/dashboard/buttons/balance/card.dart';
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<LedgerAccount> onLedgerAddFunds;
final ValueChanged<Wallet> onWalletTap;
final ValueChanged<LedgerAccount> onLedgerTap;
@@ -25,6 +27,7 @@ class BalanceCarousel extends StatefulWidget {
required this.currentIndex,
required this.onIndexChanged,
required this.onTopUp,
required this.onLedgerAddFunds,
required this.onWalletTap,
required this.onLedgerTap,
});
@@ -101,17 +104,18 @@ class _BalanceCarouselState extends State<BalanceCarousel> {
itemCount: widget.items.length,
itemBuilder: (context, index) {
final item = widget.items[index];
final Widget card = switch (item.type) {
BalanceItemType.wallet => WalletCard(
wallet: item.wallet!,
onTopUp: () => widget.onTopUp(item.wallet!),
onTap: () => widget.onWalletTap(item.wallet!),
final Widget card = switch (item) {
WalletBalanceItem(:final wallet) => WalletCard(
wallet: wallet,
onTopUp: () => widget.onTopUp(wallet),
onTap: () => widget.onWalletTap(wallet),
),
BalanceItemType.ledger => LedgerAccountCard(
account: item.account!,
onTap: () => widget.onLedgerTap(item.account!),
LedgerBalanceItem(:final account) => LedgerAccountCard(
account: account,
onTap: () => widget.onLedgerTap(account),
onAddFunds: () => widget.onLedgerAddFunds(account),
),
BalanceItemType.addAction => const AddBalanceCard(),
AddBalanceActionItem() => const AddBalanceCard(),
};
return Padding(