Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/const/page_item_const.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,24 @@ const PAGE_ITEMS = [
"img": PageImage.FLUTTER_OPEN,
"click": PageName.ANIM_MODAL_BARRIER,
},
{
"title": PageName.ANIM_SIZE,
"img": PageImage.FLUTTER_OPEN,
"click": PageName.ANIM_SIZE,
},
{
"title": PageName.ANIM_WIDGET,
"img": PageImage.FLUTTER_OPEN,
"click": PageName.ANIM_WIDGET,
},
{
"title": PageName.ANIM_PYH_MODEL,
"img": PageImage.FLUTTER_OPEN,
"click": PageName.ANIM_PYH_MODEL,
},
{
"title": PageName.ANIM_OPACITY,
"img": PageImage.FLUTTER_OPEN,
"click": PageName.ANIM_OPACITY,
},
];
4 changes: 4 additions & 0 deletions lib/const/page_name_const.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ class PageName {
static const ANIM_DEFAULT_TEXT = "DefaultText";
static const ANIM_LIST = "AnimationList";
static const ANIM_MODAL_BARRIER = "AnimatedModalBarrier";
static const ANIM_SIZE = "AnimatedSize";
static const ANIM_WIDGET = "AnimatedWidget";
static const ANIM_PYH_MODEL = "PyhModel";
static const ANIM_OPACITY = "OpacityPage";
}
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ class FlutterOpenApp extends StatelessWidget {
PageName.ANIM_DEFAULT_TEXT: (context) => DefaultTextPage(),
PageName.ANIM_LIST: (context) => AnimListPage(),
PageName.ANIM_MODAL_BARRIER: (context) => AnimatedModalPage(),
PageName.ANIM_SIZE: (context) => AnimSizePage(),
PageName.ANIM_WIDGET: (context) => AnimWidgetPage(),
PageName.ANIM_PYH_MODEL: (context) => PyhModelPage(),
PageName.ANIM_OPACITY: (context) => AnimOpacityPage(),
},
);
}
Expand Down
42 changes: 42 additions & 0 deletions lib/page/anim/AnimOpacityPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
///
/// Created by NieBin on 2019/6/10
/// Github: https://github.com/nb312
/// Email: niebin312@gmail.com
///
import "package:flutter/material.dart";
import 'package:flutter_widgets/const/_const.dart';

class AnimOpacityPage extends StatefulWidget {
@override
_AnimOpacityState createState() => _AnimOpacityState();
}

class _AnimOpacityState extends State<AnimOpacityPage> {
var op = 1.0;

Widget _opacity() => AnimatedOpacity(
opacity: op,
duration: Duration(seconds: 1),
child: Container(
color: RED_LIGHT,
child: Padding(
padding: EdgeInsets.all(50),
child: FloatingActionButton(onPressed: () {
setState(() {
op = op > 0.51 ? 0.5 : 1.0;
});
}),
),
),
);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(PageName.ANIM_OPACITY),
),
body: _opacity(),
);
}
}
62 changes: 62 additions & 0 deletions lib/page/anim/AnimSizePage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
///
/// Created by NieBin on 2019/6/10
/// Github: https://github.com/nb312
/// Email: niebin312@gmail.com

import "package:flutter/material.dart";
import 'package:flutter_widgets/const/_const.dart';

class AnimSizePage extends StatefulWidget {
@override
_AnimSizeState createState() => _AnimSizeState();
}

class _AnimSizeState extends State<AnimSizePage>
with SingleTickerProviderStateMixin {
var _size = 100.0;

Widget _sizeW() => AnimatedSize(
duration: Duration(seconds: 3),
vsync: this,
child: InkWell(
child: Container(
constraints: BoxConstraints.expand(width: _size, height: _size),
color: RED_LIGHT,
child: Text("Click"),
),
onTap: () {
setState(() {
_size = _size + 20.0;
if (_size > 500) {
_size = 10;
}
});
},
),
);

@override
void initState() {
// _controller =
// AnimationController(vsync: this, duration: Duration(seconds: 2));
// CurvedAnimation curve =
// CurvedAnimation(parent: _controller, curve: Curves.easeIn);
//
// _anim = Tween(begin: 0.0, end: 1.0).animate(curve);
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(PageName.ANIM_SIZE),
),
body: Column(
children: <Widget>[
_sizeW(),
],
),
);
}
}
73 changes: 73 additions & 0 deletions lib/page/anim/AnimWidgetPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
///
/// Created by NieBin on 2019/6/10
/// Github: https://github.com/nb312
/// Email: niebin312@gmail.com
///
import "package:flutter/material.dart";
import 'package:flutter_widgets/const/_const.dart';

class AnimWidgetPage extends StatefulWidget {
@override
_AnimWidgetState createState() => _AnimWidgetState();
}

class _AnimWidgetState extends State<AnimWidgetPage>
with SingleTickerProviderStateMixin {
Animation<double> _anim;
AnimationController _controller;

@override
void initState() {
_controller =
AnimationController(vsync: this, duration: Duration(seconds: 2));
CurvedAnimation curve =
CurvedAnimation(parent: _controller, curve: Curves.easeIn);
_anim = Tween(begin: 0.0, end: 30.0).animate(curve);
super.initState();
}

Widget _animWidget() => _AnimWidget(
anim: _anim,
child: Text("This is Animation Widget."),
);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(PageName.ANIM_WIDGET),
),
body: Column(
children: <Widget>[
_animWidget(),
FloatingActionButton(
child: Text("Click me."),
onPressed: () {
_controller.reset();
_controller.forward();
},
)
],
),
);
}
}

class _AnimWidget extends AnimatedWidget {
const _AnimWidget({Key key, Animation<double> anim, this.child})
: super(key: key, listenable: anim);

Animation<double> get size => listenable;
final Widget child;

@override
Widget build(BuildContext context) {
return Container(
constraints: BoxConstraints.expand(
width: size.value * 10,
height: size.value * 10,
),
color: RED_LIGHT,
child: child);
}
}
43 changes: 43 additions & 0 deletions lib/page/anim/PyhModelPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
///
/// Created by NieBin on 2019/6/10
/// Github: https://github.com/nb312
/// Email: niebin312@gmail.com
///
import "package:flutter_widgets/const/_const.dart";
import 'package:flutter/material.dart';

class PyhModelPage extends StatefulWidget {
@override
_BaseState createState() => _BaseState();
}

class _BaseState extends State<PyhModelPage> {
Color _color = RED_LIGHT;

Widget _pyhModel() => AnimatedPhysicalModel(
child: Container(
child: Padding(
padding: EdgeInsets.all(40),
child: FloatingActionButton(onPressed: () {
setState(() {
_color = _color == RED_LIGHT ? PURPLE : RED_LIGHT;
});
}),
),
),
shape: BoxShape.rectangle,
elevation: 2,
color: _color,
shadowColor: BLUE_DEEP,
duration: Duration(milliseconds: 100));

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(PageName.ANIM_PYH_MODEL),
),
body: _pyhModel(),
);
}
}
4 changes: 4 additions & 0 deletions lib/page/anim/_anim.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ export 'RotationPage.dart';
export 'DefaultTextPage.dart';
export 'AnimListPage.dart';
export 'AnimatedModalPage.dart';
export 'AnimSizePage.dart';
export 'AnimWidgetPage.dart';
export 'PyhModelPage.dart';
export 'AnimOpacityPage.dart';