Advertisement
valentina_scardigno

welcome page

Jan 18th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.36 KB | None | 0 0
  1. class WelcomePageState extends StatefulWidget {
  2. @override
  3. WelcomePage createState() => WelcomePage();
  4. }
  5.  
  6. class WelcomePage extends State<WelcomePageState> {
  7. Widget scaffoldBody;
  8.  
  9. @override
  10. Widget build(BuildContext context) {
  11. return Consumer<UserProvider>(
  12. builder: (BuildContext context, UserProvider userp, _) => Scaffold(
  13. appBar: AppBar(
  14. backgroundColor: Color.fromARGB(255, 98, 235, 248),
  15. title: Text(
  16. 'My AirBNB',
  17. style: TextStyle(color: Colors.black),
  18. ),
  19. centerTitle: true,
  20. elevation: 0,
  21. ),
  22. body: scaffoldBody,
  23. drawer: Drawer(
  24. child: Container(
  25. constraints: BoxConstraints.expand(),
  26. decoration: BoxDecoration(
  27. gradient: LinearGradient(
  28. begin: Alignment(0.31089, 1.09827),
  29. end: Alignment(0.68911, -0.09827),
  30. stops: [
  31. 0,
  32. 1,
  33. ],
  34. colors: [
  35. Color.fromARGB(255, 140, 28, 140),
  36. Color.fromARGB(255, 98, 235, 248),
  37. ],
  38. ),
  39. ),
  40. child: Column(
  41. children: <Widget>[
  42. UserAccountsDrawerHeader(
  43. decoration: BoxDecoration(
  44. color: Color.fromARGB(255, 255, 255, 255),
  45. ),
  46. currentAccountPicture: userp.user_name != null
  47. ? Image.memory(base64Decode(userp.user_name.image))
  48. : Text(''),
  49. accountName: userp.user_name != null
  50. ? Text(
  51. '${userp.user_name.name} ${userp.user_name.surname}',
  52. style: TextStyle(color: Colors.black))
  53. : Text(''),
  54. accountEmail: userp.user_name != null
  55. ? Text('${userp.user_name.email}',
  56. style: TextStyle(color: Colors.black))
  57. : Text(''),
  58. ),
  59. FlatButton(
  60. onPressed: () {
  61. onTappedAddProp();
  62. Navigator.pop(context);
  63. },
  64. child: Row(
  65. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  66. children: <Widget>[
  67. Text(
  68. 'Add a proposal',
  69. style: TextStyle(
  70. color: Colors.black,
  71. ),
  72. ),
  73. Icon(
  74. Icons.add,
  75. color: Colors.black,
  76. )
  77. ],
  78. ),
  79. ),
  80. Divider(
  81. color: Colors.black,
  82. ),
  83. FlatButton(
  84. onPressed: () {
  85. onTappedEditProp();
  86. Navigator.pop(context);
  87. },
  88. child: Row(
  89. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  90. children: <Widget>[
  91. Text(
  92. 'Edit a proposal',
  93. style: TextStyle(
  94. color: Colors.black,
  95. ),
  96. ),
  97. Icon(
  98. Icons.edit,
  99. color: Colors.black,
  100. )
  101. ],
  102. ),
  103. ),
  104. Divider(
  105. color: Colors.black,
  106. ),
  107. FlatButton(
  108. onPressed: () {},
  109. child: Row(
  110. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  111. children: <Widget>[
  112. Text(
  113. 'Delete a proposal',
  114. style: TextStyle(
  115. color: Colors.black,
  116. ),
  117. ),
  118. Icon(
  119. Icons.delete,
  120. color: Colors.black,
  121. )
  122. ],
  123. ),
  124. ),
  125. Divider(
  126. color: Colors.black,
  127. ),
  128. FlatButton(
  129. onPressed: () {},
  130. child: Row(
  131. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  132. children: <Widget>[
  133. Text(
  134. 'See notifications',
  135. style: TextStyle(
  136. color: Colors.black,
  137. ),
  138. ),
  139. Icon(
  140. Icons.notifications,
  141. color: Colors.black,
  142. )
  143. ],
  144. ),
  145. ),
  146. Divider(
  147. color: Colors.black,
  148. ),
  149. FlatButton(
  150. onPressed: () {
  151. AddProposalPage().onTappedAddFeed();
  152. Navigator.pop(context);
  153. },
  154. child: Row(
  155. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  156. children: <Widget>[
  157. Text(
  158. 'Add a feedback',
  159. style: TextStyle(
  160. color: Colors.black,
  161. ),
  162. ),
  163. Icon(
  164. Icons.feedback,
  165. color: Colors.black,
  166. )
  167. ],
  168. ),
  169. ),
  170. Divider(
  171. color: Colors.black,
  172. ),
  173. Spacer(),
  174. FlatButton(
  175. onPressed: () {
  176. Navigator.pushReplacementNamed(context, '/login');
  177. },
  178. child: Row(
  179. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  180. children: <Widget>[
  181. Text(
  182. 'LOGOUT',
  183. style: TextStyle(
  184. color: Colors.black,
  185. ),
  186. ),
  187. Icon(
  188. Icons.exit_to_app,
  189. color: Colors.black,
  190. )
  191. ],
  192. ),
  193. ),
  194. ],
  195. ),
  196. ),
  197. ),
  198. ),
  199. );
  200. }
  201.  
  202. @override
  203. void initState() {
  204. // Initializing it with the first body we want visible.
  205. scaffoldBody = Consumer<UserProvider>(
  206. builder: (BuildContext context, UserProvider userp, _) => Container(
  207. constraints: BoxConstraints.expand(),
  208. decoration: BoxDecoration(
  209. gradient: LinearGradient(
  210. begin: Alignment(0.31089, 1.09827),
  211. end: Alignment(0.68911, -0.09827),
  212. stops: [
  213. 0,
  214. 1,
  215. ],
  216. colors: [
  217. Color.fromARGB(255, 140, 28, 140),
  218. Color.fromARGB(255, 98, 235, 248),
  219. ],
  220. ),
  221. ),
  222. child: Column(
  223. crossAxisAlignment: CrossAxisAlignment.stretch,
  224. children: <Widget>[
  225. Align(
  226. alignment: Alignment.topCenter,
  227. child: Container(
  228. margin: EdgeInsets.only(top: 50),
  229. child: userp.user_name != null
  230. ? Text(
  231. "Welcome in myAirBNB ${userp.user_name.name} ${userp.user_name.surname}",
  232. textAlign: TextAlign.center,
  233. style: TextStyle(
  234. color: Color.fromARGB(255, 255, 255, 255),
  235. fontFamily: "Lato",
  236. fontWeight: FontWeight.w400,
  237. fontSize: 35,
  238. letterSpacing: -1,
  239. ),
  240. )
  241. : CircularProgressIndicator(),
  242. ),
  243. ),
  244. ],
  245. ),
  246. ));
  247. }
  248.  
  249. void onTappedAddProp() {
  250. // Calling setState changing the body
  251. setState(() {
  252. scaffoldBody = Consumer<UserProvider>(
  253. builder: (BuildContext context, UserProvider userp, _) => Container(
  254. constraints: BoxConstraints.expand(),
  255. decoration: BoxDecoration(
  256. gradient: LinearGradient(
  257. begin: Alignment(0.31089, 1.09827),
  258. end: Alignment(0.68911, -0.09827),
  259. stops: [
  260. 0,
  261. 1,
  262. ],
  263. colors: [
  264. Color.fromARGB(255, 140, 28, 140),
  265. Color.fromARGB(255, 98, 235, 248),
  266. ],
  267. ),
  268. ),
  269. child: Column(
  270. crossAxisAlignment: CrossAxisAlignment.stretch,
  271. children: <Widget>[
  272. Align(
  273. alignment: Alignment.topCenter,
  274. child: Container(
  275. margin: EdgeInsets.only(top: 50),
  276. child: userp.user_name != null
  277. ? Text(
  278. "add proposal",
  279. textAlign: TextAlign.center,
  280. style: TextStyle(
  281. color: Color.fromARGB(255, 255, 255, 255),
  282. fontFamily: "Lato",
  283. fontWeight: FontWeight.w400,
  284. fontSize: 35,
  285. letterSpacing: -1,
  286. ),
  287. )
  288. : CircularProgressIndicator(),
  289. ),
  290. ),
  291. ],
  292. ),
  293. ));
  294. });
  295. }
  296.  
  297. void onTappedEditProp() {
  298. // Calling setState changing the body
  299. setState(() {
  300. scaffoldBody = Consumer<UserProvider>(
  301. builder: (BuildContext context, UserProvider userp, _) => Container(
  302. constraints: BoxConstraints.expand(),
  303. decoration: BoxDecoration(
  304. gradient: LinearGradient(
  305. begin: Alignment(0.31089, 1.09827),
  306. end: Alignment(0.68911, -0.09827),
  307. stops: [
  308. 0,
  309. 1,
  310. ],
  311. colors: [
  312. Color.fromARGB(255, 140, 28, 140),
  313. Color.fromARGB(255, 98, 235, 248),
  314. ],
  315. ),
  316. ),
  317. child: Column(
  318. crossAxisAlignment: CrossAxisAlignment.stretch,
  319. children: <Widget>[
  320. Align(
  321. alignment: Alignment.topCenter,
  322. child: Container(
  323. margin: EdgeInsets.only(top: 50),
  324. child: userp.user_name != null
  325. ? Text(
  326. "edit proposal",
  327. textAlign: TextAlign.center,
  328. style: TextStyle(
  329. color: Color.fromARGB(255, 255, 255, 255),
  330. fontFamily: "Lato",
  331. fontWeight: FontWeight.w400,
  332. fontSize: 35,
  333. letterSpacing: -1,
  334. ),
  335. )
  336. : CircularProgressIndicator(),
  337. ),
  338. ),
  339. ],
  340. ),
  341. ));
  342. });
  343. }
  344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement