Skip to content

Commit

Permalink
Added app logo animation instead of loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar1805 committed Aug 9, 2021
1 parent a13ce6b commit 58e330b
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 9 deletions.
176 changes: 169 additions & 7 deletions lib/login/loading.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,175 @@
import 'package:flutter_spinkit/flutter_spinkit.dart';
// import 'package:flutter_spinkit/flutter_spinkit.dart';
// import 'package:flutter/material.dart';

// class Loading extends StatelessWidget {
// @override
// Widget build(BuildContext context) {
// return Container(
// color: Color.fromRGBO(10, 80, 106, 1),
// child: Center(
// child: SpinKitFoldingCube(color: Colors.white, size: 50.0),
// ));
// }
// }
import 'dart:async';
import 'package:flutter/animation.dart';
import 'package:flutter/material.dart';

class Loading extends StatelessWidget {
class SplashScreen1Sub extends StatefulWidget {
@override
_SplashScreen1SubState createState() => _SplashScreen1SubState();
}

class _SplashScreen1SubState extends State<SplashScreen1Sub>
with TickerProviderStateMixin {
double _fontSize = 2;
double _containerSize = 1.5;
double _textOpacity = 0.0;
double _containerOpacity = 0.0;

AnimationController _controller;
Animation<double> animation1;

@override
void initState() {
super.initState();

_controller =
AnimationController(vsync: this, duration: Duration(seconds: 3));

animation1 = Tween<double>(begin: 40, end: 20).animate(CurvedAnimation(
parent: _controller, curve: Curves.fastLinearToSlowEaseIn))
..addListener(() {
setState(() {
_textOpacity = 1.0;
});
});

_controller.forward();

Timer(Duration(seconds: 2), () {
setState(() {
_fontSize = 1.3;
});
});

Timer(Duration(seconds: 2), () {
setState(() {
_containerSize = 2;
_containerOpacity = 1;
});
});

// Timer(Duration(seconds: 4), () {
// setState(() {
// Navigator.pushReplacement(
// context, PageTransition1(SplashScreen1SubHome()));
// });
// });
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
double _width = MediaQuery.of(context).size.width;
double _height = MediaQuery.of(context).size.height;

return Scaffold(
backgroundColor: Color.fromRGBO(10, 80, 106, 1),
body: Stack(
children: [
Column(
children: [
AnimatedContainer(
duration: Duration(milliseconds: 2000),
curve: Curves.fastLinearToSlowEaseIn,
height: _height / _fontSize),
AnimatedOpacity(
duration: Duration(milliseconds: 1000),
opacity: _textOpacity,
child: Text(
'BHBS',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: animation1.value,
),
),
),
],
),
Center(
child: AnimatedOpacity(
duration: Duration(milliseconds: 2000),
curve: Curves.fastLinearToSlowEaseIn,
opacity: _containerOpacity,
child: AnimatedContainer(
duration: Duration(milliseconds: 2000),
curve: Curves.fastLinearToSlowEaseIn,
height: _width / _containerSize,
width: _width / _containerSize,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
),
child: Image.asset('assets/logo.png'),
),
),
),
],
),
);
}
}

class PageTransition1 extends PageRouteBuilder {
final Widget page;

PageTransition1(this.page)
: super(
pageBuilder: (context, animation, anotherAnimation) => page,
transitionDuration: Duration(milliseconds: 4000),
transitionsBuilder: (context, animation, anotherAnimation, child) {
animation = CurvedAnimation(
curve: Curves.fastLinearToSlowEaseIn,
parent: animation,
);
return Align(
alignment: Alignment.bottomCenter,
child: SizeTransition(
sizeFactor: animation,
child: page,
axisAlignment: 0,
),
);
},
);
}

class SplashScreen1SubHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Color.fromRGBO(10, 80, 106, 1),
child: Center(
child: SpinKitFoldingCube(color: Colors.white, size: 50.0),
));
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
brightness: Brightness.dark,
backgroundColor: Color.fromRGBO(10, 80, 106, 1),
centerTitle: true,
title: Text(
'BHBS',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
),
);
}
}
2 changes: 1 addition & 1 deletion lib/login/loginUI.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _LoginFormState extends State<LoginForm> {
Widget build(BuildContext context) {
final loginProvider = Provider.of<LoginProvider>(context);
return loading
? Loading()
? SplashScreen1Sub()
: Scaffold(
backgroundColor: Color.fromRGBO(10, 80, 106, 1),
body: SingleChildScrollView(
Expand Down
2 changes: 1 addition & 1 deletion lib/login/resetPassword.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _ResetPassState extends State<ResetPass> {
@override
Widget build(BuildContext context) {
return loading
? Loading()
? SplashScreen1Sub()
: WillPopScope(
onWillPop: () {
Navigator.pushAndRemoveUntil(
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.40.6"
animations:
dependency: "direct main"
description:
name: animations
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
archive:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies:
video_player:
chewie:
cached_network_image:
animations:

# speech_recognition: ^0.3.0+1

Expand Down

0 comments on commit 58e330b

Please sign in to comment.