-
-
Notifications
You must be signed in to change notification settings - Fork 173
/
menu_dashboard_layout.dart
172 lines (162 loc) · 6.01 KB
/
menu_dashboard_layout.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
import 'package:flutter/material.dart';
final Color backgroundColor = Color(0xFF4A4A58);
class MenuDashboardPage extends StatefulWidget {
@override
_MenuDashboardPageState createState() => _MenuDashboardPageState();
}
class _MenuDashboardPageState extends State<MenuDashboardPage> with SingleTickerProviderStateMixin {
bool isCollapsed = true;
double screenWidth, screenHeight;
final Duration duration = const Duration(milliseconds: 300);
AnimationController _controller;
Animation<double> _scaleAnimation;
Animation<double> _menuScaleAnimation;
Animation<Offset> _slideAnimation;
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: duration);
_scaleAnimation = Tween<double>(begin: 1, end: 0.8).animate(_controller);
_menuScaleAnimation = Tween<double>(begin: 0.5, end: 1).animate(_controller);
_slideAnimation = Tween<Offset>(begin: Offset(-1, 0), end: Offset(0, 0)).animate(_controller);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
screenHeight = size.height;
screenWidth = size.width;
return Scaffold(
backgroundColor: backgroundColor,
body: Stack(
children: <Widget>[
menu(context),
dashboard(context),
],
),
);
}
Widget menu(context) {
return SlideTransition(
position: _slideAnimation,
child: ScaleTransition(
scale: _menuScaleAnimation,
child: Padding(
padding: const EdgeInsets.only(left: 16.0),
child: Align(
alignment: Alignment.centerLeft,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("Dashboard", style: TextStyle(color: Colors.white, fontSize: 22)),
SizedBox(height: 10),
Text("Messages", style: TextStyle(color: Colors.white, fontSize: 22)),
SizedBox(height: 10),
Text("Utility Bills", style: TextStyle(color: Colors.white, fontSize: 22)),
SizedBox(height: 10),
Text("Funds Transfer", style: TextStyle(color: Colors.white, fontSize: 22)),
SizedBox(height: 10),
Text("Branches", style: TextStyle(color: Colors.white, fontSize: 22)),
],
),
),
),
),
);
}
Widget dashboard(context) {
return AnimatedPositioned(
duration: duration,
top: 0,
bottom: 0,
left: isCollapsed ? 0 : 0.6 * screenWidth,
right: isCollapsed ? 0 : -0.2 * screenWidth,
child: ScaleTransition(
scale: _scaleAnimation,
child: Material(
animationDuration: duration,
borderRadius: BorderRadius.all(Radius.circular(40)),
elevation: 8,
color: backgroundColor,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
physics: ClampingScrollPhysics(),
child: Container(
padding: const EdgeInsets.only(left: 16, right: 16, top: 48),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: [
InkWell(
child: Icon(Icons.menu, color: Colors.white),
onTap: () {
setState(() {
if (isCollapsed)
_controller.forward();
else
_controller.reverse();
isCollapsed = !isCollapsed;
});
},
),
Text("My Cards", style: TextStyle(fontSize: 24, color: Colors.white)),
Icon(Icons.settings, color: Colors.white),
],
),
SizedBox(height: 50),
Container(
height: 200,
child: PageView(
controller: PageController(viewportFraction: 0.8),
scrollDirection: Axis.horizontal,
pageSnapping: true,
children: <Widget>[
Container(
margin: const EdgeInsets.symmetric(horizontal: 8),
color: Colors.redAccent,
width: 100,
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 8),
color: Colors.blueAccent,
width: 100,
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 8),
color: Colors.greenAccent,
width: 100,
),
],
),
),
SizedBox(height: 20),
Text("Transactions", style: TextStyle(color: Colors.white, fontSize: 20),),
ListView.separated(
shrinkWrap: true,
itemBuilder: (context, index) {
return ListTile(
title: Text("Macbook"),
subtitle: Text("Apple"),
trailing: Text("-2900"),
);
}, separatorBuilder: (context, index) {
return Divider(height: 16);
}, itemCount: 10)
],
),
),
),
),
),
);
}
}