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