redesigned payment page + a lot of fixes

This commit is contained in:
Arseni
2026-02-21 21:55:20 +03:00
parent a68aa2abff
commit 0c6fa03aba
208 changed files with 4062 additions and 2217 deletions

View File

@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:pshared/models/payment/status.dart';
import 'package:flutter/foundation.dart';
import 'package:pweb/models/wallet_transaction.dart';
import 'package:pweb/models/wallet/wallet_transaction.dart';
import 'package:pweb/services/wallet_transactions.dart';
@@ -10,27 +9,15 @@ class WalletTransactionsProvider extends ChangeNotifier {
WalletTransactionsProvider(this._service);
List<WalletTransaction> _transactions = [];
List<WalletTransaction> _filteredTransactions = [];
DateTimeRange? _dateRange;
final Set<OperationStatus> _selectedStatuses = {};
final Set<WalletTransactionType> _selectedTypes = {};
String? _walletId;
List<WalletTransaction> _transactions = const [];
bool _isLoading = false;
String? _error;
String? _walletId;
List<WalletTransaction> get transactions => _transactions;
List<WalletTransaction> get filteredTransactions => _filteredTransactions;
DateTimeRange? get dateRange => _dateRange;
Set<OperationStatus> get selectedStatuses => _selectedStatuses;
Set<WalletTransactionType> get selectedTypes => _selectedTypes;
String? get walletId => _walletId;
List<WalletTransaction> get transactions => List.unmodifiable(_transactions);
bool get isLoading => _isLoading;
String? get error => _error;
bool get hasFilters =>
_dateRange != null ||
_selectedStatuses.isNotEmpty ||
_selectedTypes.isNotEmpty;
String? get walletId => _walletId;
Future<void> load({String? walletId}) async {
_isLoading = true;
@@ -40,65 +27,11 @@ class WalletTransactionsProvider extends ChangeNotifier {
try {
_walletId = walletId ?? _walletId;
_transactions = await _service.fetchHistory(walletId: _walletId);
_applyFilters(notify: false);
_isLoading = false;
notifyListeners();
} catch (e) {
_error = e.toString();
} finally {
_isLoading = false;
notifyListeners();
}
}
void setWallet(String walletId) {
_walletId = walletId;
_applyFilters();
}
void setDateRange(DateTimeRange? range) {
_dateRange = range;
_applyFilters();
}
void toggleStatus(OperationStatus status) {
if (_selectedStatuses.contains(status)) {
_selectedStatuses.remove(status);
} else {
_selectedStatuses.add(status);
}
_applyFilters();
}
void toggleType(WalletTransactionType type) {
if (_selectedTypes.contains(type)) {
_selectedTypes.remove(type);
} else {
_selectedTypes.add(type);
}
_applyFilters();
}
void resetFilters() {
_dateRange = null;
_selectedStatuses.clear();
_selectedTypes.clear();
_applyFilters();
}
void _applyFilters({bool notify = true}) {
_filteredTransactions = _transactions.where((tx) {
final walletMatch = _walletId == null || tx.walletId == _walletId;
final statusMatch =
_selectedStatuses.isEmpty || _selectedStatuses.contains(tx.status);
final typeMatch =
_selectedTypes.isEmpty || _selectedTypes.contains(tx.type);
final dateMatch = _dateRange == null ||
(tx.date.isAfter(_dateRange!.start.subtract(const Duration(seconds: 1))) &&
tx.date.isBefore(_dateRange!.end.add(const Duration(seconds: 1))));
return walletMatch && statusMatch && typeMatch && dateMatch;
}).toList();
if (notify) notifyListeners();
}
}