From d14e1787b56cabb568bf81fb312491a56fb1de73 Mon Sep 17 00:00:00 2001 From: Atharva Date: Mon, 15 Jul 2024 22:37:08 +0530 Subject: [PATCH 1/4] only print statements added between files --- lib/main.dart | 7 +++++ .../screens/login_screen/login_screen.dart | 8 ++++- .../notes_screen/widgets/notes_filter.dart | 29 +++++++++++++++++++ .../screens/splash_screen/splash_screen.dart | 1 + lib/services/notes_service.dart | 24 ++++++++------- 5 files changed, 57 insertions(+), 12 deletions(-) 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/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/services/notes_service.dart b/lib/services/notes_service.dart index b692e836..7df0a61e 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(); @@ -66,19 +66,21 @@ class NotesService { Future> fetchNotes(UserModel? user) async { late QuerySnapshot> querySnapshot; + print(debugPrint); + print(user); if (user == null) return []; if (user.isStudent) { // debugPrint( // "${user.studentModel?.branch}, ${user.studentModel?.div}, ${calcGradYear(user.studentModel!.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": calcGradYear(user.studentModel!.gradyear), + }, + ) .orderBy("time", descending: true) .get(); } else { @@ -89,7 +91,7 @@ class NotesService { 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 +130,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 +148,4 @@ class NotesService { debugPrint('Error updating or creating document: $e'); } } -} +} \ No newline at end of file From 387772c0738e40a97e70dc2a532f72955ef692c8 Mon Sep 17 00:00:00 2001 From: Atharva Date: Tue, 16 Jul 2024 00:58:45 +0530 Subject: [PATCH 2/4] notes_service.dart FIXED LOGIN ISSUE. changed notes to Notes. only issue is that professor login is not displaying uploaded notes --- lib/provider/auth_provider.dart | 2 ++ lib/services/notes_service.dart | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) 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/services/notes_service.dart b/lib/services/notes_service.dart index 7df0a61e..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,25 @@ 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), + "year": gradyear, }, ) .orderBy("time", descending: true) @@ -88,6 +93,13 @@ 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 From 6860eb663014385b9e9c9a3a362d806f482a0dad Mon Sep 17 00:00:00 2001 From: Atharva Date: Tue, 16 Jul 2024 01:19:21 +0530 Subject: [PATCH 3/4] FIXED NOTES FOR BOTH TEACHER AND STUDENT. NOTES ARE WORKING FINE --- lib/new_ui/screens/notes_screen/widgets/note_list.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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), From ed99214c072cae451e7988df5721146f39c07383 Mon Sep 17 00:00:00 2001 From: Atharva Date: Tue, 16 Jul 2024 01:31:16 +0530 Subject: [PATCH 4/4] notification date bg color fixed --- lib/screens/notification_screen/notification_screen.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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), ), ), );