import 'package:equatable/equatable.dart'; import '../../../core/ui/view_status.dart'; import '../data/models/wallet.dart'; import '../data/models/wallet_txn.dart'; import '../data/wallet_repository.dart'; enum WalletAction { none, toppingUp, topupFailed, topupDone, invoiceReady } class WalletState extends Equatable { const WalletState({ this.status = ViewStatus.idle, this.wallet, this.transactions = const [], this.action = WalletAction.none, this.invoice, this.error, }); final ViewStatus status; final Wallet? wallet; final List transactions; /// فعلٌ جارٍ داخل الشاشة — منفصل عن [status] كي لا يُخفي الشحنُ الرصيدَ /// المعروض خلفه. final WalletAction action; /// فاتورة تحويل بانتظار الدفع — تُعرض للمستخدم بمرجعها وحساب الاستلام. final TopupResult? invoice; final String? error; String get currency => wallet?.currency ?? ''; WalletState copyWith({ ViewStatus? status, Wallet? wallet, List? transactions, WalletAction? action, TopupResult? invoice, String? error, }) { return WalletState( status: status ?? this.status, wallet: wallet ?? this.wallet, transactions: transactions ?? this.transactions, action: action ?? this.action, invoice: invoice ?? this.invoice, error: error ?? this.error, ); } @override List get props => [status, wallet, transactions, action, invoice?.reference, error]; }