feat: better and centralized loading screen
This commit is contained in:
parent
eb83e9fbe3
commit
b751d93be6
11 changed files with 82 additions and 13 deletions
47
lib/ui/core/ui/await_loading.dart
Normal file
47
lib/ui/core/ui/await_loading.dart
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AwaitLoading extends StatefulWidget {
|
||||
const AwaitLoading({super.key});
|
||||
|
||||
@override
|
||||
State<AwaitLoading> createState() => _AwaitLoadingState();
|
||||
}
|
||||
|
||||
class _AwaitLoadingState extends State<AwaitLoading> {
|
||||
String text = "";
|
||||
|
||||
Timer? t;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
t?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
t = Timer(Duration(seconds: 8), () {
|
||||
setState(() {
|
||||
text =
|
||||
"Il semblerait qu'il y ait un problème. Vérifiez que vous êtes connecté·e à internet.";
|
||||
});
|
||||
});
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(child: SizedBox()),
|
||||
Center(child: CircularProgressIndicator()),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 300,
|
||||
child: Text(text, textAlign: TextAlign.center),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
27
lib/ui/core/ui/overlay_boundary.dart
Normal file
27
lib/ui/core/ui/overlay_boundary.dart
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class OverlayBoundary extends StatefulWidget {
|
||||
const OverlayBoundary({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<OverlayBoundary> createState() => _OverlayBoundaryState();
|
||||
}
|
||||
|
||||
class _OverlayBoundaryState extends State<OverlayBoundary> {
|
||||
late final OverlayEntry _overlayEntry = OverlayEntry(
|
||||
builder: (context) => widget.child,
|
||||
);
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant OverlayBoundary oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
_overlayEntry.markNeedsBuild();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Overlay(initialEntries: [_overlayEntry]);
|
||||
}
|
||||
}
|
||||
Reference in a new issue