From 1bd551a84a798bc19e4b290981baedf9950ba259 Mon Sep 17 00:00:00 2001
From: Sara <sarasdj@stud.ntnu.no>
Date: Mon, 8 Apr 2024 12:45:44 +0200
Subject: [PATCH] add: reload page animation

---
 app/lib/pages/default_page.dart | 55 +++++++++++++--------------------
 app/pubspec.lock                |  8 +++++
 app/pubspec.yaml                |  1 +
 3 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/app/lib/pages/default_page.dart b/app/lib/pages/default_page.dart
index 9ec84cbb..5c693ecc 100644
--- a/app/lib/pages/default_page.dart
+++ b/app/lib/pages/default_page.dart
@@ -1,6 +1,7 @@
 import 'dart:async';
 import 'package:app/server_requests/fetch_relation.dart';
 import 'package:flutter/material.dart';
+import 'package:liquid_pull_to_refresh/liquid_pull_to_refresh.dart';
 
 import '../consts.dart';
 import '../data_classes.dart';
@@ -27,35 +28,15 @@ class _DefaultPageState extends State<DefaultPage> {
     super.dispose();
   }
 
-  /// Display message to user
-  void showConnectionMessage() {
-    showDialog(
-      context: context,
-      builder: (context) => AlertDialog(
-        actions: [
-          TextButton(
-            onPressed: () {
-              Navigator.of(context).pop();
-              },
-            child: const Text("Ok"),
-          )
-        ],
-        title: const Center(
-          child: Text("No server connection")
-        ),
-        contentPadding: const EdgeInsets.all(10.0),
-        content: const Text(
-          "The app may display outdated information. Use with caution!",
-          textAlign: TextAlign.center, // Align text center
-        ),
-      ),
-    );
+  Future<void> _handleRefresh() async {
+    return await Future.delayed(const Duration(seconds: 2));
   }
 
   @override
   Widget build(BuildContext context) {
     return MaterialApp(
       home: Scaffold(
+        backgroundColor: Colors.grey[900],
         appBar: AppBar(
           backgroundColor: Colors.black87,
           leading: IconButton(
@@ -101,16 +82,24 @@ class _DefaultPageState extends State<DefaultPage> {
             ),
           ],
         ),
-        body: Container( // Return container with list view and background color
-          color: const Color(0xff151515),
-          child: ListView(
-            children: [
-              MapContainerWidget(
-                markerList: selectedMarkerList,
-                relation: selectedRelation,
-                serverConnection: serverConnection,
-              ),
-            ],
+        body: LiquidPullToRefresh(
+          color: Colors.grey[900],
+          height: 200,
+          backgroundColor: Colors.grey[600],
+          onRefresh: _handleRefresh,
+          animSpeedFactor: 3,
+          showChildOpacityTransition: false,
+          child: Container( // Return main container with map and stats widget
+            color: const Color(0xff151515),
+            child: ListView(
+              children: [
+                MapContainerWidget(
+                  markerList: selectedMarkerList,
+                  relation: selectedRelation,
+                  serverConnection: serverConnection,
+                ),
+              ],
+            ),
           ),
         ),
       ),
diff --git a/app/pubspec.lock b/app/pubspec.lock
index f052b8a7..984f6899 100644
--- a/app/pubspec.lock
+++ b/app/pubspec.lock
@@ -248,6 +248,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "2.1.1"
+  liquid_pull_to_refresh:
+    dependency: "direct main"
+    description:
+      name: liquid_pull_to_refresh
+      sha256: "11e4cd8c5460085a31b479ec4e1cd063eb8e599f35684d57a44dafa1fd1f67f3"
+      url: "https://pub.dev"
+    source: hosted
+    version: "3.0.1"
   lists:
     dependency: transitive
     description:
diff --git a/app/pubspec.yaml b/app/pubspec.yaml
index 84fd4516..84f52da0 100644
--- a/app/pubspec.yaml
+++ b/app/pubspec.yaml
@@ -22,6 +22,7 @@ dependencies:
   fuzzy: any                          # Search algorithm
   connectivity_plus: ^3.0.3           # Check internet connection
   get: ^4.6.5
+  liquid_pull_to_refresh: ^3.0.0      # Pull to refresh
 
 dev_dependencies:
   flutter_test:
-- 
GitLab