/
main.dart
178 lines (158 loc) · 5.28 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import 'package:example/tabs/chips.dart';
import 'package:example/tabs/inputs.dart';
import 'package:example/tabs/others.dart';
import 'package:example/tabs/sliders.dart';
import 'package:example/tabs/typography.dart';
import 'package:example/tabs/widgets.dart';
import 'package:flutter/material.dart';
////////// IMPORT EASY THEME //////////
import 'package:easy_theme/easy_theme.dart';
/// Creating a Easy Theme based on the blue color (`Colors.blue`)
final EasyTheme myCustomTheme = EasyTheme(primary: Colors.blue);
/// get the ThemeData object created by the EasyTheme
final ThemeData myTheme = myCustomTheme.getTheme();
/// get the EasyColors object created by the EasyTheme
final EasyColors myColors = myCustomTheme.getColors();
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Easy Theme Exemple',
/// use `myTheme` in your
theme: myTheme,
home: MyHomePage(),
);
}
}
class TabItem {
final String text;
final IconData icon;
TabItem(this.text, this.icon);
}
class MyHomePage extends StatefulWidget {
ThemeData get theme => myTheme;
const MyHomePage({Key key}) : super(key: key);
@override
MyHomePageState createState() => MyHomePageState();
}
class MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
// RepaintBoundary key
GlobalKey _globalKey = new GlobalKey();
final _tabsItem = [
TabItem('Controls', Icons.check_box),
TabItem('Buttons', Icons.touch_app),
TabItem('Inputs', Icons.keyboard),
TabItem('Slider', Icons.tune),
TabItem('Chips', Icons.dns),
TabItem('Others', Icons.people),
TabItem('Text', Icons.text_fields),
TabItem('Primary Text', Icons.text_fields),
TabItem('Accent Text', Icons.text_fields),
/*TabItem('Color scheme', Icons.color_lens),*/
];
TabController tabBarController;
bool showFAB = true;
get bottomItems => [
{'label': 'Map', 'icon': Icons.map},
{'label': 'Description', 'icon': Icons.description},
{'label': 'Transform', 'icon': Icons.transform},
]
.map<Widget>((item) => IconButton(
icon: Icon(item['icon']),
onPressed: () {},
)
/*BottomNavigationBarItem(
icon: Icon(item['icon']),
title: Text(item['label']),
)*/
)
.toList();
@override
void initState() {
super.initState();
tabBarController = TabController(length: _tabsItem.length, vsync: this);
tabBarController.addListener(() {
setState(() {
showFAB = tabBarController.index == 0;
});
});
}
@override
Widget build(BuildContext context) {
return RepaintBoundary(
key: _globalKey,
child: AnimatedTheme(
data: widget.theme,
child: DefaultTabController(
length: _tabsItem.length,
child: Scaffold(
appBar: AppBar(
title: Text("App Preview"),
bottom: _buildTabBar(),
actions: <Widget>[
IconButton(icon: Icon(Icons.add), onPressed: () {}),
IconButton(icon: Icon(Icons.add_a_photo), onPressed: () {}),
/*IconButton(
icon: Icon(Icons.create_new_folder),
onPressed: () => Scaffold.of(context).openDrawer()),*/
],
),
floatingActionButton: tabBarController.index == 0
? FloatingActionButton(
child: Icon(
Icons.check,
/*color: widget.theme?.accentTextTheme?.button?.color,*/
),
onPressed: () {})
: null,
floatingActionButtonLocation:
FloatingActionButtonLocation.endDocked,
drawer: Drawer(
child: ListView(
children: <Widget>[
Text('Drawer'),
],
),
),
body: TabBarView(controller: tabBarController, children: [
WidgetPreview(theme: widget.theme),
ButtonPreview(theme: widget.theme),
InputsPreview(theme: widget.theme),
SliderPreview(theme: widget.theme),
ChipsPreview(theme: widget.theme),
OthersPreview(theme: widget.theme),
TypographyPreview(
textTheme: widget.theme.textTheme,
brightness: widget.theme.brightness,
),
TypographyPreview(
textTheme: widget.theme.primaryTextTheme,
brightness: widget.theme.primaryColorBrightness,
),
TypographyPreview(
textTheme: widget.theme.accentTextTheme,
brightness: widget.theme.accentColorBrightness,
),
]),
bottomNavigationBar: BottomAppBar(
child: Row(children: bottomItems),
shape: CircularNotchedRectangle(),
),
),
),
),
);
}
_buildTabBar() {
return TabBar(
isScrollable: true,
controller: tabBarController,
tabs:
_tabsItem.map((t) => Tab(text: t.text, icon: Icon(t.icon))).toList(),
);
}
}