mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
|
import 'dart:async';
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||
|
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
|
||
|
|
||
|
Future<T> showLoading<T>({
|
||
|
required Future<T> whileFuture,
|
||
|
required BuildContext context,
|
||
|
required String message,
|
||
|
String? subMessage,
|
||
|
bool isDesktop = false,
|
||
|
}) async {
|
||
|
unawaited(
|
||
|
showDialog<void>(
|
||
|
context: context,
|
||
|
barrierDismissible: false,
|
||
|
builder: (_) => WillPopScope(
|
||
|
onWillPop: () async => false,
|
||
|
child: Container(
|
||
|
color: Theme.of(context)
|
||
|
.extension<StackColors>()!
|
||
|
.overlay
|
||
|
.withOpacity(0.6),
|
||
|
child: CustomLoadingOverlay(
|
||
|
message: message,
|
||
|
subMessage: subMessage,
|
||
|
eventBus: null,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
|
||
|
final result = await whileFuture;
|
||
|
|
||
|
// TODO: update to flutter 3.7.x to take advantage of context.mounted
|
||
|
// if (mounted) {
|
||
|
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||
|
// }
|
||
|
|
||
|
return result;
|
||
|
}
|