Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iampawan committed Apr 21, 2018
1 parent 12e6179 commit 8cd8eb7
Show file tree
Hide file tree
Showing 11 changed files with 695 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
.dart_tool/

.packages
.pub/

build/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## [0.0.1] - Release

* A customizable animated walkthrough library written in dart.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
36 changes: 36 additions & 0 deletions example/example_app.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:flutter_walkthrough/flutter_walkthrough.dart';
import 'package:flutter_walkthrough/walkthrough.dart';

class TestScreen extends StatelessWidget {
final List<Walkthrough> list = [
Walkthrough(
title: "Title 1",
content: "Content 1",
imageIcon: Icons.restaurant_menu,
),
Walkthrough(
title: "Title 2",
content: "Content 2",
imageIcon: Icons.search,
),
Walkthrough(
title: "Title 3",
content: "Content 3",
imageIcon: Icons.shopping_cart,
),
Walkthrough(
title: "Title 4",
content: "Content 4",
imageIcon: Icons.verified_user,
),
];

@override
Widget build(BuildContext context) {
return new IntroScreen(
list,
new MaterialPageRoute(builder: (context) => new TestScreen()),
);
}
}
19 changes: 19 additions & 0 deletions flutter_walkthrough.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart Packages" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Flutter Plugins" level="project" />
</component>
</module>
98 changes: 98 additions & 0 deletions lib/flutter_walkthrough.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
library flutter_walkthrough;

import 'package:flutter/material.dart';
import 'package:flutter_walkthrough/walkthrough.dart';

/// A IntroScreen Class.
///
///
class IntroScreen extends StatefulWidget {
final List<Walkthrough> walkthroughList;
final MaterialPageRoute pageRoute;
IntroScreen(this.walkthroughList, this.pageRoute);

void skipPage(BuildContext context) {
Navigator.push(context, pageRoute);
}

@override
IntroScreenState createState() {
return new IntroScreenState();
}
}

class IntroScreenState extends State<IntroScreen> {
final PageController controller = new PageController();
int currentPage = 0;
bool lastPage = false;

void _onPageChanged(int page) {
setState(() {
currentPage = page;
if (currentPage == widget.walkthroughList.length - 1) {
lastPage = true;
} else {
lastPage = false;
}
});
}

@override
Widget build(BuildContext context) {
return Container(
color: new Color(0xFFEEEEEE),
padding: const EdgeInsets.all(10.0),
child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Expanded(
flex: 1,
child: new Container(),
),
new Expanded(
flex: 3,
child: new PageView(
children: widget.walkthroughList,
controller: controller,
onPageChanged: _onPageChanged,
),
),
new Expanded(
flex: 1,
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
new FlatButton(
child: new Text(lastPage ? "" : "SKIP",
style: new TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16.0)),
onPressed: () => lastPage
? null
: widget.skipPage(
context,
),
),
new FlatButton(
child: new Text(lastPage ? "GOT IT" : "NEXT",
style: new TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16.0)),
onPressed: () => lastPage
? widget.skipPage(context)
: controller.nextPage(
duration: Duration(milliseconds: 300),
curve: Curves.easeIn),
),
],
),
)
],
),
);
}
}
91 changes: 91 additions & 0 deletions lib/walkthrough.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';

class Walkthrough extends StatefulWidget {
final title;
final content;
final imageIcon;
final imagecolor;

Walkthrough(
{this.title,
this.content,
this.imageIcon,
this.imagecolor = Colors.redAccent});

@override
WalkthroughState createState() {
return new WalkthroughState();
}
}

class WalkthroughState extends State<Walkthrough>
with SingleTickerProviderStateMixin {
Animation animation;
AnimationController animationController;

@override
void initState() {
// TODO: implement initState
super.initState();
animationController = new AnimationController(
vsync: this, duration: new Duration(milliseconds: 500));
animation = new Tween(begin: -250.0, end: 0.0).animate(new CurvedAnimation(
parent: animationController, curve: Curves.easeInOut));

animation.addListener(() => setState(() {}));

animationController.forward();
}

@override
void dispose() {
// TODO: implement dispose
super.dispose();
animationController.dispose();
}

@override
Widget build(BuildContext context) {
return new Container(
padding: const EdgeInsets.all(20.0),
child: new Material(
animationDuration: new Duration(milliseconds: 500),
elevation: 2.0,
borderRadius: new BorderRadius.all(Radius.circular(5.0)),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
new Transform(
transform:
new Matrix4.translationValues(animation.value, 0.0, 0.0),
child: new Text(
widget.title,
style: new TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.black),
),
),
new Transform(
transform:
new Matrix4.translationValues(animation.value, 0.0, 0.0),
child: new Text(widget.content,
softWrap: true,
textAlign: TextAlign.center,
style: new TextStyle(
fontWeight: FontWeight.normal,
fontSize: 15.0,
color: Colors.black)),
),
new Icon(
widget.imageIcon,
size: 100.0,
color: widget.imagecolor,
)
],
),
),
);
}
}
Loading

0 comments on commit 8cd8eb7

Please sign in to comment.