Skip to content

Commit

Permalink
Merge pull request #242 from SayedZeeshanHyder/main
Browse files Browse the repository at this point in the history
Fixed Railway Null , Attendance Empty and Announcement Filter
  • Loading branch information
SayedZeeshanHyder authored Jul 28, 2024
2 parents a92e3e8 + 0d49ee1 commit 6aad74d
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 161 deletions.
39 changes: 36 additions & 3 deletions lib/new_ui/screens/AnnouncementScreen/announcementscreen.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:tsec_app/models/student_model/student_model.dart';
import 'package:tsec_app/new_ui/colors.dart';
import 'package:url_launcher/url_launcher.dart';
// import '../models/announcement_model/announcement_model.dart';
import '../../../models/user_model/user_model.dart';
import 'announcementmodel.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:tsec_app/provider/auth_provider.dart';

class AnnouncementScreen extends StatelessWidget {
class AnnouncementScreen extends ConsumerStatefulWidget {
@override
ConsumerState<AnnouncementScreen> createState() => _AnnouncementScreenState();
}

class _AnnouncementScreenState extends ConsumerState<AnnouncementScreen> {
final DateTime _lastDate = DateTime.now();

late StudentModel studentModel;

@override
void initState() {
super.initState();
final UserModel? data = ref.read(userModelProvider);
setState(() {
studentModel = data!.studentModel!;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -56,14 +76,27 @@ class AnnouncementScreen extends StatelessWidget {
announcementModel: announcement,
);

if (_lastDate.isSameDate(_parseTimestamp(announcement.startDate))) {

//Condition if the Date has ended or deadline has crossed
if(!announcement.endDate!.toDate().isAfter(DateTime.now(),)){
return SizedBox();
}

//Condition if it is for all
if(announcement.batch!.contains("All")) {
return listTile;
}

//Condition if the student cannot see the Announcement
if(studentModel.branch != announcement.branch || studentModel.batch != announcement.batch || studentModel.div != announcement.div || studentModel.gradyear != announcement.gradYear) {
return SizedBox();
}

//The Announcement Belongs to Student
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
//_buildDateHeader(_parseTimestamp(announcement.startDate)),
_buildDateHeader(_parseTimestamp(announcement.startDate)),
listTile,
],
);
Expand Down
Loading

0 comments on commit 6aad74d

Please sign in to comment.