2022-04-24 04:08:45 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
|
|
|
|
|
|
|
|
class ImmichLoadingOverlay extends StatelessWidget {
|
|
|
|
const ImmichLoadingOverlay({
|
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ValueListenableBuilder<bool>(
|
2022-06-23 06:14:14 +02:00
|
|
|
valueListenable:
|
|
|
|
ImmichLoadingOverlayController.appLoader.loaderShowingNotifier,
|
2022-04-24 04:08:45 +02:00
|
|
|
builder: (context, shouldShow, child) {
|
2022-06-23 06:14:14 +02:00
|
|
|
return shouldShow
|
|
|
|
? const Scaffold(
|
|
|
|
backgroundColor: Colors.black54,
|
|
|
|
body: Center(
|
|
|
|
child: ImmichLoadingIndicator(),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: const SizedBox();
|
2022-04-24 04:08:45 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ImmichLoadingOverlayController {
|
2022-06-23 06:14:14 +02:00
|
|
|
static final ImmichLoadingOverlayController appLoader =
|
|
|
|
ImmichLoadingOverlayController();
|
2022-04-24 04:08:45 +02:00
|
|
|
ValueNotifier<bool> loaderShowingNotifier = ValueNotifier(false);
|
|
|
|
ValueNotifier<String> loaderTextNotifier = ValueNotifier('error message');
|
|
|
|
|
|
|
|
void show() {
|
|
|
|
loaderShowingNotifier.value = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hide() {
|
|
|
|
loaderShowingNotifier.value = false;
|
|
|
|
}
|
|
|
|
}
|