From 107c0156af44e259573607d71671c4d447ef44d9 Mon Sep 17 00:00:00 2001 From: Yash-Garg Date: Wed, 7 Sep 2022 21:04:45 +0530 Subject: [PATCH] fix: only navigate to day wise attendance if lectures are greater than 0 --- lib/cubits/attendance/attendance_cubit.dart | 6 +---- lib/ui/home/widgets/subjects_list_view.dart | 26 +++++++++++++-------- pubspec.yaml | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/cubits/attendance/attendance_cubit.dart b/lib/cubits/attendance/attendance_cubit.dart index 58d74b0..974ab54 100644 --- a/lib/cubits/attendance/attendance_cubit.dart +++ b/lib/cubits/attendance/attendance_cubit.dart @@ -27,11 +27,7 @@ class AttendanceCubit extends Cubit { _extraLectures = extraLectures; _mainLectures = mainLectures; _subId = subjectId; - if (mainLectures.isNotEmpty) { - _calculate(); - } else { - emit(state.copyWith(loading: false)); - } + _calculate(); } changeDate(DateTime date) { diff --git a/lib/ui/home/widgets/subjects_list_view.dart b/lib/ui/home/widgets/subjects_list_view.dart index eed9a88..6e658bf 100644 --- a/lib/ui/home/widgets/subjects_list_view.dart +++ b/lib/ui/home/widgets/subjects_list_view.dart @@ -1,3 +1,4 @@ +import 'package:edtrack/ui/common/custom_snackbar.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -30,16 +31,21 @@ class SubjectsListView extends StatelessWidget { shape: AppTheme.cardShape, child: InkWell( borderRadius: BorderRadius.circular(AppTheme.cardRadius), - onTap: () => Navigator.push( - context, - CupertinoPageRoute( - builder: (_) => SubjectAttendance( - mainLectures: attendance.attendanceData, - extraLectures: attendance.extraLectures, - subject: subject, - ), - ), - ), + onTap: () => subject.totalLectures > 0 + ? Navigator.push( + context, + CupertinoPageRoute( + builder: (_) => SubjectAttendance( + mainLectures: attendance.attendanceData, + extraLectures: attendance.extraLectures, + subject: subject, + ), + ), + ) + : showCustomSnack( + context: context, + message: 'No lectures to show for this subject yet', + ), child: Padding( padding: const EdgeInsets.all(8.0), child: ListTile( diff --git a/pubspec.yaml b/pubspec.yaml index 0577505..3c3cd8b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Edumarshal client for AKGEC publish_to: "none" -version: 1.3.1+10 +version: 1.4.0+11 environment: sdk: ">=2.17.0 <3.0.0"