-
Notifications
You must be signed in to change notification settings - Fork 1
/
MyTestApp.dart
206 lines (193 loc) · 5.39 KB
/
MyTestApp.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import 'package:flutter/material.dart';
void main() => runApp(const TestApp());
class TestApp extends StatefulWidget {
const TestApp({Key? key}) : super(key: key);
@override
State<TestApp> createState() => _TestAppState();
}
class _TestAppState extends State<TestApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
// MaterialApp props
title: "MyTestApp",
theme: ThemeData(primarySwatch: Colors.blue),
darkTheme: ThemeData(primarySwatch: Colors.cyan),
color: Colors.amberAccent,
supportedLocales: {const Locale("en", "")},
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.lightBlueAccent,
//appbar
appBar: AppBar(
backgroundColor: Colors.cyan,
title: const Text("My Test App"),
titleSpacing: 00.0,
centerTitle: true,
toolbarHeight: 60,
actions: <Widget>[
IconButton(
icon: const Icon(Icons.add),
tooltip: "Add",
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.settings),
tooltip: "Settings",
onPressed: () {},
),
],
),
// body
body: Center(
child: AppBody(),
),
//float action button
floatingActionButton: FloatingActionButton(
elevation: 10.0,
child: const Icon(Icons.add),
onPressed: () => {},
),
// drawer
drawer: AppDrawer(),
//BOTTOM NAVIGATION BAR
bottomNavigationBar: AppBottomNavBar(),
),
);
}
}
// body
class AppBody extends StatefulWidget {
@override
State<AppBody> createState() => _AppBodyState();
}
class _AppBodyState extends State<AppBody> {
@override
Widget build(BuildContext context) {
return Container(
width: 190,
height: 160,
margin: const EdgeInsets.all(20),
padding: const EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.amber,
border: Border.all(color: Colors.blueAccent, width: 3),
borderRadius: BorderRadius.circular(10),
boxShadow: const [
BoxShadow(
color: Colors.cyanAccent,
offset: Offset(5.0, 5.0),
blurRadius: 5.0,
spreadRadius: 5.0,
),
]),
child: RichText(
overflow: TextOverflow.clip,
textAlign: TextAlign.center,
softWrap: true,
maxLines: 1,
textScaleFactor: 1,
text: TextSpan(
text: "Rich Text Element",
style: DefaultTextStyle.of(context).style,
),
),
);
}
}
class AppDrawer extends StatefulWidget {
@override
State<AppDrawer> createState() => _AppDrawerState();
}
class _AppDrawerState extends State<AppDrawer> {
@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero, //padding drawer
children: <Widget>[
const DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue,
),
child: UserAccountsDrawerHeader(
accountName: Text("Ivan Doe",
style: TextStyle(
fontSize: 16,
)),
accountEmail: Text("info@ivandoe.com"),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.amberAccent,
child: Text("I",
style: TextStyle(fontSize: 30, color: Colors.indigo)),
),
currentAccountPictureSize: Size.square(50),
),
),
ListTile(
leading: const Icon(Icons.person),
title: const Text(' My Profile '),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
title: const Text("Friends"),
leading: const Icon(Icons.people),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
title: const Text("Contact"),
leading: const Icon(Icons.mail),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
title: const Text("Settings"),
leading: const Icon(Icons.settings),
onTap: () {
Navigator.pop(context);
},
),
],
),
);
}
}
class AppBottomNavBar extends StatefulWidget {
@override
State<AppBottomNavBar> createState() => _AppBottomNavBarState();
}
class _AppBottomNavBarState extends State<AppBottomNavBar> {
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
currentIndex: 0,
fixedColor: Colors.green,
backgroundColor: Colors.black,
unselectedItemColor: Colors.white,
selectedLabelStyle: const TextStyle(
fontSize: 18,
),
items: const [
BottomNavigationBarItem(
label: "Home",
icon: Icon(Icons.home),
),
BottomNavigationBarItem(
label: "Search",
icon: Icon(Icons.search),
),
BottomNavigationBarItem(
label: "Profile",
icon: Icon(Icons.account_circle),
),
],
onTap: (int indexOfItem) {},
);
}
}