Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:flutter/animation.dart';
- class Intro extends StatefulWidget {
- @override
- _IntroState createState() => _IntroState();
- }
- class _IntroState extends State<Intro> with TickerProviderStateMixin {
- Animation animation, fadeout;
- AnimationController animationController, fadeController;
- PageController controller;
- int carouselIndex, itemIndex;
- @override
- void initState() {
- super.initState();
- controller = PageController(
- initialPage: 0,
- keepPage: true,
- viewportFraction: 0.8,
- );
- animationController = AnimationController(
- duration: Duration(seconds: 2),
- vsync: this,
- );
- fadeController = AnimationController(
- duration: Duration(seconds: 7),
- vsync: this,
- );
- fadeout = Tween(begin: -1.0, end: 0.0)
- .animate(CurvedAnimation(parent: fadeController, curve: Curves.easeIn));
- fadeController.forward();
- animation = Tween(begin: -1.0, end: 0.0).animate(CurvedAnimation(
- parent: animationController, curve: Curves.fastOutSlowIn));
- animationController.forward();
- }
- @override
- Widget build(BuildContext context) {
- final double width = MediaQuery.of(context).size.width;
- return AnimatedBuilder(
- animation: animationController,
- builder: (BuildContext context, Widget child) {
- return Scaffold(
- appBar: new AppBar(
- backgroundColor: Colors.white,
- elevation: 2.0,
- leading: IconButton(
- icon: Icon(
- Icons.list,
- color: Colors.red,
- ),
- onPressed: () {
- Navigator.pop(context);
- }),
- ),
- body: ListView(children: <Widget>[
- new Stack(
- children: <Widget>[
- new AspectRatio(
- aspectRatio: 10 / 100,
- child: new Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- image: AssetImage('assets/dashboard.png'),
- alignment: Alignment.topCenter)),
- ),
- ),
- new Transform(
- transform: Matrix4.translationValues(
- animation.value * width,
- 0.0,
- 0.0,
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12.0),
- child: Container(
- child: Column(
- children: <Widget>[
- SizedBox(height: 60.0),
- new Row(
- children: <Widget>[
- Expanded(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- 'Have you',
- style: TextStyle(
- color: Colors.black,
- fontSize: 24.0,
- height: 0.1),
- ),
- Padding(
- padding:
- const EdgeInsets.only(left: 8.0),
- child: Text(
- 'subscribe',
- style: TextStyle(
- color: Color(0xFFFFB300),
- fontSize: 24.0,
- height: 0.9),
- ),
- ),
- Padding(
- padding:
- const EdgeInsets.only(left: 13.0),
- child: Text(
- 'PewDiePie?',
- style: TextStyle(
- color: Color(0xFFFF1744),
- fontSize: 24.0,
- height: 0.8),
- ),
- )
- ],
- )),
- ],
- ),
- SizedBox(height: 7.7),
- ],
- ),
- ),
- ),
- ),
- new FadeTransition(
- opacity: fadeController
- .drive(CurveTween(curve: Curves.easeIn)),
- child: new Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 22.0, vertical: 115.0),
- child: new Row(
- children: <Widget>[
- Expanded(
- child: Row(
- children: <Widget>[
- new Padding(
- padding: const EdgeInsets.only(right: 3.3),
- child: new Container(
- height: 40.0,
- width: 65.0,
- decoration: BoxDecoration(
- color: Colors.red,
- borderRadius:
- BorderRadius.circular(5.0),
- ),
- child: Column(
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: <Widget>[
- Text('yes',
- style: TextStyle(
- color: Colors.white,
- fontSize: 21.5))
- ],
- ),
- ),
- ),
- new Padding(
- padding: const EdgeInsets.only(left: 3.3),
- child: new Container(
- height: 40.0,
- width: 65.0,
- decoration: BoxDecoration(
- color: Colors.greenAccent,
- borderRadius:
- BorderRadius.circular(5.0),
- ),
- child: Column(
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: <Widget>[
- Text('no',
- style: TextStyle(
- color: Colors.white,
- fontSize: 21.5))
- ],
- ),
- ),
- )
- ],
- ),
- )
- ],
- ),
- ),
- ),
- //HORIZONTAL LISTVIEW
- new ListView.builder(
- itemCount: 3,
- scrollDirection: Axis.horizontal,
- padding: EdgeInsets.symmetric(vertical: 16.0),
- itemBuilder: (BuildContext context, int index) {
- if (index % 3 == 0) {
- return _buildCarousel(context, index ~/ 3);
- } else {
- return Divider();
- }
- },
- ),
- ],
- ),
- ]));
- });
- }
- Widget _buildCarousel(BuildContext context, int carouselIndex) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Text('Carousel $carouselIndex'),
- SizedBox(
- // you may want to use an aspect ratio here for tablet support
- height: 200.0,
- child: PageView.builder(
- // store this controller in a State to save the carousel scroll position
- controller: PageController(viewportFraction: 0.8),
- itemBuilder: (BuildContext context, int itemIndex) {
- return _buildCarouselItem(context, carouselIndex, itemIndex);
- },
- ),
- )
- ],
- );
- }
- Widget _buildCarouselItem(
- BuildContext context, int carouselIndex, int itemIndex) {
- return Padding(
- padding: EdgeInsets.symmetric(horizontal: 4.0),
- child: Container(
- decoration: BoxDecoration(
- color: Colors.grey,
- borderRadius: BorderRadius.all(Radius.circular(4.0)),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement