From 87e8c4700358f35eb683fb867e9f865eded56ae1 Mon Sep 17 00:00:00 2001 From: Fransolet Thomas Date: Fri, 17 Mar 2023 18:49:35 +0100 Subject: [PATCH] Add common loading --- android/app/version.properties | 4 +-- lib/Components/loading_common.dart | 50 ++++++++++++++++++++++++++++++ lib/Screens/Main/Home/home.dart | 3 +- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 lib/Components/loading_common.dart diff --git a/android/app/version.properties b/android/app/version.properties index 13048d8..b171b88 100644 --- a/android/app/version.properties +++ b/android/app/version.properties @@ -1,5 +1,5 @@ -#Fri Mar 17 18:03:23 CET 2023 -VERSION_BUILD=17 +#Fri Mar 17 18:48:37 CET 2023 +VERSION_BUILD=19 VERSION_MAJOR=1 VERSION_MINOR=0 VERSION_PATCH=0 diff --git a/lib/Components/loading_common.dart b/lib/Components/loading_common.dart new file mode 100644 index 0000000..a796afa --- /dev/null +++ b/lib/Components/loading_common.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; +import 'package:myhomie_app/constants.dart'; + +class LoadingCommon extends StatefulWidget { + const LoadingCommon({Key? key}) : super(key: key); + + @override + State createState() => _LoadingCommonState(); +} + +class _LoadingCommonState extends State with TickerProviderStateMixin { + AnimationController? _controller; + + @override + void initState() { + _controller = AnimationController( + duration: const Duration(milliseconds: 5000), + vsync: this, + )..repeat(); + super.initState(); + } + + @override + void dispose() { + _controller!.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + _controller!.forward(from: 0.0); + _controller!.addListener(() { + if (_controller!.isCompleted) { + _controller!.reverse(); + } + if(_controller!.isDismissed){ + _controller!.forward(); + } + }); + return Center( + child: RotationTransition( + turns: Tween(begin: 0.0, end: 3.0).animate(_controller!), + child: Icon(Icons.home, color: kMainColor, size: size.height*0.1), + ), + ); + } +} + + diff --git a/lib/Screens/Main/Home/home.dart b/lib/Screens/Main/Home/home.dart index 7dbbe3a..a0dbb7a 100644 --- a/lib/Screens/Main/Home/home.dart +++ b/lib/Screens/Main/Home/home.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:mycore_api/api.dart'; import 'package:myhomie_app/Components/loading.dart'; +import 'package:myhomie_app/Components/loading_common.dart'; import 'package:myhomie_app/Models/homieContext.dart'; import 'package:myhomie_app/app_context.dart'; import 'package:myhomie_app/constants.dart'; @@ -49,7 +50,7 @@ class _HomeScreenState extends State { print('ConnectionState.none'); return Text("No data"); } else { - return Container(height: size.height * 0.2, child: Loading()); + return Container(height: size.height * 0.2, child: LoadingCommon()); } } );