forked from FusionIIIT/Fusion-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aditig2
committed
Apr 20, 2023
1 parent
988b166
commit f89f579
Showing
16 changed files
with
830 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MessTable extends StatelessWidget { | ||
const MessTable({Key? key, required this.head, required this.body,this.child}) : super(key: key); | ||
final List<List<String>> head; | ||
final List<List<String>> body; | ||
final Widget? child; | ||
@override | ||
Widget build(BuildContext context) { | ||
return SingleChildScrollView( | ||
scrollDirection: Axis.horizontal, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [..._buildHeading(head),..._buildRows(body,child)] | ||
), | ||
); | ||
} | ||
} | ||
|
||
|
||
List<Widget> _buildCells(List<String> val) { | ||
return List.generate( | ||
val.length, | ||
(index) => Container( | ||
alignment: Alignment.center, | ||
width: 120.0, | ||
height: 60.0, | ||
color: Colors.white, | ||
margin: EdgeInsets.all(4.0), | ||
child: Text(val[index]), | ||
), | ||
); | ||
} | ||
|
||
List<Widget> _buildRows(List<List<String>> items,Widget? child) { | ||
|
||
return List.generate( | ||
items.length, | ||
(index) => Row( | ||
children: [..._buildCells(items[index]), | ||
child??Container(),], | ||
), | ||
); | ||
} | ||
|
||
List<Widget> _buildHeading(List<List<String>> items) { | ||
return List.generate( | ||
items.length, | ||
(index) => Row( | ||
children: _buildCells(items[index]), | ||
), | ||
); | ||
} | ||
|
||
class RespondButton extends StatelessWidget { | ||
const RespondButton({Key? key, required this.val, required this.color,required this.onclick}) : super(key: key); | ||
final String val; | ||
final Color color; | ||
final void Function() onclick; | ||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
onTap: onclick, | ||
child: Container( | ||
alignment: Alignment.center, | ||
width: 120.0, | ||
height: 25.0, | ||
color: color, | ||
margin: EdgeInsets.all(4.0), | ||
child: Text(val), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
class MessItem{ | ||
int id; | ||
String mealTime; | ||
String dish; | ||
String messOption; | ||
MessItem({required this.id, required this.mealTime,required this.dish,required this.messOption}); | ||
|
||
factory MessItem.fromJson(Map<String,dynamic> x){ | ||
return MessItem(id:x['id'],mealTime:x['meal_time'],dish:x['dish'],messOption:x['mess_option']); | ||
} | ||
} | ||
|
||
List<String> getdata(String x) | ||
{ | ||
int len = x.length; | ||
return [x.substring(0,len-1),x[len-1]]; | ||
} | ||
|
||
void insertatindex(List<String> x, String time,String dish) { | ||
if (time == 'B') { | ||
x[0] = dish; | ||
} else if (time == 'L') { | ||
x[1] = dish; | ||
} else { | ||
x[2] = dish; | ||
} | ||
} | ||
|
||
List<List<String>> processMessItems(List<MessItem> messitems){ | ||
List<String> M=['','','']; | ||
List<String> T = ['','','']; | ||
List<String> W = ['','','']; | ||
List<String> TH = ['','','']; | ||
List<String> F = ['','','']; | ||
List<String> S = ['','','']; | ||
List<String> SU = ['','','']; | ||
Map<String,int> mp={}; | ||
for(var m in messitems) | ||
{ | ||
var temp = getdata(m.mealTime); | ||
String day=temp[0]; | ||
String time = temp[1]; | ||
if(!mp.containsKey(day)) | ||
{ | ||
mp[day]=1; | ||
switch(day){ | ||
case 'M': insertatindex(M,time,m.dish); | ||
break; | ||
case 'T':insertatindex(T,time,m.dish); | ||
break; | ||
|
||
case 'W':insertatindex(W,time,m.dish); | ||
break; | ||
|
||
case 'TH':insertatindex(TH,time,m.dish); | ||
break; | ||
|
||
case 'F':insertatindex(F,time,m.dish); | ||
break; | ||
|
||
case 'S':insertatindex(S,time,m.dish); | ||
break; | ||
|
||
case 'SU':insertatindex(SU,time,m.dish); | ||
break; | ||
} | ||
} | ||
else if(mp[day]!<=3) | ||
{ | ||
mp[day]= mp[day]!+1; | ||
switch(day){ | ||
case 'M': insertatindex(M,time,m.dish); | ||
break; | ||
case 'T':insertatindex(T,time,m.dish); | ||
break; | ||
|
||
case 'W':insertatindex(W,time,m.dish); | ||
break; | ||
|
||
case 'TH':insertatindex(TH,time,m.dish); | ||
break; | ||
|
||
case 'F':insertatindex(F,time,m.dish); | ||
break; | ||
|
||
case 'S':insertatindex(S,time,m.dish); | ||
break; | ||
|
||
case 'SU':insertatindex(SU,time,m.dish); | ||
break; | ||
} | ||
} | ||
} | ||
return [M,T,W,TH,F,S,SU]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.