File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,33 +139,32 @@ class StatusViewState extends State<StatusView> {
139139 );
140140 }
141141
142+ String _getNextStatus (String currentStatus) {
143+ switch (currentStatus.toLowerCase ()) {
144+ case 'present' :
145+ return 'bunked' ;
146+ case 'bunked' :
147+ return 'cancelled' ;
148+ case 'cancelled' :
149+ return 'present' ;
150+ default :
151+ return 'present' ;
152+ }
153+ }
154+
142155 Widget _buildCourseItem (Map <String , dynamic > course) {
143156 String name = course["name" ].toString ();
144157 String status = course["status" ];
145158 Color statusColor = _getStatusColor (status);
146159
147160 return GestureDetector (
148- onTap: () => {
161+ onTap: () {
162+ String nextStatus = _getNextStatus (status);
149163 setState (() {
150- statusColor = _getStatusColor ("bunked" );
151- status = "bunked" ;
152- }),
153- _updateCourseStatus (course, "bunked" )
154- },
155- onDoubleTap: () => {
156- setState (() {
157- statusColor = _getStatusColor ("cancelled" );
158- status = "cancelled" ;
159- }),
160- _updateCourseStatus (course, "cancelled" )
161- },
162- onLongPress: () => {
163- setState (() {
164- statusColor = _getStatusColor ("present" );
165- status = "present" ;
166- }),
167-
168- _updateCourseStatus (course, "present" )
164+ status = nextStatus;
165+ statusColor = _getStatusColor (nextStatus);
166+ });
167+ _updateCourseStatus (course, nextStatus);
169168 },
170169 child: AnimatedContainer (
171170 duration: Duration (milliseconds: 0 ),
@@ -217,7 +216,7 @@ class StatusViewState extends State<StatusView> {
217216 }
218217
219218 Color _getStatusColor (String status) {
220- switch (status) {
219+ switch (status. toLowerCase () ) {
221220 case 'bunked' :
222221 return Colors .red;
223222 case 'cancelled' :
You can’t perform that action at this time.
0 commit comments