minor refactor
This commit is contained in:
parent
85c6f87168
commit
b392b90b8f
|
@ -285,7 +285,7 @@ class _GalleryState extends State<Gallery> {
|
||||||
final List<List<File>> collatedFiles = [];
|
final List<List<File>> collatedFiles = [];
|
||||||
for (int index = 0; index < files.length; index++) {
|
for (int index = 0; index < files.length; index++) {
|
||||||
if (index > 0 &&
|
if (index > 0 &&
|
||||||
!_areFromSameDay(
|
!areFromSameDay(
|
||||||
files[index - 1].creationTime,
|
files[index - 1].creationTime,
|
||||||
files[index].creationTime,
|
files[index].creationTime,
|
||||||
)) {
|
)) {
|
||||||
|
@ -303,14 +303,6 @@ class _GalleryState extends State<Gallery> {
|
||||||
.sort((a, b) => b[0].creationTime.compareTo(a[0].creationTime));
|
.sort((a, b) => b[0].creationTime.compareTo(a[0].creationTime));
|
||||||
return collatedFiles;
|
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 {
|
class GalleryIndexUpdatedEvent {
|
||||||
|
|
|
@ -60,6 +60,14 @@ int daysBetween(DateTime from, DateTime to) {
|
||||||
return (to.difference(from).inHours / 24).round();
|
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
|
//Thu, 30 Jun
|
||||||
String getDayAndMonth(DateTime dateTime) {
|
String getDayAndMonth(DateTime dateTime) {
|
||||||
return _days[dateTime.weekday]! +
|
return _days[dateTime.weekday]! +
|
||||||
|
|
Loading…
Reference in a new issue