forked from alexvasl/drifter_app
added rotating icon to splash loading
This commit is contained in:
parent
41e0117c65
commit
578a461075
@ -1,8 +1,8 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class RotateIconController {
|
||||
VoidCallback? forward;
|
||||
VoidCallback? reverse;
|
||||
// VoidCallback? forward;
|
||||
VoidCallback? repeat;
|
||||
VoidCallback? reset;
|
||||
}
|
||||
|
||||
@ -51,8 +51,8 @@ class _RotateIconState extends State<RotateIcon>
|
||||
),
|
||||
);
|
||||
|
||||
widget.controller?.forward = animationController.forward;
|
||||
widget.controller?.reverse = animationController.reverse;
|
||||
// widget.controller?.forward = animationController.forward;
|
||||
widget.controller?.repeat = animationController.repeat;
|
||||
widget.controller?.reset = animationController.reset;
|
||||
|
||||
super.initState();
|
||||
@ -61,8 +61,8 @@ class _RotateIconState extends State<RotateIcon>
|
||||
@override
|
||||
void dispose() {
|
||||
animationController.dispose();
|
||||
widget.controller?.forward = null;
|
||||
widget.controller?.reverse = null;
|
||||
// widget.controller?.forward = null;
|
||||
widget.controller?.repeat = null;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:drifter/pages/animated_widgets/rotate_icon.dart';
|
||||
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';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
|
||||
@ -15,18 +14,33 @@ class Splash extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SplashState extends State<Splash> {
|
||||
late final RotateIconController _rotateIconController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_rotateIconController = RotateIconController();
|
||||
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
Navigator.pushReplacement(context,
|
||||
MaterialPageRoute(builder: (context) => const MainScreenWidget()));
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
dispose() {
|
||||
_rotateIconController.repeat = null;
|
||||
_rotateIconController.reset = null;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var isAndroid;
|
||||
_rotateIconController.reset?.call();
|
||||
_rotateIconController.repeat?.call();
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.background,
|
||||
body: Center(
|
||||
@ -53,17 +67,20 @@ class _SplashState extends State<Splash> {
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 250,
|
||||
height: 230,
|
||||
),
|
||||
//replace with rotating drifter icon
|
||||
if (Platform.isAndroid)
|
||||
const CircularProgressIndicator(
|
||||
color: AppColors.mainAccent,
|
||||
)
|
||||
else
|
||||
const CupertinoActivityIndicator(
|
||||
radius: 20,
|
||||
)
|
||||
RotateIcon(
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.drifterIcon,
|
||||
height: 45,
|
||||
width: 45,
|
||||
),
|
||||
curve: Curves.easeInOutSine,
|
||||
animationDurationMultiplier: 1.2,
|
||||
rotationPercent: 1.0,
|
||||
controller: _rotateIconController,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user