2023-09-20 22:14:34 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart';
|
2023-09-22 22:20:48 +00:00
|
|
|
|
2023-09-20 22:14:34 +00:00
|
|
|
class FusionProgressUIState extends ChangeNotifier {
|
2023-09-28 20:16:48 +00:00
|
|
|
bool _ableToConnect = true; // set to true for now
|
2023-09-20 22:14:34 +00:00
|
|
|
|
|
|
|
bool get done {
|
|
|
|
if (!_ableToConnect) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-10-17 16:18:43 +00:00
|
|
|
bool _done = (_connecting.status == CashFusionStatus.success) ||
|
|
|
|
(_connecting.status == CashFusionStatus.failed);
|
|
|
|
_done &= (_outputs.status == CashFusionStatus.success) ||
|
|
|
|
(_outputs.status == CashFusionStatus.failed);
|
|
|
|
_done &= (_peers.status == CashFusionStatus.success) ||
|
|
|
|
(_peers.status == CashFusionStatus.failed);
|
|
|
|
_done &= (_fusing.status == CashFusionStatus.success) ||
|
|
|
|
(_fusing.status == CashFusionStatus.failed);
|
|
|
|
_done &= (_complete.status == CashFusionStatus.success) ||
|
|
|
|
(_complete.status == CashFusionStatus.failed);
|
|
|
|
|
|
|
|
_done &= (fusionState.status == CashFusionStatus.success) ||
|
|
|
|
(fusionState.status == CashFusionStatus.failed);
|
2023-09-22 22:20:48 +00:00
|
|
|
|
2023-09-20 22:14:34 +00:00
|
|
|
return _done;
|
|
|
|
}
|
|
|
|
|
2023-09-22 22:20:48 +00:00
|
|
|
bool get succeeded {
|
|
|
|
if (!_ableToConnect) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-10-17 16:15:31 +00:00
|
|
|
bool _succeeded = _connecting.status == CashFusionStatus.success;
|
|
|
|
_succeeded &= _outputs.status == CashFusionStatus.success;
|
|
|
|
_succeeded &= _peers.status == CashFusionStatus.success;
|
|
|
|
_succeeded &= _fusing.status == CashFusionStatus.success;
|
|
|
|
_succeeded &= _complete.status == CashFusionStatus.success;
|
2023-09-22 22:20:48 +00:00
|
|
|
|
2023-10-17 16:18:43 +00:00
|
|
|
_succeeded &= fusionState.status == CashFusionStatus.success;
|
2023-09-22 22:20:48 +00:00
|
|
|
|
|
|
|
return _succeeded;
|
|
|
|
}
|
|
|
|
|
2023-10-17 16:15:31 +00:00
|
|
|
CashFusionState _connecting =
|
|
|
|
CashFusionState(status: CashFusionStatus.waiting, info: null);
|
|
|
|
CashFusionState get connecting => _connecting;
|
|
|
|
set connecting(CashFusionState state) {
|
2023-09-20 22:14:34 +00:00
|
|
|
_connecting = state;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2023-10-17 16:15:31 +00:00
|
|
|
CashFusionState _outputs =
|
|
|
|
CashFusionState(status: CashFusionStatus.waiting, info: null);
|
|
|
|
CashFusionState get outputs => _outputs;
|
|
|
|
set outputs(CashFusionState state) {
|
2023-09-20 22:14:34 +00:00
|
|
|
_outputs = state;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2023-10-17 16:15:31 +00:00
|
|
|
CashFusionState _peers =
|
|
|
|
CashFusionState(status: CashFusionStatus.waiting, info: null);
|
|
|
|
CashFusionState get peers => _peers;
|
|
|
|
set peers(CashFusionState state) {
|
2023-09-20 22:14:34 +00:00
|
|
|
_peers = state;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2023-10-17 16:15:31 +00:00
|
|
|
CashFusionState _fusing =
|
|
|
|
CashFusionState(status: CashFusionStatus.waiting, info: null);
|
|
|
|
CashFusionState get fusing => _fusing;
|
|
|
|
set fusing(CashFusionState state) {
|
2023-09-20 22:14:34 +00:00
|
|
|
_fusing = state;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
|
2023-10-17 16:15:31 +00:00
|
|
|
CashFusionState _complete =
|
|
|
|
CashFusionState(status: CashFusionStatus.waiting, info: null);
|
|
|
|
CashFusionState get complete => _complete;
|
|
|
|
set complete(CashFusionState state) {
|
2023-09-20 22:14:34 +00:00
|
|
|
_complete = state;
|
|
|
|
notifyListeners();
|
|
|
|
}
|
2023-09-22 22:20:48 +00:00
|
|
|
|
2023-10-17 16:15:31 +00:00
|
|
|
CashFusionState _fusionStatus =
|
|
|
|
CashFusionState(status: CashFusionStatus.waiting, info: null);
|
|
|
|
CashFusionState get fusionState => _fusionStatus;
|
|
|
|
set fusionState(CashFusionState fusionStatus) {
|
2023-09-28 20:16:48 +00:00
|
|
|
_fusionStatus = fusionStatus;
|
2023-09-26 15:30:31 +00:00
|
|
|
notifyListeners();
|
2023-09-22 22:20:48 +00:00
|
|
|
}
|
2023-09-20 22:14:34 +00:00
|
|
|
}
|