minor refactor

This commit is contained in:
Neeraj Gupta 2022-12-08 11:05:53 +05:30
parent 85c6f87168
commit b392b90b8f
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 9 additions and 9 deletions

View file

@ -285,7 +285,7 @@ class _GalleryState extends State<Gallery> {
final List<List<File>> collatedFiles = [];
for (int index = 0; index < files.length; index++) {
if (index > 0 &&
!_areFromSameDay(
!areFromSameDay(
files[index - 1].creationTime,
files[index].creationTime,
)) {
@ -303,14 +303,6 @@ class _GalleryState extends State<Gallery> {
.sort((a, b) => b[0].creationTime.compareTo(a[0].creationTime));
return collatedFiles;
}
bool _areFromSameDay(int firstCreationTime, int secondCreationTime) {
final firstDate = DateTime.fromMicrosecondsSinceEpoch(firstCreationTime);
final secondDate = DateTime.fromMicrosecondsSinceEpoch(secondCreationTime);
return firstDate.year == secondDate.year &&
firstDate.month == secondDate.month &&
firstDate.day == secondDate.day;
}
}
class GalleryIndexUpdatedEvent {

View file

@ -60,6 +60,14 @@ int daysBetween(DateTime from, DateTime to) {
return (to.difference(from).inHours / 24).round();
}
bool areFromSameDay(int firstCreationTime, int secondCreationTime) {
final firstDate = DateTime.fromMicrosecondsSinceEpoch(firstCreationTime);
final secondDate = DateTime.fromMicrosecondsSinceEpoch(secondCreationTime);
return firstDate.year == secondDate.year &&
firstDate.month == secondDate.month &&
firstDate.day == secondDate.day;
}
//Thu, 30 Jun
String getDayAndMonth(DateTime dateTime) {
return _days[dateTime.weekday]! +