Skip to content

Commit

Permalink
Solved the Filter Section of Notes
Browse files Browse the repository at this point in the history
  • Loading branch information
SayedZeeshanHyder committed Jul 6, 2024
1 parent 08041c2 commit f5b9f25
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 225 deletions.
1 change: 1 addition & 0 deletions lib/new_ui/screens/notes_screen/notes_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class _NotesScreenState extends ConsumerState<NotesScreen> {

void changeFilters(DateTime? startDate, DateTime? endDate, bool latest,
List<String> subjects) {
print("Filtered Subjects = ${subjects}");
setState(() {
filterStartDate = startDate;
filterEndDate = endDate;
Expand Down
267 changes: 135 additions & 132 deletions lib/new_ui/screens/notes_screen/widgets/note_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,142 +118,145 @@ class _NoteListState extends ConsumerState<NoteList> {
}
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<String> selectedFiles,
List<String> deletedFiles,
List<String> 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<String> selectedFiles,
List<String> deletedFiles,
List<String> 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();
}
},
),
)
Expand Down
94 changes: 1 addition & 93 deletions lib/new_ui/screens/notes_screen/widgets/notes_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,99 +203,6 @@ class _NotesFilterBarState extends ConsumerState<NotesFilterBar>
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: [
Expand Down Expand Up @@ -368,6 +275,7 @@ class _NotesFilterBarState extends ConsumerState<NotesFilterBar>
.toList();
} else {
tempSubjects.add(allSubjects[index]);
widget.subjects = tempSubjects;
}
debugPrint(
"after change: all subjects ${allSubjects.length}");
Expand Down

0 comments on commit f5b9f25

Please sign in to comment.