diff --git a/lib/new_ui/screens/notes_screen/notes_screen.dart b/lib/new_ui/screens/notes_screen/notes_screen.dart index 877f5f31..496540b7 100644 --- a/lib/new_ui/screens/notes_screen/notes_screen.dart +++ b/lib/new_ui/screens/notes_screen/notes_screen.dart @@ -100,6 +100,7 @@ class _NotesScreenState extends ConsumerState { void changeFilters(DateTime? startDate, DateTime? endDate, bool latest, List subjects) { + print("Filtered Subjects = ${subjects}"); setState(() { filterStartDate = startDate; filterEndDate = endDate; 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 e0e6e2d1..796fec4c 100644 --- a/lib/new_ui/screens/notes_screen/widgets/note_list.dart +++ b/lib/new_ui/screens/notes_screen/widgets/note_list.dart @@ -118,142 +118,145 @@ class _NoteListState extends ConsumerState { } return newString; }).toList(); - - return Column( - children: [ - SizedBox(height: 10), - i == 0 || allNotes[i].time != allNotes[i - 1].time - ? Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - formatDate(allNotes[i].time), - style: TextStyle( - color: Colors.grey, - ), - ) - ], - ) - : Container(), - SizedBox( - height: - i == 0 || allNotes[i].time != allNotes[i - 1].time - ? 15 - : 0), - Padding( - padding: EdgeInsets.all(8), - child: OpenContainer( - transitionDuration: Duration(milliseconds: 500), - closedColor: Color(0xff1B1B1B), - closedBuilder: (context, action) { - return Container( - // margin: EdgeInsets.all(8), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: Color(0xff383838), - ), - child: Padding( - padding: const EdgeInsets.all(20,), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${allNotes[i].subject}: ${allNotes[i].title}", - style: Theme.of(context) - .textTheme - .titleMedium! - .copyWith(color: Colors.white), - ), - const SizedBox( - height: 7, - ), - Text( - /* use can use the - _getFirst5Words method here if want to - _getFirst5Words(widget.noteContent) - method on line no. 40 - */ - allNotes[i].description, - // widget.noteContent, - style: Theme.of(context) - .textTheme - .titleSmall! - .copyWith(color: Colors.grey, fontSize: 14), + if(widget.subjects.contains(allNotes[i].subject)) + return Column( + children: [ + SizedBox(height: 10), + i == 0 || allNotes[i].time != allNotes[i - 1].time + ? Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + formatDate(allNotes[i].time), + style: TextStyle( + color: Colors.grey, ), - const SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - width: - MediaQuery.of(context).size.width * - .8, - height: 40, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: - min(2, attachments.length), - itemBuilder: (context, ind) { - return CustomPdfIcon( - pdfName: attachments[ind], - ); - }), - ), - attachments.length > 2 - ? Text( - "+${attachments.length - 2}", - style: TextStyle( - color: Theme.of(context).colorScheme.tertiary, - fontSize: 12, + ) + ], + ) + : Container(), + SizedBox( + height: + i == 0 || allNotes[i].time != allNotes[i - 1].time + ? 15 + : 0), + Padding( + padding: EdgeInsets.all(8), + child: OpenContainer( + transitionDuration: Duration(milliseconds: 500), + closedColor: Color(0xff1B1B1B), + closedBuilder: (context, action) { + return Container( + // margin: EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Color(0xff383838), + ), + child: Padding( + padding: const EdgeInsets.all(20,), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "${allNotes[i].subject}: ${allNotes[i].title}", + style: Theme.of(context) + .textTheme + .titleMedium! + .copyWith(color: Colors.white), + ), + const SizedBox( + height: 7, + ), + Text( + /* use can use the + _getFirst5Words method here if want to + _getFirst5Words(widget.noteContent) + method on line no. 40 + */ + allNotes[i].description, + // widget.noteContent, + style: Theme.of(context) + .textTheme + .titleSmall! + .copyWith(color: Colors.grey, fontSize: 14), + ), + const SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + width: + MediaQuery.of(context).size.width * + .8, + height: 40, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: + min(2, attachments.length), + itemBuilder: (context, ind) { + return CustomPdfIcon( + pdfName: attachments[ind], + ); + }), + ), + attachments.length > 2 + ? Text( + "+${attachments.length - 2}", + style: TextStyle( + color: Theme.of(context).colorScheme.tertiary, + fontSize: 12, + ) ) - ) - : Container() - ], - ), - ], + : Container() + ], + ), + ], + ), ), - ), - ); - }, - openBuilder: (context, action) { - return NotesModal( - action: action, - note: allNotes[i], - formKey: widget.formKey, - uploadNoteCallback: (List selectedFiles, - List deletedFiles, - List originalFiles, - String? id, - String? title, - String? description, - String? subject, - String? branch, - String? division, - String? year) { - if (widget.formKey.currentState!.validate()) { - widget.uploadNoteCallback( - selectedFiles, - deletedFiles, - originalFiles, - id, - title, - description, - subject, - branch, - division, - year); - action.call(); - } - }, - ); - }, + ); + }, + openBuilder: (context, action) { + return NotesModal( + action: action, + note: allNotes[i], + formKey: widget.formKey, + uploadNoteCallback: (List selectedFiles, + List deletedFiles, + List originalFiles, + String? id, + String? title, + String? description, + String? subject, + String? branch, + String? division, + String? year) { + if (widget.formKey.currentState!.validate()) { + widget.uploadNoteCallback( + selectedFiles, + deletedFiles, + originalFiles, + id, + title, + description, + subject, + branch, + division, + year); + action.call(); + } + }, + ); + }, + ), ), - ), - ], - ); + ], + ); + else { + return SizedBox(); + } }, ), ) 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 86ca1298..d577fac9 100644 --- a/lib/new_ui/screens/notes_screen/widgets/notes_filter.dart +++ b/lib/new_ui/screens/notes_screen/widgets/notes_filter.dart @@ -203,99 +203,6 @@ class _NotesFilterBarState extends ConsumerState padding: const EdgeInsets.all(8.0), child: Column( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width * 0.40, - child: TextButton( - onPressed: () async { - DateTime? pickedDate = await showDatePicker( - context: context, - initialDate: widget.startDate, - firstDate: DateTime(2000), - lastDate: DateTime(2025), - ); - if (pickedDate != null) { - // setState(() {~ - // startDate = pickedDate; - // }); - widget.changeFilters(pickedDate, widget.endDate, - widget.latest, widget.subjects); - } else { - // print( - // "Date is not selected"); - } - }, - child: Text( - widget.startDate != null - ? DateFormat('d MMM y') - .format(widget.startDate!) - : "Start date", - style: Theme.of(context) - .textTheme - .labelMedium! - .copyWith( - color: Colors.black, - ), - ), - ), - ), - const SizedBox( - width: 20, - child: Icon( - Icons.arrow_right_alt_rounded, - color: Colors.black, - ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * 0.40, - child: TextButton( - onPressed: () async { - DateTime? pickedDate = await showDatePicker( - context: context, - initialDate: widget.endDate, - firstDate: DateTime(2000), - lastDate: DateTime(2025), - ); - if (pickedDate != null) { - if (widget.startDate != null && - pickedDate.isBefore(widget.startDate!)) { - showSnackBar(context, - "Please select an appropriate date"); - return; - } - // setState(() { - // endDate = pickedDate; - // }); - - widget.changeFilters(widget.startDate, - pickedDate, widget.latest, widget.subjects); - } else { - // print( - // "Date is not selected"); - } - }, - child: Text( - widget.endDate != null - ? DateFormat('d MMM y') - .format(widget.endDate!) - : "End date", - style: Theme.of(context) - .textTheme - .labelMedium! - .copyWith( - color: Colors.black, - ), - ), - ), - ), - ], - ), - const Divider( - thickness: 1, - color: Colors.grey, - ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -368,6 +275,7 @@ class _NotesFilterBarState extends ConsumerState .toList(); } else { tempSubjects.add(allSubjects[index]); + widget.subjects = tempSubjects; } debugPrint( "after change: all subjects ${allSubjects.length}");