WIP fusion progress error labels

This commit is contained in:
sneurlax 2023-10-17 00:00:54 -05:00
parent aa31f04c20
commit 3d72e83d2f
4 changed files with 78 additions and 11 deletions

@ -1 +1 @@
Subproject commit 0d22e933ca1cf081262064d3a42f031f5285f77b
Subproject commit d93bfccb1ad4d169a27da647c82186bc44de660b

View file

@ -83,4 +83,48 @@ class FusionProgressUIState extends ChangeNotifier {
_fusionStatus = fusionStatus;
notifyListeners();
}
// Instance variables for info labels on fusion progress steps.
//
// "Connecting to server"
String? _connectionInfo;
String? get connectionInfo => _connectionInfo;
set connectionInfo(String? fusionInfo) {
_connectionInfo = fusionInfo;
notifyListeners();
}
// "Allocating outputs"
String? _outputsInfo;
String? get outputsInfo => _outputsInfo;
set outputsInfo(String? fusionInfo) {
_outputsInfo = fusionInfo;
notifyListeners();
}
// "Waiting for peers"
String? _peersInfo;
String? get peersInfo => _peersInfo;
set peersInfo(String? fusionInfo) {
_peersInfo = fusionInfo;
notifyListeners();
}
// "Fusing"
String? _fusingInfo;
String? get fusingInfo => _fusingInfo;
set fusingInfo(String? fusionInfo) {
_fusingInfo = fusionInfo;
notifyListeners();
}
// "Complete"
//
// Should show txId if successful.
String? _completeInfo;
String? get completeInfo => _completeInfo;
set completeInfo(String? fusionInfo) {
_completeInfo = fusionInfo;
notifyListeners();
}
}

View file

@ -47,7 +47,9 @@ class FusionProgress extends ConsumerWidget {
iconAsset: Assets.svg.node,
label: "Connecting to server",
status: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.connecting))),
.select((value) => value.connecting)),
info: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.connectionInfo))),
const SizedBox(
height: 12,
),
@ -55,7 +57,9 @@ class FusionProgress extends ConsumerWidget {
iconAsset: Assets.svg.upFromLine,
label: "Allocating outputs",
status: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.outputs))),
.select((value) => value.outputs)),
info: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.outputsInfo))),
const SizedBox(
height: 12,
),
@ -63,7 +67,9 @@ class FusionProgress extends ConsumerWidget {
iconAsset: Assets.svg.peers,
label: "Waiting for peers",
status: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.peers))),
.select((value) => value.peers)),
info: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.peersInfo))),
const SizedBox(
height: 12,
),
@ -71,7 +77,9 @@ class FusionProgress extends ConsumerWidget {
iconAsset: Assets.svg.fusing,
label: "Fusing",
status: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.fusing))),
.select((value) => value.fusing)),
info: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.fusingInfo))),
const SizedBox(
height: 12,
),
@ -79,7 +87,9 @@ class FusionProgress extends ConsumerWidget {
iconAsset: Assets.svg.checkCircle,
label: "Complete",
status: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.complete))),
.select((value) => value.complete)),
info: ref.watch(fusionProgressUIStateProvider(walletId)
.select((value) => value.completeInfo))),
],
);
}
@ -91,11 +101,13 @@ class _ProgressItem extends StatelessWidget {
required this.iconAsset,
required this.label,
required this.status,
this.info,
});
final String iconAsset;
final String label;
final CashFusionStatus status;
final String? info;
Widget _getIconForState(CashFusionStatus state, BuildContext context) {
switch (state) {
@ -156,6 +168,9 @@ class _ProgressItem extends StatelessWidget {
child: _getIconForState(status, context),
),
title: label,
subTitle: info != null
? Text(info!) // TODO style error message eg. red.
: null,
),
);
}

View file

@ -153,8 +153,8 @@ mixin FusionWalletInterface {
}
// callback to update the ui state object
void _updateStatus(fusion.FusionStatus fusionStatus) {
switch (fusionStatus) {
void _updateStatus({required fusion.FusionStatus status, String? info}) {
switch (status) {
case fusion.FusionStatus.connecting:
_uiState?.connecting = CashFusionStatus.running;
break;
@ -178,13 +178,13 @@ mixin FusionWalletInterface {
// _uiState?.fusing = CashFusionStatus.failed;
_uiState?.complete = CashFusionStatus.failed;
failCurrentUiState();
failCurrentUiState(info);
break;
case fusion.FusionStatus.exception:
_uiState?.complete = CashFusionStatus.failed;
failCurrentUiState();
failCurrentUiState(info);
break;
case fusion.FusionStatus.reset:
_uiState?.outputs = CashFusionStatus.waiting;
@ -197,19 +197,27 @@ mixin FusionWalletInterface {
}
}
void failCurrentUiState() {
void failCurrentUiState(String? info) {
// Check each _uiState value to see if it is running. If so, set it to failed.
if (_uiState?.connecting == CashFusionStatus.running) {
_uiState?.connecting = CashFusionStatus.failed;
_uiState?.connectionInfo = info;
}
if (_uiState?.outputs == CashFusionStatus.running) {
_uiState?.outputs = CashFusionStatus.failed;
_uiState?.outputsInfo = info;
}
if (_uiState?.peers == CashFusionStatus.running) {
_uiState?.peers = CashFusionStatus.failed;
_uiState?.connectionInfo = info;
}
if (_uiState?.fusing == CashFusionStatus.running) {
_uiState?.fusing = CashFusionStatus.failed;
_uiState?.fusingInfo = info;
}
if (_uiState?.complete == CashFusionStatus.running) {
_uiState?.complete = CashFusionStatus.failed;
_uiState?.completeInfo = info;
}
}