Skip to content

Commit 943a77c

Browse files
committed
fix: make status gestures cycle on single tap
1 parent fc558b4 commit 943a77c

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

lib/screens/Status/status_page.dart

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff 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':

0 commit comments

Comments
 (0)