wallet card redesign
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/payment/source.dart';
|
||||
import 'package:pshared/models/payment/type.dart';
|
||||
|
||||
import 'package:pweb/app/router/payout_routes.dart';
|
||||
|
||||
|
||||
class BalanceActionButtonState {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
const BalanceActionButtonState({
|
||||
required this.label,
|
||||
required this.icon,
|
||||
required this.onPressed,
|
||||
});
|
||||
}
|
||||
|
||||
class BalanceActionsState {
|
||||
final BalanceActionButtonState topLeading;
|
||||
final BalanceActionButtonState topTrailing;
|
||||
final BalanceActionButtonState bottom;
|
||||
|
||||
const BalanceActionsState({
|
||||
required this.topLeading,
|
||||
required this.topTrailing,
|
||||
required this.bottom,
|
||||
});
|
||||
}
|
||||
|
||||
class BalanceSourceActionsController {
|
||||
const BalanceSourceActionsController();
|
||||
|
||||
BalanceActionsState wallet({
|
||||
required BuildContext context,
|
||||
required String walletRef,
|
||||
required VoidCallback onAddFunds,
|
||||
}) {
|
||||
return BalanceActionsState(
|
||||
topLeading: BalanceActionButtonState(
|
||||
label: 'Operation History',
|
||||
icon: Icons.history_rounded,
|
||||
onPressed: () => _openWalletOperationHistory(context, walletRef),
|
||||
),
|
||||
topTrailing: BalanceActionButtonState(
|
||||
label: 'Send Payout',
|
||||
icon: Icons.send_rounded,
|
||||
onPressed: () => _sendWalletPayout(context, walletRef),
|
||||
),
|
||||
bottom: BalanceActionButtonState(
|
||||
label: 'Wallet Details / Add Funds',
|
||||
icon: Icons.account_balance_wallet_rounded,
|
||||
onPressed: onAddFunds,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
BalanceActionsState ledger({
|
||||
required BuildContext context,
|
||||
required String ledgerAccountRef,
|
||||
required VoidCallback onAddFunds,
|
||||
required VoidCallback onWalletDetails,
|
||||
}) {
|
||||
return BalanceActionsState(
|
||||
topLeading: BalanceActionButtonState(
|
||||
label: 'Operation History / Wallet Details',
|
||||
icon: Icons.receipt_long_rounded,
|
||||
onPressed: onWalletDetails,
|
||||
),
|
||||
topTrailing: BalanceActionButtonState(
|
||||
label: 'Send Payout',
|
||||
icon: Icons.send_rounded,
|
||||
onPressed: () => _sendLedgerPayout(context, ledgerAccountRef),
|
||||
),
|
||||
bottom: BalanceActionButtonState(
|
||||
label: 'Add Funds',
|
||||
icon: Icons.add_card_rounded,
|
||||
onPressed: onAddFunds,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openWalletOperationHistory(BuildContext context, String walletRef) {
|
||||
context.read<PaymentSourceController>().selectWalletByRef(walletRef);
|
||||
context.pushNamed(PayoutRoutes.editWallet);
|
||||
}
|
||||
|
||||
void _sendWalletPayout(BuildContext context, String walletRef) {
|
||||
context.read<PaymentSourceController>().selectWalletByRef(walletRef);
|
||||
context.pushNamed(
|
||||
PayoutRoutes.payment,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(
|
||||
paymentType: PaymentType.wallet,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _sendLedgerPayout(BuildContext context, String ledgerAccountRef) {
|
||||
context.read<PaymentSourceController>().selectLedgerByRef(ledgerAccountRef);
|
||||
context.pushNamed(
|
||||
PayoutRoutes.payment,
|
||||
queryParameters: PayoutRoutes.buildQueryParameters(
|
||||
paymentType: PaymentType.ledger,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user