Advertisement
Sanlover

Untitled

Feb 12th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.92 KB | None | 0 0
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/painting.dart';
  4.  
  5. void main() => runApp(MaterialApp(
  6. debugShowCheckedModeBanner: false,
  7. home: MainScreen(),
  8. ));
  9.  
  10. class MainScreen extends StatefulWidget {
  11. @override
  12. _MainScreenState createState() => _MainScreenState();
  13. }
  14.  
  15. class _MainScreenState extends State<MainScreen>
  16. with SingleTickerProviderStateMixin {
  17. bool isLeftCollapsed = true;
  18. bool isRightCollapsed = true;
  19. bool isTopCollapsed = true;
  20. bool isBottomCollapsed = true;
  21. double screenWidth, screenHeight;
  22. final Duration duration = const Duration(milliseconds: 300);
  23. AnimationController _controller;
  24.  
  25. @override
  26. void initState() {
  27. super.initState();
  28. _controller = AnimationController(vsync: this, duration: duration);
  29. }
  30.  
  31. @override
  32. void dispose() {
  33. _controller.dispose();
  34. super.dispose();
  35. }
  36.  
  37. @override
  38. Widget build(BuildContext context) {
  39. Size size = MediaQuery.of(context).size;
  40. screenHeight = size.height;
  41. screenWidth = size.width;
  42.  
  43. return Scaffold(
  44. body: Stack(
  45. children: <Widget>[
  46. upperBar(),
  47. sideBar(),
  48. bottomBar(),
  49. AnimatedPositioned(
  50. left: isLeftCollapsed ? 0 : 0.5 * screenWidth,
  51. right: isRightCollapsed ? 0 : -0.2 * screenWidth,
  52. top: isTopCollapsed ? 0 : 0.1 * screenHeight,
  53. bottom: isBottomCollapsed ? 0 : 0.1 * screenHeight,
  54. duration: duration,
  55. child: dashboard(context)),
  56. ],
  57. ),
  58. );
  59. }
  60.  
  61. Widget bottomBar() {
  62. return Positioned(
  63. bottom: 10,
  64. left: 30,
  65. child: Row(
  66. children: [
  67. Text(
  68. "Reset Password",
  69. style: TextStyle(color: Colors.grey, fontSize: 25),
  70. ),
  71. SizedBox(
  72. width: 60,
  73. ),
  74. Container(
  75. width: 100,
  76. height: 40,
  77. child: Center(
  78. child: Text(
  79. "Log Out",
  80. style:
  81. TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
  82. )),
  83. decoration: BoxDecoration(
  84. borderRadius: BorderRadius.circular(10), color: Colors.blue),
  85. )
  86. ],
  87. ));
  88. }
  89.  
  90. Widget sideBar() {
  91. return Positioned(
  92. left: 30,
  93. top: 250,
  94. child: Column(
  95. crossAxisAlignment: CrossAxisAlignment.start,
  96. children: [
  97. Text(
  98. "Home",
  99. style: TextStyle(
  100. fontWeight: FontWeight.bold,
  101. color: Colors.blue,
  102. fontSize: 25),
  103. ),
  104. SizedBox(
  105. height: 10,
  106. ),
  107. Text(
  108. "My Account",
  109. style: TextStyle(
  110. fontWeight: FontWeight.bold,
  111. color: Colors.blue,
  112. fontSize: 25),
  113. ),
  114. SizedBox(
  115. height: 10,
  116. ),
  117. Text(
  118. "My Orders",
  119. style: TextStyle(
  120. fontWeight: FontWeight.bold,
  121. color: Colors.blue,
  122. fontSize: 25),
  123. ),
  124. SizedBox(
  125. height: 10,
  126. ),
  127. Text(
  128. "Settings",
  129. style: TextStyle(
  130. fontWeight: FontWeight.bold,
  131. color: Colors.blue,
  132. fontSize: 25),
  133. ),
  134. ],
  135. ));
  136. }
  137.  
  138. Widget upperBar() {
  139. return Positioned(
  140. top: 40,
  141. left: 30,
  142. child: Row(
  143. children: [
  144. CircleAvatar(
  145. child: Icon(Icons.person_outline),
  146. ),
  147. SizedBox(
  148. width: 10,
  149. ),
  150. Text(
  151. "User name",
  152. style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
  153. ),
  154. SizedBox(
  155. width: 80,
  156. ),
  157. Container(
  158. width: 100,
  159. height: 40,
  160. child: Center(
  161. child: Text(
  162. "View Profile",
  163. style:
  164. TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
  165. )),
  166. decoration: BoxDecoration(
  167. borderRadius: BorderRadius.circular(10), color: Colors.blue),
  168. )
  169. ],
  170. ));
  171. }
  172.  
  173. Widget dashboard(context) {
  174. return SafeArea(
  175. child: Material(
  176. type: MaterialType.card,
  177. animationDuration: duration,
  178. elevation: 8,
  179. child: Scaffold(
  180. appBar: AppBar(
  181. elevation: 0,
  182. title: Text('MarketWatch'),
  183. actions: [
  184. IconButton(
  185. icon: isTopCollapsed
  186. ? Icon(
  187. Icons.keyboard_arrow_down_outlined,
  188. size: 40,
  189. color: Colors.white,
  190. )
  191. : Icon(
  192. Icons.keyboard_arrow_up_outlined,
  193. size: 40,
  194. color: Colors.white,
  195. ),
  196. onPressed: () {
  197. setState(() {
  198. isTopCollapsed
  199. ? _controller.forward()
  200. : _controller.reverse();
  201. isTopCollapsed = !isTopCollapsed;
  202. });
  203. },
  204. )
  205. ],
  206. leading: IconButton(
  207. icon: isLeftCollapsed ? Icon(Icons.menu) : Icon(Icons.clear),
  208. onPressed: () {
  209. setState(() {
  210. if (isLeftCollapsed) {
  211. _controller.forward();
  212. } else {
  213. _controller.reverse();
  214. }
  215. isTopCollapsed = !isTopCollapsed;
  216. isLeftCollapsed = !isLeftCollapsed;
  217. isBottomCollapsed = !isBottomCollapsed;
  218. });
  219. }),
  220. ),
  221. floatingActionButton: FloatingActionButton(
  222. onPressed: () {
  223. setState(() {
  224. isBottomCollapsed
  225. ? _controller.forward()
  226. : _controller.reverse();
  227. isBottomCollapsed = !isBottomCollapsed;
  228. });
  229. },
  230. child: isBottomCollapsed
  231. ? Icon(
  232. Icons.keyboard_arrow_up_outlined,
  233. size: 40,
  234. )
  235. : Icon(
  236. Icons.keyboard_arrow_down_outlined,
  237. size: 40,
  238. ),
  239. ),
  240. ),
  241. ),
  242. );
  243. }
  244. }
  245.  
  246.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement