Skip to content

Commit ce74dc9

Browse files
committed
add
2 parents 9895327 + a62491e commit ce74dc9

File tree

6 files changed

+428
-221
lines changed

6 files changed

+428
-221
lines changed

.idea/workspace.xml

Lines changed: 244 additions & 216 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import 'material/DraggableDemo.dart';
2525
import 'material/animation/AnimationPage.dart';
2626
import 'material/paint/CustomPainterDemo.dart';
2727
import 'material/animation/AnimationBuilderDemo.dart';
28+
import 'material/animation/WavyHeaderImage.dart';
29+
import 'material/BackdropFilterDemo.dart';
2830

2931
void main() => runApp(
3032
//The => expr syntax is a shorthand for { return expr; }. The => notation is sometimes referred to as arrow syntax.
@@ -55,7 +57,7 @@ class MyApp extends StatelessWidget {
5557
// products: initProducts(),
5658
// ),
5759
// home: BasicAppBarSample(),
58-
home: TabBarDemo(),
60+
// home: TabBarDemo(),
5961
// home: AppBarBottomSample(),
6062
// home: ListViewDemo(),
6163
// home: TextFieldSample(),
@@ -74,6 +76,8 @@ class MyApp extends StatelessWidget {
7476
// home: AnimationPage(),
7577
// home: CustomPainterDemo(),
7678
// home: AnimationBuilderDemo(),
79+
// home: WavyHeaderPage(),
80+
home: BackdropFilterPage(),
7781
);
7882
}
7983
}

lib/material/BackdropFilterDemo.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter/widgets.dart';
3+
import 'dart:ui';
4+
5+
class BackdropFilterPage extends StatefulWidget {
6+
@override
7+
_MyHomePageState createState() => _MyHomePageState();
8+
}
9+
10+
class _MyHomePageState extends State<BackdropFilterPage> {
11+
@override
12+
Widget build(BuildContext context) {
13+
return Scaffold(
14+
body: _WavyHeaderImage(),
15+
);
16+
}
17+
}
18+
19+
class _WavyHeaderImage extends StatelessWidget {
20+
@override
21+
Widget build(BuildContext context) {
22+
return new Stack(
23+
children: <Widget>[
24+
new Positioned(
25+
left: 0.0,
26+
top: 0.0,
27+
right: 0.0,
28+
bottom: 0.0,
29+
child: new Image.asset(
30+
'images/2018.jpg',
31+
fit: BoxFit.fill,
32+
)),
33+
new Positioned(
34+
top: 200.0,
35+
left: 100.0,
36+
right: 100.0,
37+
bottom: 200.0,
38+
child: new BackdropFilter(
39+
filter: new ImageFilter.blur(sigmaX: 12.0, sigmaY: 12.0),
40+
// child: new Text(
41+
// 'test',
42+
// style: Theme.of(context).textTheme.headline,
43+
// textAlign: TextAlign.center,
44+
// maxLines: 1,
45+
// ),
46+
child: new Container(
47+
color: const Color.fromRGBO(0, 0, 0, 0.5),
48+
),
49+
),
50+
),
51+
],
52+
);
53+
}
54+
}

lib/material/TabBarSample.dart

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,53 @@
11
import 'package:flutter/material.dart';
22

3-
class TabBarDemo extends StatelessWidget {
3+
class TabBarDemo extends StatefulWidget {
4+
@override
5+
State<StatefulWidget> createState() {
6+
return TabBarState();
7+
}
8+
}
9+
10+
class TabBarState extends State<TabBarDemo>
11+
with SingleTickerProviderStateMixin {
12+
Color _themeColor = Colors.blue;
13+
TabController _tabController;
14+
15+
@override
16+
void initState() {
17+
super.initState();
18+
_tabController = TabController(length: 3, initialIndex: 0, vsync: this);
19+
_tabController.addListener(getCurrentIndex);
20+
}
21+
22+
void getCurrentIndex() {
23+
print("currentIndex:${_tabController.index}");
24+
setState(() {
25+
switch (_tabController.index) {
26+
case 0:
27+
_themeColor = Colors.blue;
28+
break;
29+
case 1:
30+
_themeColor = Colors.red;
31+
break;
32+
case 2:
33+
_themeColor = Colors.black38;
34+
break;
35+
}
36+
});
37+
}
38+
39+
@override
40+
void dispose() {
41+
_tabController.dispose();
42+
super.dispose();
43+
}
44+
445
@override
546
Widget build(BuildContext context) {
6-
return DefaultTabController(
7-
length: 3,
47+
return Theme(
48+
data: ThemeData(
49+
primaryColor: _themeColor,
50+
),
851
child: Scaffold(
952
appBar: AppBar(
1053
bottom: TabBar(
@@ -13,6 +56,16 @@ class TabBarDemo extends StatelessWidget {
1356
Tab(text: "Train", icon: Icon(Icons.directions_transit)),
1457
Tab(text: "Bike", icon: Icon(Icons.directions_bike)),
1558
],
59+
controller: _tabController,
60+
// indicator: ShapeDecoration(
61+
// color: Colors.white,
62+
// shape: RoundedRectangleBorder(
63+
// borderRadius: BorderRadius.all(
64+
// Radius.circular(10),
65+
// ),
66+
// ),
67+
// ),
68+
indicatorColor: Colors.white,
1669
),
1770
title: Text('Tabs Demo'),
1871
),
@@ -22,16 +75,18 @@ class TabBarDemo extends StatelessWidget {
2275
Icon(Icons.directions_transit),
2376
Icon(Icons.directions_bike),
2477
],
78+
controller: _tabController,
2579
),
2680
bottomNavigationBar: Container(
2781
height: 60.0,
28-
color: Colors.blue[500],
82+
color: _themeColor,
2983
child: TabBar(
3084
tabs: [
3185
Tab(text: "Car", icon: Icon(Icons.directions_car)),
3286
Tab(text: "Train", icon: Icon(Icons.directions_transit)),
3387
Tab(text: "Bike", icon: Icon(Icons.directions_bike)),
3488
],
89+
controller: _tabController,
3590
),
3691
),
3792
drawer: Container(
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter/widgets.dart';
3+
4+
class WavyHeaderPage extends StatefulWidget {
5+
@override
6+
_MyHomePageState createState() => _MyHomePageState();
7+
}
8+
9+
class _MyHomePageState extends State<WavyHeaderPage> {
10+
@override
11+
Widget build(BuildContext context) {
12+
return Scaffold(
13+
body: _WavyHeaderImage(),
14+
);
15+
}
16+
}
17+
18+
class _WavyHeaderImage extends StatelessWidget {
19+
@override
20+
Widget build(BuildContext context) {
21+
return ClipPath(
22+
child: Image.asset('images/2018.jpg'),
23+
clipper: BottomWaveClipper(),
24+
);
25+
}
26+
}
27+
28+
class BottomWaveClipper extends CustomClipper<Path> {
29+
@override
30+
Path getClip(Size size) {
31+
var path = Path();
32+
path.lineTo(0.0, size.height - 20);
33+
var firstControlPoint = Offset(size.width / 4, size.height);
34+
var firstEndPoint = Offset(size.width / 2.25, size.height - 30.0);
35+
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
36+
firstEndPoint.dx, firstEndPoint.dy);
37+
38+
var secondControlPoint =
39+
Offset(size.width - (size.width / 3.25), size.height - 65);
40+
var secondEndPoint = Offset(size.width, size.height - 40);
41+
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
42+
secondEndPoint.dx, secondEndPoint.dy);
43+
44+
path.lineTo(size.width, size.height - 40);
45+
path.lineTo(size.width, 0.0);
46+
path.close();
47+
48+
return path;
49+
}
50+
51+
@override
52+
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
53+
}

lib/material/paint/CustomPainterDemo.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ class CustomPainterDemo extends StatelessWidget {
1414
size: Size.square(200),
1515
),
1616
),
17+
// body: DecoratedBox(
18+
// decoration: BoxDecoration(
19+
// gradient: RadialGradient(
20+
// center: const Alignment(-0.5, -0.6),
21+
// radius: 0.15,
22+
// colors: <Color>[
23+
// const Color(0xFFEEEEEE),
24+
// const Color(0xFF111133),
25+
// ],
26+
// stops: <double>[0.9, 1.0],
27+
// ),
28+
// ),
29+
// ),
1730
);
1831
}
1932
}

0 commit comments

Comments
 (0)