diff --git a/lib/pages/animated_widgets/rotate_icon.dart b/lib/pages/animated_widgets/rotate_icon.dart index e69de29..d93f6b3 100644 --- a/lib/pages/animated_widgets/rotate_icon.dart +++ b/lib/pages/animated_widgets/rotate_icon.dart @@ -0,0 +1,76 @@ +import 'package:flutter/widgets.dart'; + +class RotateIconController { + VoidCallback? forward; + VoidCallback? reverse; + VoidCallback? reset; +} + +class RotateIcon extends StatefulWidget { + const RotateIcon({ + Key? key, + required this.icon, + required this.curve, + this.controller, + this.animationDurationMultiplier = 1.0, + this.rotationPercent = 0.5, + }) : super(key: key); + + final Widget icon; + final Curve curve; + final RotateIconController? controller; + final double animationDurationMultiplier; + final double rotationPercent; + + @override + State createState() => _RotateIconState(); +} + +class _RotateIconState extends State + with SingleTickerProviderStateMixin { + late final AnimationController animationController; + late final Animation animation; + late final Duration duration; + + @override + void initState() { + duration = Duration( + milliseconds: (500 * widget.animationDurationMultiplier).toInt(), + ); + animationController = AnimationController( + vsync: this, + duration: duration, + ); + animation = Tween( + begin: 0.0, + end: widget.rotationPercent, + ).animate( + CurvedAnimation( + curve: widget.curve, + parent: animationController, + ), + ); + + widget.controller?.forward = animationController.forward; + widget.controller?.reverse = animationController.reverse; + widget.controller?.reset = animationController.reset; + + super.initState(); + } + + @override + void dispose() { + animationController.dispose(); + widget.controller?.forward = null; + widget.controller?.reverse = null; + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return RotationTransition( + turns: animation, + child: widget.icon, + ); + } +} diff --git a/lib/pages/main_screen/main_screen_widget.dart b/lib/pages/main_screen/main_screen_widget.dart index 06c478c..e56c390 100644 --- a/lib/pages/main_screen/main_screen_widget.dart +++ b/lib/pages/main_screen/main_screen_widget.dart @@ -32,6 +32,7 @@ class _MainScreenWidgetState extends State { title: Row( // mainAxisAlignment: MainAxisAlignment.center, children: [ + // use png instead SvgPicture.asset( Assets.svg.drifterIcon, height: 30, diff --git a/lib/pages/splash_screen/splash_screen.dart b/lib/pages/splash_screen/splash_screen.dart index ec8f03c..43fa189 100644 --- a/lib/pages/splash_screen/splash_screen.dart +++ b/lib/pages/splash_screen/splash_screen.dart @@ -1,6 +1,5 @@ import 'dart:io'; -import 'package:drifter/pages/main_screen/main_screen_widget.dart'; import 'package:drifter/theme/app_colors.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -27,6 +26,7 @@ class _SplashState extends State { @override Widget build(BuildContext context) { + var isAndroid; return Scaffold( backgroundColor: AppColors.background, body: Center( @@ -55,6 +55,7 @@ class _SplashState extends State { const SizedBox( height: 250, ), + //replace with rotating drifter icon if (Platform.isAndroid) const CircularProgressIndicator( color: AppColors.mainAccent,