Top Up Balance logic and Added fixes for routing
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pweb/models/wallet.dart';
|
||||
import 'package:pweb/pages/dashboard/buttons/balance/carousel.dart';
|
||||
import 'package:pweb/providers/wallets.dart';
|
||||
|
||||
@@ -9,7 +10,9 @@ import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class BalanceWidget extends StatelessWidget {
|
||||
const BalanceWidget({super.key});
|
||||
final ValueChanged<Wallet> onTopUp;
|
||||
|
||||
const BalanceWidget({super.key, required this.onTopUp});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -30,6 +33,7 @@ class BalanceWidget extends StatelessWidget {
|
||||
WalletCarousel(
|
||||
wallets: wallets,
|
||||
onWalletChanged: walletsProvider.selectWallet,
|
||||
onTopUp: onTopUp,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,12 @@ import 'package:pweb/providers/wallets.dart';
|
||||
|
||||
class WalletCard extends StatelessWidget {
|
||||
final Wallet wallet;
|
||||
final VoidCallback onTopUp;
|
||||
|
||||
const WalletCard({
|
||||
super.key,
|
||||
required this.wallet,
|
||||
required this.onTopUp,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -43,7 +45,7 @@ class WalletCard extends StatelessWidget {
|
||||
),
|
||||
BalanceAddFunds(
|
||||
onTopUp: () {
|
||||
// TODO: Implement top-up functionality
|
||||
onTopUp();
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -51,4 +53,4 @@ class WalletCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,13 @@ import 'package:pweb/providers/carousel.dart';
|
||||
class WalletCarousel extends StatefulWidget {
|
||||
final List<Wallet> wallets;
|
||||
final ValueChanged<Wallet> onWalletChanged;
|
||||
final ValueChanged<Wallet> onTopUp;
|
||||
|
||||
const WalletCarousel({
|
||||
super.key,
|
||||
required this.wallets,
|
||||
required this.onWalletChanged,
|
||||
required this.onTopUp,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -33,6 +35,11 @@ class _WalletCarouselState extends State<WalletCarousel> {
|
||||
_pageController = PageController(
|
||||
viewportFraction: WalletCardConfig.viewportFraction,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (widget.wallets.isNotEmpty) {
|
||||
widget.onWalletChanged(widget.wallets[_currentPage]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -83,7 +90,10 @@ class _WalletCarouselState extends State<WalletCarousel> {
|
||||
itemBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: WalletCardConfig.cardPadding,
|
||||
child: WalletCard(wallet: widget.wallets[index]),
|
||||
child: WalletCard(
|
||||
wallet: widget.wallets[index],
|
||||
onTopUp: () => widget.onTopUp(widget.wallets[index]),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -110,4 +120,4 @@ class _WalletCarouselState extends State<WalletCarousel> {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user