Pass sort property to gallery
This commit is contained in:
parent
537b880281
commit
e8594566b5
4 changed files with 19 additions and 3 deletions
|
@ -74,6 +74,7 @@ class CollectionPage extends StatelessWidget {
|
|||
selectedFiles: _selectedFiles,
|
||||
initialFiles: initialFiles,
|
||||
albumName: c.collection.name,
|
||||
sortOrderAsc: false,
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
|
|
|
@ -31,6 +31,7 @@ class GalleryListView extends StatelessWidget {
|
|||
final bool shouldCollateFilesByDay;
|
||||
final String logTag;
|
||||
final Logger logger;
|
||||
final bool sortOrderAsc;
|
||||
|
||||
const GalleryListView({
|
||||
required this.hugeListViewKey,
|
||||
|
@ -50,6 +51,7 @@ class GalleryListView extends StatelessWidget {
|
|||
required this.shouldCollateFilesByDay,
|
||||
required this.logTag,
|
||||
required this.logger,
|
||||
required this.sortOrderAsc,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
@ -91,6 +93,7 @@ class GalleryListView extends StatelessWidget {
|
|||
reloadEvent,
|
||||
removalEventTypes,
|
||||
asyncLoader,
|
||||
sortOrderAsc,
|
||||
selectedFiles,
|
||||
tagPrefix,
|
||||
Bus.instance
|
||||
|
|
|
@ -21,6 +21,7 @@ class LazyLoadingGallery extends StatefulWidget {
|
|||
final Stream<FilesUpdatedEvent>? reloadEvent;
|
||||
final Set<EventType> removalEventTypes;
|
||||
final GalleryLoader asyncLoader;
|
||||
final bool sortOrderAsc;
|
||||
final SelectedFiles? selectedFiles;
|
||||
final String tag;
|
||||
final String? logTag;
|
||||
|
@ -34,6 +35,7 @@ class LazyLoadingGallery extends StatefulWidget {
|
|||
this.reloadEvent,
|
||||
this.removalEventTypes,
|
||||
this.asyncLoader,
|
||||
this.sortOrderAsc,
|
||||
this.selectedFiles,
|
||||
this.tag,
|
||||
this.currentIndexStream,
|
||||
|
@ -112,6 +114,7 @@ class _LazyLoadingGalleryState extends State<LazyLoadingGallery> {
|
|||
final result = await widget.asyncLoader(
|
||||
dayStartTime.microsecondsSinceEpoch,
|
||||
dayStartTime.microsecondsSinceEpoch + microSecondsInDay - 1,
|
||||
asc: widget.sortOrderAsc,
|
||||
);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
|
|
@ -42,6 +42,7 @@ class Gallery extends StatefulWidget {
|
|||
final Widget loadingWidget;
|
||||
final bool disableScroll;
|
||||
final bool limitSelectionToOne;
|
||||
final bool sortOrderAsc;
|
||||
|
||||
const Gallery({
|
||||
required this.asyncLoader,
|
||||
|
@ -60,6 +61,7 @@ class Gallery extends StatefulWidget {
|
|||
this.loadingWidget = const EnteLoadingWidget(),
|
||||
this.disableScroll = false,
|
||||
this.limitSelectionToOne = false,
|
||||
this.sortOrderAsc = false,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
|
@ -126,7 +128,7 @@ class _GalleryState extends State<Gallery> {
|
|||
);
|
||||
}
|
||||
}
|
||||
if (widget.initialFiles != null) {
|
||||
if (widget.initialFiles != null && !widget.sortOrderAsc) {
|
||||
_onFilesLoaded(widget.initialFiles!);
|
||||
}
|
||||
_loadFiles(limit: kInitialLoadLimit).then((result) async {
|
||||
|
@ -154,6 +156,7 @@ class _GalleryState extends State<Gallery> {
|
|||
galleryLoadStartTime,
|
||||
galleryLoadEndTime,
|
||||
limit: limit,
|
||||
asc: widget.sortOrderAsc,
|
||||
);
|
||||
final endTime = DateTime.now().microsecondsSinceEpoch;
|
||||
final duration = Duration(microseconds: endTime - startTime);
|
||||
|
@ -213,6 +216,7 @@ class _GalleryState extends State<Gallery> {
|
|||
disableScroll: widget.disableScroll,
|
||||
emptyState: widget.emptyState,
|
||||
asyncLoader: widget.asyncLoader,
|
||||
sortOrderAsc: widget.sortOrderAsc,
|
||||
removalEventTypes: widget.removalEventTypes,
|
||||
tagPrefix: widget.tagPrefix,
|
||||
scrollBottomSafeArea: widget.scrollBottomSafeArea,
|
||||
|
@ -244,8 +248,13 @@ class _GalleryState extends State<Gallery> {
|
|||
if (dailyFiles.isNotEmpty) {
|
||||
collatedFiles.add(dailyFiles);
|
||||
}
|
||||
collatedFiles
|
||||
.sort((a, b) => b[0].creationTime!.compareTo(a[0].creationTime!));
|
||||
if (widget.sortOrderAsc) {
|
||||
collatedFiles
|
||||
.sort((a, b) => a[0].creationTime!.compareTo(b[0].creationTime!));
|
||||
} else {
|
||||
collatedFiles
|
||||
.sort((a, b) => b[0].creationTime!.compareTo(a[0].creationTime!));
|
||||
}
|
||||
return collatedFiles;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue