Skip to content

Commit

Permalink
Merge pull request #205 from 12fahed/main
Browse files Browse the repository at this point in the history
notes professor upload fixed
  • Loading branch information
12fahed authored Jul 15, 2024
2 parents 182c327 + 88495d0 commit 3815b54
Showing 1 changed file with 171 additions and 176 deletions.
347 changes: 171 additions & 176 deletions lib/new_ui/screens/notes_screen/widgets/note_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class _NoteListState extends ConsumerState<NoteList> {
// debugPrint("after date sorting ${notes.toString()}");
List<NotesModel> filteredNotes = notes
.where((note) =>
(widget.startDate == null ||
note.time.isAfter(widget.startDate!)) &&
(widget.endDate == null || note.time.isBefore(widget.endDate!)) &&
(note.title.contains(widget.searchQuery) ||
note.description.contains(widget.searchQuery)))
(widget.startDate == null ||
note.time.isAfter(widget.startDate!)) &&
(widget.endDate == null || note.time.isBefore(widget.endDate!)) &&
(note.title.contains(widget.searchQuery) ||
note.description.contains(widget.searchQuery)))
.toList();
// debugPrint("after date filtering ${filteredNotes.toString()}");
// for (String subject in widget.subjects) {
Expand All @@ -103,187 +103,182 @@ class _NoteListState extends ConsumerState<NoteList> {

return allNotes.length != 0
? SliverList(
delegate: SliverChildBuilderDelegate(
childCount: allNotes.length,
(context, i) {
List<String> attachments = allNotes[i].attachments.map((e) {
String newString = Uri.parse(e)
.pathSegments
.last
.replaceFirst("notes_attachments/", "");
int firstSlashIndex = newString.indexOf('/');
delegate: SliverChildBuilderDelegate(
childCount: allNotes.length,
(context, i) {
List<String> attachments = allNotes[i].attachments.map((e) {
String newString = Uri.parse(e)
.pathSegments
.last
.replaceFirst("notes_attachments/", "");
int firstSlashIndex = newString.indexOf('/');

if (firstSlashIndex != -1) {
newString = newString.substring(firstSlashIndex + 1);
}
return newString;
}).toList();
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,
if (firstSlashIndex != -1) {
newString = newString.substring(firstSlashIndex + 1);
}
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),
),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
formatDate(allNotes[i].time),
style: TextStyle(
color: Colors.grey,
),
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(),
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),
border: Border.all(color: timePickerBorder, width: 1.0), // Change the color and width as needed
color: timePickerBg,
),
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()
],
),
],
),
),
);
},
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();
}
},
),
)
: SliverFillRemaining(
child: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/images/app_bar/notes.png',
height: 100,
),
SizedBox(height: 20),
Text(
"No notes added yet",
style: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(color: Colors.white),
);
},
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();
}
},
);
},
),
),
],
),
);
},
),
)
: SliverFillRemaining(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Add your image here
Image.asset(
'assets/images/app_bar/notes.png',
height: 100,
),
SizedBox(height: 20),
Text(
"No notes added yet",
style: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(color: Colors.white),
),
],
),
),
);

}
}
}

0 comments on commit 3815b54

Please sign in to comment.