diff --git a/lib/main.dart b/lib/main.dart index 2a195e8b..8825dbad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -37,6 +37,13 @@ Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { print("Handling a background message: ${message.messageId}"); } + +var debugprint = "////////////////////////////////////////////////////////////////////////////////////////////////////////TESTING/////////////////////////////////////////////////////////////////////////"; + + + + + Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); diff --git a/lib/new_ui/screens/login_screen/login_screen.dart b/lib/new_ui/screens/login_screen/login_screen.dart index 03907a2f..5f1f2a16 100644 --- a/lib/new_ui/screens/login_screen/login_screen.dart +++ b/lib/new_ui/screens/login_screen/login_screen.dart @@ -73,22 +73,28 @@ class _LoginScreenState extends ConsumerState { setState(() { loggedInButtonPressed = true; }); + print("print1"); UserCredential? userCredential = await ref .watch(authProvider.notifier) .signInUser(_emailTextEditingController.text.trim(), _passwordTextEditingController.text.trim(), context); - + print("print2"); if (userCredential == null) { setState(() { loggedInButtonPressed = false; }); return; } + print("print3"); await ref.watch(authProvider.notifier).getUserData(ref, context); + print("print4"); UserModel? userModel = ref.watch(userModelProvider); + print("print5"); + print("print6"); if (userModel != null) { + print("print6"); ref.watch(authProvider.notifier).setupFCMNotifications(ref, userModel.studentModel, FirebaseAuth.instance.currentUser!.uid); diff --git a/lib/new_ui/screens/notes_screen/widgets/note_list.dart b/lib/new_ui/screens/notes_screen/widgets/note_list.dart index c02bc6af..154e96c7 100644 --- a/lib/new_ui/screens/notes_screen/widgets/note_list.dart +++ b/lib/new_ui/screens/notes_screen/widgets/note_list.dart @@ -97,6 +97,8 @@ class _NoteListState extends ConsumerState { @override Widget build(BuildContext context) { List allNotes = ref.watch(notesProvider); + UserModel? user = ref.read(userModelProvider); + // allNotes = applyFilters(allNotes); // debugPrint("all notes are ${allNotes}"); // List allNotes = []; @@ -118,8 +120,13 @@ class _NoteListState extends ConsumerState { } return newString; }).toList(); + print(i); + print(attachments.toString()); + print(widget.subjects.toString()); + print(allNotes[i].professorName); + print(user?.facultyModel?.name); - if(widget.subjects.contains(allNotes[i].subject)) + if(widget.subjects.contains(allNotes[i].subject) || user?.facultyModel?.name==allNotes[i].professorName) return Column( children: [ SizedBox(height: 10), diff --git a/lib/new_ui/screens/notes_screen/widgets/notes_filter.dart b/lib/new_ui/screens/notes_screen/widgets/notes_filter.dart index a9a27811..05e99c11 100644 --- a/lib/new_ui/screens/notes_screen/widgets/notes_filter.dart +++ b/lib/new_ui/screens/notes_screen/widgets/notes_filter.dart @@ -9,6 +9,25 @@ import 'package:tsec_app/provider/subjects_provider.dart'; import 'package:tsec_app/utils/custom_snackbar.dart'; import 'package:tsec_app/utils/profile_details.dart'; + + + + + + + +/////////////////////////// THIS IS DROPDOWN FOR NOTES PAGE WHERE U SEE AND SELECT ALL SEBJECTS //////////////////////// + + + + + + + + + + + class NotesFilterBar extends ConsumerStatefulWidget { DateTime? startDate; String searchQuery; @@ -132,9 +151,14 @@ class _NotesFilterBarState extends ConsumerState SemesterData semData = subjects.dataMap[ "${calcGradYear(user.studentModel?.gradyear)}_${user.studentModel?.branch}"] ?? SemesterData(even_sem: [], odd_sem: []); + debugPrint(semData.even_sem.toString()); + debugPrint(semData.odd_sem.toString()); + + List allSubjects = evenOrOddSem() == "even_sem" ? semData.even_sem : semData.odd_sem; + print("selected senm subjects ${allSubjects.toString()}"); // debugPrint(allSubjects.toString()); // debugPrint( // "${user!.studentModel?.gradyear} ${user.studentModel?.branch} ${evenOrOddSem()}"); @@ -238,6 +262,11 @@ class _NotesFilterBarState extends ConsumerState thickness: 1, color: timePickerBorder, ), + + + + + //THIS IS FOR DROPDOWN user.isStudent && allSubjects.isNotEmpty ? Column( mainAxisSize: MainAxisSize.max, diff --git a/lib/new_ui/screens/splash_screen/splash_screen.dart b/lib/new_ui/screens/splash_screen/splash_screen.dart index 5a0cbfbf..ca0d41c8 100644 --- a/lib/new_ui/screens/splash_screen/splash_screen.dart +++ b/lib/new_ui/screens/splash_screen/splash_screen.dart @@ -69,6 +69,7 @@ class _SplashScreenState extends ConsumerState { return Scaffold( body: Center( child: SizedBox( + //SECOND SCREEN LOGO child: Image.asset(ImageAssets.tsecapplogo), height: 250, width: 250, diff --git a/lib/provider/auth_provider.dart b/lib/provider/auth_provider.dart index 551d72fc..af191e4f 100644 --- a/lib/provider/auth_provider.dart +++ b/lib/provider/auth_provider.dart @@ -113,7 +113,9 @@ class AuthProvider extends StateNotifier { Future getUserData(WidgetRef ref, BuildContext context) async { //this is being called on both splash and login screen final user = _ref.watch(firebaseAuthProvider).currentUser; + print("in getUserData"); if (user?.uid != null) { + print("uid not null : ${user?.uid}"); UserModel? userModel = await ref .watch(authProvider.notifier) .fetchUserDetails(user, context); diff --git a/lib/screens/notification_screen/notification_screen.dart b/lib/screens/notification_screen/notification_screen.dart index 498fb4cf..087377b8 100644 --- a/lib/screens/notification_screen/notification_screen.dart +++ b/lib/screens/notification_screen/notification_screen.dart @@ -102,13 +102,14 @@ class _NotificationScreenState extends ConsumerState { _lastDate = notificationTime; return Center( child: Chip( - backgroundColor: Colors.white, + backgroundColor: Colors.transparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0), ), labelStyle: const TextStyle(fontSize: 12), label: Text( DateFormat("dd MMMM,yyyy").format(notificationTime), + style: TextStyle(color: Colors.white), ), ), ); diff --git a/lib/services/notes_service.dart b/lib/services/notes_service.dart index b692e836..aa275516 100644 --- a/lib/services/notes_service.dart +++ b/lib/services/notes_service.dart @@ -29,7 +29,7 @@ class NotesService { final FirebaseStorage firebaseStorage; NotesService(this.firebaseAuth, this.firebaseFirestore, this.firebaseStorage); CollectionReference> notesCollection = - FirebaseFirestore.instance.collection('Notes'); + FirebaseFirestore.instance.collection('Notes'); Stream get userCurrentState => firebaseAuth.authStateChanges(); @@ -65,20 +65,27 @@ class NotesService { } Future> fetchNotes(UserModel? user) async { - late QuerySnapshot> querySnapshot; + print(debugPrint); + print(user); if (user == null) return []; + late QuerySnapshot> querySnapshot; + + try{ if (user.isStudent) { // debugPrint( // "${user.studentModel?.branch}, ${user.studentModel?.div}, ${calcGradYear(user.studentModel!.gradyear)}"); + + final gradyear = calcGradYear(user.studentModel?.gradyear); + print(gradyear); querySnapshot = await notesCollection .where( - 'target_classes', - arrayContains: { - "branch": user.studentModel?.branch, - "division": user.studentModel?.div, - "year": calcGradYear(user.studentModel!.gradyear), - }, - ) + 'target_classes', + arrayContains: { + "branch": user.studentModel?.branch, + "division": user.studentModel?.div, + "year": gradyear, + }, + ) .orderBy("time", descending: true) .get(); } else { @@ -86,10 +93,17 @@ class NotesService { .where("professor_name", isEqualTo: user.facultyModel?.name) .get(); } + + }catch(e){ + print(calcGradYear(user.studentModel?.gradyear)); + print(user.studentModel?.name); + print(user.facultyModel?.name); + print("Error in notes_service.dart in fetchnotes ${e}"); + } List reqNotes = []; for (QueryDocumentSnapshot> document - in querySnapshot.docs) { + in querySnapshot.docs) { var noteData = document.data(); NotesModel note = NotesModel.fromJson(noteData); note.id = document.id; @@ -128,7 +142,7 @@ class NotesService { await notesDoc.update(note.toJson()); } else { DocumentReference> noteUploaded = - await notesCollection.add(note.toJson()); + await notesCollection.add(note.toJson()); note.id = noteUploaded.id; } } catch (e) { @@ -146,4 +160,4 @@ class NotesService { debugPrint('Error updating or creating document: $e'); } } -} +} \ No newline at end of file