Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated MessMenu. #33

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 149 additions & 6 deletions lib/messMenu/screens/messmenu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<MessMenu> {
String dropdownValue = 'MOHANI';

void initState() {
super.initState();
dataContainer.mess.makeMessItems();
Expand Down Expand Up @@ -95,23 +108,80 @@ class _MessMenuState extends State<MessMenu> {
dataContainer.mess.sheet.writeData([
[
DateTime.now().toString(),
x,
DateTime.now().weekday,
food,
dataContainer.auth.user.email,
temp
]
], 'messFeedbackItems!A:D');
});
dataContainer.mess.storeFoodVotes();
},
),
// DropdownButton<String>(
// 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<dynamic> 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: <String>['L', 'U']
// .map<DropdownMenuItem<String>>((String value) {
// return DropdownMenuItem<String>(
// 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;
Expand All @@ -133,12 +203,14 @@ class _MessMenuState extends State<MessMenu> {
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');
Expand Down Expand Up @@ -191,6 +263,8 @@ class _MessMenuState extends State<MessMenu> {
}
}

String _value = "";
List<String> _list = ["Mohani", "Jaiswal"];
@override
Widget build(BuildContext context) {
return DefaultTabController(
Expand All @@ -201,16 +275,85 @@ class _MessMenuState extends State<MessMenu> {
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<String>(
// 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: <String>['MOHANI', 'JAISWAL']
// .map<DropdownMenuItem<String>>((String value) {
// return DropdownMenuItem<String>(
// 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,
Expand Down