From 6c22a31d345aa448f8161dac1046cd41a0016efa Mon Sep 17 00:00:00 2001 From: Progyan Date: Thu, 18 Nov 2021 21:52:12 +0530 Subject: [PATCH] Update messmenu.dart --- lib/messMenu/screens/messmenu.dart | 155 +++++++++++++++++++++++++++-- 1 file changed, 149 insertions(+), 6 deletions(-) diff --git a/lib/messMenu/screens/messmenu.dart b/lib/messMenu/screens/messmenu.dart index 6317a93..9410c11 100644 --- a/lib/messMenu/screens/messmenu.dart +++ b/lib/messMenu/screens/messmenu.dart @@ -4,12 +4,25 @@ import 'package:instiapp/themeing/notifier.dart'; // import 'package:instiapp/themeing/notifier.dart'; import 'package:instiapp/utilities/constants.dart'; +// import 'package:hive/hive.dart'; +var x = ""; + +IconData getIcon(_value) { + if (_value == "Jaiswal") { + return (Icons.arrow_upward_rounded); + } else { + return (Icons.arrow_downward_rounded); + } +} + class MessMenu extends StatefulWidget { @override _MessMenuState createState() => _MessMenuState(); } class _MessMenuState extends State { + String dropdownValue = 'MOHANI'; + void initState() { super.initState(); dataContainer.mess.makeMessItems(); @@ -95,9 +108,9 @@ class _MessMenuState extends State { dataContainer.mess.sheet.writeData([ [ DateTime.now().toString(), + x, DateTime.now().weekday, food, - dataContainer.auth.user.email, temp ] ], 'messFeedbackItems!A:D'); @@ -105,13 +118,70 @@ class _MessMenuState extends State { dataContainer.mess.storeFoodVotes(); }, ), + // DropdownButton( + // value: dropdownValue, + // icon: const Icon( + // Icons.thumb_down_alt, + // ), + // iconSize: 20, + // elevation: 16, + // focusColor: Colors.green, + // style: const TextStyle(color: Colors.deepPurple), + // underline: Container( + // height: 2, + // color: Colors.deepPurpleAccent, + // ), + // onChanged: (String newValue) { + // setState(() { + // dropdownValue = newValue; + // String temp = ''; + // bool hasAlreadyVoted = false; + // dataContainer.mess.foodVotes + // .forEach((List ls) { + // if (ls[0] == food) { + // if (ls[1] == '-1' || ls[1] == '0') { + // ls[1] = '1'; + // temp = '1'; + // } else { + // ls[1] = '0'; + // temp = '0'; + // } + // hasAlreadyVoted = true; + // } + // }); + + // if (!hasAlreadyVoted) { + // dataContainer.mess.foodVotes.add([food, '1']); + // temp = '1'; + // } + // dataContainer.mess.sheet.writeData([ + // [ + // DateTime.now().toString(), + // DateTime.now().weekday, + // food, + // dropdownValue, + // temp + // ] + // ], 'messFeedbackItems!A:D'); + // }); + // dataContainer.mess.storeFoodVotes(); + // }, + // items: ['L', 'U'] + // .map>((String value) { + // return DropdownMenuItem( + // value: value, + // child: Text(value), + // ); + // }).toList(), + // ), + IconButton( icon: Icon( Icons.thumb_up_alt, ), iconSize: 20, color: returnColorUpVote(food), - onPressed: () async { + onPressed: () { setState(() { String temp = ''; bool hasAlreadyVoted = false; @@ -133,12 +203,14 @@ class _MessMenuState extends State { dataContainer.mess.foodVotes.add([food, '1']); temp = '1'; } + print("--------------------"); + print("DUN DUN DUN"); dataContainer.mess.sheet.writeData([ [ DateTime.now().toString(), + x, DateTime.now().weekday, food, - dataContainer.auth.user.email, temp ] ], 'messFeedbackItems!A:D'); @@ -191,6 +263,8 @@ class _MessMenuState extends State { } } + String _value = ""; + List _list = ["Mohani", "Jaiswal"]; @override Widget build(BuildContext context) { return DefaultTabController( @@ -201,16 +275,85 @@ class _MessMenuState extends State { appBar: AppBar( elevation: 0, backgroundColor: theme.appBarColor, + //Back Button leading: IconButton( icon: Icon(Icons.arrow_back, color: theme.iconColor), onPressed: () { Navigator.pop(context); }, ), + centerTitle: true, - title: Text('Mess Menu', - style: TextStyle( - fontWeight: FontWeight.bold, color: theme.textHeadingColor)), + title: Text( + "Mess Menu ", + style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold), + ), + // DropdownButton( + // value: dropdownValue, + // // icon: const Icon( + // // Icons.food_bank, + // // ), + // // iconSize: 30, + // // elevation: 100, + // focusColor: Colors.green, + // style: const TextStyle( + // color: Colors.deepPurple, + // fontSize: 30, + // fontWeight: FontWeight.bold, + // fontFamily: 'OpenSans'), + // // underline: Container( + // // height: 4, + // // color: Colors.deepPurpleAccent, + // // ), + // onChanged: (String newValue) { + // setState(() { + // x = newValue; + // print("----------------------------------------------------"); + // print(x); + // print( + // "--------------------------------------------------------"); + // dropdownValue = newValue; + // }); + // }, + // items: ['MOHANI', 'JAISWAL'] + // .map>((String value) { + // return DropdownMenuItem( + // value: value, + // child: Text(value), + // ); + // }).toList(), + // ), + + actions: [ + PopupMenuButton( + icon: Icon( + getIcon(_value), + size: 30, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(20.0), + ), + ), + elevation: 20, + enabled: true, + onSelected: (value) { + setState(() { + _value = value; + }); + }, + itemBuilder: (context) { + return _list.map((String choice) { + return PopupMenuItem( + value: choice, + child: Text("$choice"), + ); + }).toList(); + }), + Padding(padding: EdgeInsets.all(0.4)), + // Container(width: 50, child: Text("Mess", style: TextStyle(fontSize: 18.0))), + // Icon(Icons.menu_book_rounded), + ], bottom: PreferredSize( child: TabBar( isScrollable: true,