added ledger as souec of funds for payouts
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/balance_mask/wallets.dart';
|
||||
import 'package:pshared/provider/ledger.dart';
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
|
||||
import 'package:pweb/pages/dashboard/buttons/balance/carousel.dart';
|
||||
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;
|
||||
|
||||
const BalanceWidget({
|
||||
super.key,
|
||||
required this.onTopUp,
|
||||
required this.onWalletTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final walletsController = context.watch<WalletsController>();
|
||||
final ledgerProvider = context.watch<LedgerAccountsProvider>();
|
||||
final carousel = context.watch<BalanceCarouselController>();
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
|
||||
final wallets = walletsController.wallets;
|
||||
final accounts = ledgerProvider.accounts;
|
||||
final isLoading =
|
||||
walletsController.isLoading &&
|
||||
ledgerProvider.isLoading &&
|
||||
wallets.isEmpty &&
|
||||
accounts.isEmpty;
|
||||
|
||||
if (isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final carouselWidget = BalanceCarousel(
|
||||
items: carousel.items,
|
||||
currentIndex: carousel.index,
|
||||
onIndexChanged: carousel.onPageChanged,
|
||||
onTopUp: onTopUp,
|
||||
onWalletTap: onWalletTap,
|
||||
);
|
||||
|
||||
if (wallets.isEmpty && accounts.isEmpty) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Center(child: Text(loc.noWalletsAvailable)),
|
||||
const SizedBox(height: 12),
|
||||
carouselWidget,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return carouselWidget;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user