From 107a5bdbf8ba26f1d78934b08e647dc9bbb94d3d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Elias=20M=C3=BCller?= <elias@elias-mueller.com>
Date: Wed, 24 Apr 2024 19:23:32 +0200
Subject: [PATCH] added content position animation when error bar is displayed

---
 lib/state/widgets/components/error_bar.dart | 71 +++++++++++----------
 1 file changed, 37 insertions(+), 34 deletions(-)

diff --git a/lib/state/widgets/components/error_bar.dart b/lib/state/widgets/components/error_bar.dart
index 56875d1..6d63b25 100644
--- a/lib/state/widgets/components/error_bar.dart
+++ b/lib/state/widgets/components/error_bar.dart
@@ -13,42 +13,45 @@ class ErrorBar extends StatelessWidget {
   @override
   Widget build(BuildContext context) => ControllerProvider<ErrorBarController>(
     create: (context) => ErrorBarController(),
-    child: (context) => AnimatedSwitcher(
+    child: (context) => AnimatedSize(
       duration: animationDuration,
-      transitionBuilder: (Widget child, Animation<double> animation) => SlideTransition(
-        position: Tween<Offset>(
-          begin: const Offset(0.0, -1.0),
-          end: Offset.zero,
-        ).animate(animation),
-        child: child,
-      ),
-      child: Visibility(
-        key: Key(visible.hashCode.toString()),
-        visible: visible,
-        child: Builder(
-          builder: (context) {
-            var controller = context.watchController<ErrorBarController>();
-            var status = controller.connectivityStatusKnown() && !controller.isConnected()
-              ? (icon: Icons.wifi_off_outlined, text: 'Offline', color: Colors.grey.shade600)
-              : (icon: Icons.wifi_find_outlined, text: 'Verbindung fehlgeschlagen', color: Theme.of(context).primaryColor);
+      child: AnimatedSwitcher(
+          duration: animationDuration,
+          transitionBuilder: (Widget child, Animation<double> animation) => SlideTransition(
+            position: Tween<Offset>(
+              begin: const Offset(0.0, -1.0),
+              end: Offset.zero,
+            ).animate(animation),
+            child: child,
+          ),
+          child: Visibility(
+              key: Key(visible.hashCode.toString()),
+              visible: visible,
+              child: Builder(
+                builder: (context) {
+                  var controller = context.watchController<ErrorBarController>();
+                  var status = controller.connectivityStatusKnown() && !controller.isConnected()
+                      ? (icon: Icons.wifi_off_outlined, text: 'Offline', color: Colors.grey.shade600)
+                      : (icon: Icons.wifi_find_outlined, text: 'Verbindung fehlgeschlagen', color: Theme.of(context).primaryColor);
 
-            return Container(
-              height: 20,
-              decoration: BoxDecoration(
-                color: status.color,
-              ),
-              child: Row(
-                mainAxisAlignment: MainAxisAlignment.center,
-                children: [
-                  Icon(status.icon, size: 14),
-                  const SizedBox(width: 10),
-                  Text(status.text, style: const TextStyle(fontSize: 12))
-                ],
-              ),
-            );
-          },
-        )
-      )
+                  return Container(
+                    height: 20,
+                    decoration: BoxDecoration(
+                      color: status.color,
+                    ),
+                    child: Row(
+                      mainAxisAlignment: MainAxisAlignment.center,
+                      children: [
+                        Icon(status.icon, size: 14),
+                        const SizedBox(width: 10),
+                        Text(status.text, style: const TextStyle(fontSize: 12))
+                      ],
+                    ),
+                  );
+                },
+              )
+          )
+      ),
     ),
   );
 }