diff --git a/app/lib/pages/default_page.dart b/app/lib/pages/default_page.dart index 9ec84cbb1bda4f9b0f0c48a7b39ead5d4174898f..5c693ecc02e489573cd4898390c321f4e967eca6 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 f052b8a782a53e5dfd02c4305034688622205349..984f6899ab9a4b32ab6cb57848133f5223380fdc 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 84fd4516d63b13f277e6f5a31ed0f71f9752840a..84f52da0bd413378cff2befea4868d068e1d2b95 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: