WIP: integration with ledger
This commit is contained in:
@@ -3,42 +3,58 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
import 'package:pshared/provider/ledger.dart';
|
||||
import 'package:pshared/provider/payment/wallets.dart';
|
||||
|
||||
import 'package:pweb/pages/payout_page/wallet/card.dart';
|
||||
|
||||
import 'package:pweb/pages/payout_page/wallet/ledger/card.dart';
|
||||
|
||||
class WalletWidgets extends StatelessWidget {
|
||||
final void Function(Wallet) onWalletTap;
|
||||
final void Function(String ledgerAccountRef) onLedgerTap;
|
||||
|
||||
const WalletWidgets({super.key, required this.onWalletTap});
|
||||
const WalletWidgets({
|
||||
super.key,
|
||||
required this.onWalletTap,
|
||||
required this.onLedgerTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<WalletsProvider>();
|
||||
final ledgerProvider = context.watch<LedgerAccountsProvider>();
|
||||
|
||||
final wallets = provider.wallets;
|
||||
final accounts = ledgerProvider.accounts;
|
||||
|
||||
return GridView.builder(
|
||||
scrollDirection: Axis.vertical,
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 12,
|
||||
crossAxisSpacing: 12,
|
||||
childAspectRatio: 3,
|
||||
),
|
||||
itemCount: wallets.length,
|
||||
itemCount: wallets.length + accounts.length,
|
||||
itemBuilder: (context, index) {
|
||||
final wallet = wallets[index];
|
||||
if (index < wallets.length) {
|
||||
final wallet = wallets[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: WalletCard(wallet: wallet, onTap: () => onWalletTap(wallet)),
|
||||
);
|
||||
}
|
||||
|
||||
final account = accounts[index - wallets.length];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: WalletCard(
|
||||
wallet: wallet,
|
||||
onTap: () => onWalletTap(wallet),
|
||||
child: LedgerWalletCard(
|
||||
account: account,
|
||||
onTap: () => onLedgerTap(account.ledgerAccountRef),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user