forked from alexvasl/drifter_app
Compare commits
2 Commits
f6a466872f
...
41e0117c65
Author | SHA1 | Date | |
---|---|---|---|
41e0117c65 | |||
01652be658 |
76
lib/pages/animated_widgets/rotate_icon.dart
Normal file
76
lib/pages/animated_widgets/rotate_icon.dart
Normal file
@ -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<RotateIcon> createState() => _RotateIconState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RotateIconState extends State<RotateIcon>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController animationController;
|
||||||
|
late final Animation<double> animation;
|
||||||
|
late final Duration duration;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
duration = Duration(
|
||||||
|
milliseconds: (500 * widget.animationDurationMultiplier).toInt(),
|
||||||
|
);
|
||||||
|
animationController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: duration,
|
||||||
|
);
|
||||||
|
animation = Tween<double>(
|
||||||
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,7 @@ class _MainScreenWidgetState extends State<MainScreenWidget> {
|
|||||||
title: Row(
|
title: Row(
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
// use png instead
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
Assets.svg.drifterIcon,
|
Assets.svg.drifterIcon,
|
||||||
height: 30,
|
height: 30,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
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/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -27,6 +26,7 @@ class _SplashState extends State<Splash> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var isAndroid;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.background,
|
backgroundColor: AppColors.background,
|
||||||
body: Center(
|
body: Center(
|
||||||
@ -55,6 +55,7 @@ class _SplashState extends State<Splash> {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 250,
|
height: 250,
|
||||||
),
|
),
|
||||||
|
//replace with rotating drifter icon
|
||||||
if (Platform.isAndroid)
|
if (Platform.isAndroid)
|
||||||
const CircularProgressIndicator(
|
const CircularProgressIndicator(
|
||||||
color: AppColors.mainAccent,
|
color: AppColors.mainAccent,
|
||||||
|
@ -6,7 +6,7 @@ abstract class Assets {
|
|||||||
class _PNG {
|
class _PNG {
|
||||||
const _PNG();
|
const _PNG();
|
||||||
|
|
||||||
// String get drifterIcon => "assets/images/logo/drifter_vector.png";
|
String get drifterPNG => "assets/images/logo/drifter_vector.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SVG {
|
class _SVG {
|
||||||
|
@ -63,7 +63,7 @@ flutter:
|
|||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
assets:
|
assets:
|
||||||
- assets/images
|
- assets/images/logo/
|
||||||
# - images/a_dot_ham.jpeg
|
# - images/a_dot_ham.jpeg
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
|
Loading…
Reference in New Issue
Block a user