mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 10:34:32 +00:00
WIP: fusion progress provider
This commit is contained in:
parent
a4f8c52148
commit
b0d0fec5e4
2 changed files with 90 additions and 0 deletions
44
lib/models/fusion_progress_state.dart
Normal file
44
lib/models/fusion_progress_state.dart
Normal file
|
@ -0,0 +1,44 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart';
|
||||
import 'package:stackwallet/services/coins/manager.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
|
||||
class FusionProgressState extends ChangeNotifier {
|
||||
final String walletId;
|
||||
final String walletName;
|
||||
final Coin coin;
|
||||
late CashFusionStatus _fusionStatus;
|
||||
Manager? manager;
|
||||
String? address;
|
||||
|
||||
CashFusionStatus get fusionState => _fusionStatus;
|
||||
set fusionState(CashFusionStatus fusionStatus) {
|
||||
_fusionStatus = fusionStatus;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
FusionProgressState({
|
||||
required this.walletId,
|
||||
required this.walletName,
|
||||
required this.coin,
|
||||
required CashFusionStatus fusionStatus,
|
||||
this.manager,
|
||||
this.address,
|
||||
}) {
|
||||
_fusionStatus = fusionStatus;
|
||||
}
|
||||
|
||||
FusionProgressState copyWith({
|
||||
CashFusionStatus? fusionStatus,
|
||||
String? address,
|
||||
}) {
|
||||
return FusionProgressState(
|
||||
walletId: walletId,
|
||||
walletName: walletName,
|
||||
coin: coin,
|
||||
fusionStatus: fusionStatus ?? _fusionStatus,
|
||||
manager: manager,
|
||||
address: this.address,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart';
|
||||
|
||||
import 'fusion_progress_state.dart';
|
||||
|
||||
class FusionProgressUIState extends ChangeNotifier {
|
||||
bool _ableToConnect = false;
|
||||
|
||||
|
@ -19,9 +21,33 @@ class FusionProgressUIState extends ChangeNotifier {
|
|||
(_fusing == CashFusionStatus.failed);
|
||||
_done &= (_complete == CashFusionStatus.success) ||
|
||||
(_complete == CashFusionStatus.failed);
|
||||
|
||||
// for (final wallet in _walletStates.values) {
|
||||
// _done &= (wallet.restoringState == CashFusionStatus.success) ||
|
||||
// (wallet.restoringState == CashFusionStatus.failed);
|
||||
// }
|
||||
|
||||
return _done;
|
||||
}
|
||||
|
||||
bool get succeeded {
|
||||
if (!_ableToConnect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _succeeded = _connecting == CashFusionStatus.success;
|
||||
_succeeded &= _outputs == CashFusionStatus.success;
|
||||
_succeeded &= _peers == CashFusionStatus.success;
|
||||
_succeeded &= _fusing == CashFusionStatus.success;
|
||||
_succeeded &= _complete == CashFusionStatus.success;
|
||||
|
||||
// for (final wallet in _walletStates.values) {
|
||||
// _succeeded &= wallet.restoringState == StackRestoringStatus.success;
|
||||
// }
|
||||
|
||||
return _succeeded;
|
||||
}
|
||||
|
||||
CashFusionStatus _connecting = CashFusionStatus.waiting;
|
||||
CashFusionStatus get connecting => _connecting;
|
||||
set connecting(CashFusionStatus state) {
|
||||
|
@ -56,4 +82,24 @@ class FusionProgressUIState extends ChangeNotifier {
|
|||
_complete = state;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// List<Manager> get managers {
|
||||
// List<Manager> _managers = [];
|
||||
// for (final item in _walletStates.values) {
|
||||
// if (item.manager != null) {
|
||||
// _managers.add(item.manager!);
|
||||
// }
|
||||
// }
|
||||
// return _managers;
|
||||
// }
|
||||
|
||||
Map<String, FusionProgressState> _fusionState = {};
|
||||
set fusionState(Map<String, FusionProgressState> state) {
|
||||
_fusionState = state;
|
||||
// _fusionStateProviders = {};
|
||||
// for (final wallet in _fusionState.values) {
|
||||
// _fusionStateProviders[wallet.walletId] =
|
||||
// ChangeNotifierProvider<FusionProgressState>((_) => wallet);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue