Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 23a87a8

Browse files
authored
Merge pull request #39 from FlutterOpen/dev
add AnimatedSize,AnimatedOpacity,AnimatedWidget.
2 parents 992e804 + a91997b commit 23a87a8

File tree

8 files changed

+252
-0
lines changed

8 files changed

+252
-0
lines changed

‎lib/const/page_item_const.dart‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,24 @@ const PAGE_ITEMS = [
232232
"img": PageImage.FLUTTER_OPEN,
233233
"click": PageName.ANIM_MODAL_BARRIER,
234234
},
235+
{
236+
"title": PageName.ANIM_SIZE,
237+
"img": PageImage.FLUTTER_OPEN,
238+
"click": PageName.ANIM_SIZE,
239+
},
240+
{
241+
"title": PageName.ANIM_WIDGET,
242+
"img": PageImage.FLUTTER_OPEN,
243+
"click": PageName.ANIM_WIDGET,
244+
},
245+
{
246+
"title": PageName.ANIM_PYH_MODEL,
247+
"img": PageImage.FLUTTER_OPEN,
248+
"click": PageName.ANIM_PYH_MODEL,
249+
},
250+
{
251+
"title": PageName.ANIM_OPACITY,
252+
"img": PageImage.FLUTTER_OPEN,
253+
"click": PageName.ANIM_OPACITY,
254+
},
235255
];

‎lib/const/page_name_const.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@ class PageName {
5151
static const ANIM_DEFAULT_TEXT = "DefaultText";
5252
static const ANIM_LIST = "AnimationList";
5353
static const ANIM_MODAL_BARRIER = "AnimatedModalBarrier";
54+
static const ANIM_SIZE = "AnimatedSize";
55+
static const ANIM_WIDGET = "AnimatedWidget";
56+
static const ANIM_PYH_MODEL = "PyhModel";
57+
static const ANIM_OPACITY = "OpacityPage";
5458
}

‎lib/main.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class FlutterOpenApp extends StatelessWidget {
6565
PageName.ANIM_DEFAULT_TEXT: (context) => DefaultTextPage(),
6666
PageName.ANIM_LIST: (context) => AnimListPage(),
6767
PageName.ANIM_MODAL_BARRIER: (context) => AnimatedModalPage(),
68+
PageName.ANIM_SIZE: (context) => AnimSizePage(),
69+
PageName.ANIM_WIDGET: (context) => AnimWidgetPage(),
70+
PageName.ANIM_PYH_MODEL: (context) => PyhModelPage(),
71+
PageName.ANIM_OPACITY: (context) => AnimOpacityPage(),
6872
},
6973
);
7074
}

‎lib/page/anim/AnimOpacityPage.dart‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
///
2+
/// Created by NieBin on 2019年6月10日
3+
/// Github: https://github.com/nb312
4+
/// Email: niebin312@gmail.com
5+
///
6+
import "package:flutter/material.dart";
7+
import 'package:flutter_widgets/const/_const.dart';
8+
9+
class AnimOpacityPage extends StatefulWidget {
10+
@override
11+
_AnimOpacityState createState() => _AnimOpacityState();
12+
}
13+
14+
class _AnimOpacityState extends State<AnimOpacityPage> {
15+
var op = 1.0;
16+
17+
Widget _opacity() => AnimatedOpacity(
18+
opacity: op,
19+
duration: Duration(seconds: 1),
20+
child: Container(
21+
color: RED_LIGHT,
22+
child: Padding(
23+
padding: EdgeInsets.all(50),
24+
child: FloatingActionButton(onPressed: () {
25+
setState(() {
26+
op = op > 0.51 ? 0.5 : 1.0;
27+
});
28+
}),
29+
),
30+
),
31+
);
32+
33+
@override
34+
Widget build(BuildContext context) {
35+
return Scaffold(
36+
appBar: AppBar(
37+
title: Text(PageName.ANIM_OPACITY),
38+
),
39+
body: _opacity(),
40+
);
41+
}
42+
}

‎lib/page/anim/AnimSizePage.dart‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
///
2+
/// Created by NieBin on 2019年6月10日
3+
/// Github: https://github.com/nb312
4+
/// Email: niebin312@gmail.com
5+
6+
import "package:flutter/material.dart";
7+
import 'package:flutter_widgets/const/_const.dart';
8+
9+
class AnimSizePage extends StatefulWidget {
10+
@override
11+
_AnimSizeState createState() => _AnimSizeState();
12+
}
13+
14+
class _AnimSizeState extends State<AnimSizePage>
15+
with SingleTickerProviderStateMixin {
16+
var _size = 100.0;
17+
18+
Widget _sizeW() => AnimatedSize(
19+
duration: Duration(seconds: 3),
20+
vsync: this,
21+
child: InkWell(
22+
child: Container(
23+
constraints: BoxConstraints.expand(width: _size, height: _size),
24+
color: RED_LIGHT,
25+
child: Text("Click"),
26+
),
27+
onTap: () {
28+
setState(() {
29+
_size = _size + 20.0;
30+
if (_size > 500) {
31+
_size = 10;
32+
}
33+
});
34+
},
35+
),
36+
);
37+
38+
@override
39+
void initState() {
40+
// _controller =
41+
// AnimationController(vsync: this, duration: Duration(seconds: 2));
42+
// CurvedAnimation curve =
43+
// CurvedAnimation(parent: _controller, curve: Curves.easeIn);
44+
//
45+
// _anim = Tween(begin: 0.0, end: 1.0).animate(curve);
46+
super.initState();
47+
}
48+
49+
@override
50+
Widget build(BuildContext context) {
51+
return Scaffold(
52+
appBar: AppBar(
53+
title: Text(PageName.ANIM_SIZE),
54+
),
55+
body: Column(
56+
children: <Widget>[
57+
_sizeW(),
58+
],
59+
),
60+
);
61+
}
62+
}

‎lib/page/anim/AnimWidgetPage.dart‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
///
2+
/// Created by NieBin on 2019年6月10日
3+
/// Github: https://github.com/nb312
4+
/// Email: niebin312@gmail.com
5+
///
6+
import "package:flutter/material.dart";
7+
import 'package:flutter_widgets/const/_const.dart';
8+
9+
class AnimWidgetPage extends StatefulWidget {
10+
@override
11+
_AnimWidgetState createState() => _AnimWidgetState();
12+
}
13+
14+
class _AnimWidgetState extends State<AnimWidgetPage>
15+
with SingleTickerProviderStateMixin {
16+
Animation<double> _anim;
17+
AnimationController _controller;
18+
19+
@override
20+
void initState() {
21+
_controller =
22+
AnimationController(vsync: this, duration: Duration(seconds: 2));
23+
CurvedAnimation curve =
24+
CurvedAnimation(parent: _controller, curve: Curves.easeIn);
25+
_anim = Tween(begin: 0.0, end: 30.0).animate(curve);
26+
super.initState();
27+
}
28+
29+
Widget _animWidget() => _AnimWidget(
30+
anim: _anim,
31+
child: Text("This is Animation Widget."),
32+
);
33+
34+
@override
35+
Widget build(BuildContext context) {
36+
return Scaffold(
37+
appBar: AppBar(
38+
title: Text(PageName.ANIM_WIDGET),
39+
),
40+
body: Column(
41+
children: <Widget>[
42+
_animWidget(),
43+
FloatingActionButton(
44+
child: Text("Click me."),
45+
onPressed: () {
46+
_controller.reset();
47+
_controller.forward();
48+
},
49+
)
50+
],
51+
),
52+
);
53+
}
54+
}
55+
56+
class _AnimWidget extends AnimatedWidget {
57+
const _AnimWidget({Key key, Animation<double> anim, this.child})
58+
: super(key: key, listenable: anim);
59+
60+
Animation<double> get size => listenable;
61+
final Widget child;
62+
63+
@override
64+
Widget build(BuildContext context) {
65+
return Container(
66+
constraints: BoxConstraints.expand(
67+
width: size.value * 10,
68+
height: size.value * 10,
69+
),
70+
color: RED_LIGHT,
71+
child: child);
72+
}
73+
}

‎lib/page/anim/PyhModelPage.dart‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
///
2+
/// Created by NieBin on 2019年6月10日
3+
/// Github: https://github.com/nb312
4+
/// Email: niebin312@gmail.com
5+
///
6+
import "package:flutter_widgets/const/_const.dart";
7+
import 'package:flutter/material.dart';
8+
9+
class PyhModelPage extends StatefulWidget {
10+
@override
11+
_BaseState createState() => _BaseState();
12+
}
13+
14+
class _BaseState extends State<PyhModelPage> {
15+
Color _color = RED_LIGHT;
16+
17+
Widget _pyhModel() => AnimatedPhysicalModel(
18+
child: Container(
19+
child: Padding(
20+
padding: EdgeInsets.all(40),
21+
child: FloatingActionButton(onPressed: () {
22+
setState(() {
23+
_color = _color == RED_LIGHT ? PURPLE : RED_LIGHT;
24+
});
25+
}),
26+
),
27+
),
28+
shape: BoxShape.rectangle,
29+
elevation: 2,
30+
color: _color,
31+
shadowColor: BLUE_DEEP,
32+
duration: Duration(milliseconds: 100));
33+
34+
@override
35+
Widget build(BuildContext context) {
36+
return Scaffold(
37+
appBar: AppBar(
38+
title: Text(PageName.ANIM_PYH_MODEL),
39+
),
40+
body: _pyhModel(),
41+
);
42+
}
43+
}

‎lib/page/anim/_anim.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ export 'RotationPage.dart';
1212
export 'DefaultTextPage.dart';
1313
export 'AnimListPage.dart';
1414
export 'AnimatedModalPage.dart';
15+
export 'AnimSizePage.dart';
16+
export 'AnimWidgetPage.dart';
17+
export 'PyhModelPage.dart';
18+
export 'AnimOpacityPage.dart';

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /