Erweiterungen
This commit is contained in:
1 parent
ba1f7d5440
commit
bb3dc9e856
28 files changed
+1672
-1291
No files matched your search
+33
-1
@@ -188,7 +188,7 @@ class Main extends StatefulWidget {
|
||||
State<Main> createState() => _MainState();
|
||||
}
|
||||
|
||||
class _MainState extends State<Main> with SingleTickerProviderStateMixin, ProducerMixin, ConsumerMixin {
|
||||
class _MainState extends State<Main> with SingleTickerProviderStateMixin, ProducerMixin, ConsumerMixin, WidgetsBindingObserver {
|
||||
DateTime? _lastBackPressed;
|
||||
late ContentViewWidget _currentContent;
|
||||
late WidgetStack<ContentViewWidget> contentStack = WidgetStack();
|
||||
@@ -210,7 +210,11 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Unregister from app lifecycle events
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
|
||||
_animationController?.dispose();
|
||||
_checkForNewState0JobsJobsTimer?.cancel();
|
||||
|
||||
// Unsubscribe from all message topics
|
||||
unsubscribe(queueId: Constants.messageTopicPushContentView);
|
||||
@@ -228,6 +232,9 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Register for app lifecycle events
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
_animationController = AnimationController(vsync: this, duration: const Duration(milliseconds: 1000));
|
||||
_animationController!.repeat(reverse: true);
|
||||
@@ -253,6 +260,31 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
super.didChangeAppLifecycleState(state);
|
||||
|
||||
switch (state) {
|
||||
case AppLifecycleState.paused:
|
||||
case AppLifecycleState.inactive:
|
||||
case AppLifecycleState.hidden:
|
||||
// App geht in den Hintergrund - Animation und Timer pausieren
|
||||
_animationController?.stop();
|
||||
_checkForNewState0JobsJobsTimer?.cancel();
|
||||
Util.logInfo('App in Hintergrund - Rendering pausiert');
|
||||
break;
|
||||
case AppLifecycleState.resumed:
|
||||
// App kommt zurück in den Vordergrund - Animation und Timer fortsetzen
|
||||
_animationController?.repeat(reverse: true);
|
||||
_startCheckForNewState0JobsJobsTimer();
|
||||
Util.logInfo('App im Vordergrund - Rendering fortgesetzt');
|
||||
break;
|
||||
case AppLifecycleState.detached:
|
||||
// App wird beendet
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_initCompleted) {
|
||||
|
||||
Reference in new issue
Block a user