mirror of
https://github.com/ente-io/ente.git
synced 2025-07-02 05:35:12 +00:00
Normal search and hierarchical search needs slightly different set of files. Refactored code in such a way that the elements in both these lists are references of a elements in a list of all files and hence reducing the memory needed for search and hierarchical search combined. Files used for hierarchical search contain only uploaded files now, rather than mix of uploaded and un-uploaded, reducing iterations required for hierarchical search
107 lines
3.6 KiB
Dart
107 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:photos/core/event_bus.dart';
|
|
import 'package:photos/events/collection_meta_event.dart';
|
|
import 'package:photos/events/collection_updated_event.dart';
|
|
import 'package:photos/events/files_updated_event.dart';
|
|
import "package:photos/generated/l10n.dart";
|
|
import "package:photos/models/file/extensions/file_props.dart";
|
|
import "package:photos/models/file/file.dart";
|
|
import 'package:photos/models/file_load_result.dart';
|
|
import 'package:photos/models/gallery_type.dart';
|
|
import 'package:photos/models/selected_files.dart';
|
|
import "package:photos/services/search_service.dart";
|
|
import 'package:photos/ui/viewer/actions/file_selection_overlay_bar.dart';
|
|
import "package:photos/ui/viewer/gallery/component/group/type.dart";
|
|
import 'package:photos/ui/viewer/gallery/gallery.dart';
|
|
import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";
|
|
import "package:photos/ui/viewer/gallery/state/selection_state.dart";
|
|
|
|
class LargeFilesPagePage extends StatelessWidget {
|
|
final String tagPrefix;
|
|
final GalleryType appBarType;
|
|
final GalleryType overlayType;
|
|
final _selectedFiles = SelectedFiles();
|
|
static const int minLargeFileSize = 50 * 1024 * 1024;
|
|
|
|
LargeFilesPagePage({
|
|
this.tagPrefix = "Uncategorized_page",
|
|
this.appBarType = GalleryType.homepage,
|
|
this.overlayType = GalleryType.homepage,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final gallery = Gallery(
|
|
asyncLoader: (creationStartTime, creationEndTime, {limit, asc}) async {
|
|
final List<EnteFile> allFiles =
|
|
await SearchService.instance.getAllFilesForSearch();
|
|
final Set<int> alreadyTracked = <int>{};
|
|
|
|
final filesWithSize = <EnteFile>[];
|
|
for (final file in allFiles) {
|
|
if (file.isOwner &&
|
|
file.isUploaded &&
|
|
file.fileSize != null &&
|
|
file.fileSize! > minLargeFileSize) {
|
|
if (!alreadyTracked.contains(file.uploadedFileID!)) {
|
|
filesWithSize.add(file);
|
|
alreadyTracked.add(file.uploadedFileID!);
|
|
}
|
|
}
|
|
}
|
|
final FileLoadResult result = FileLoadResult(filesWithSize, false);
|
|
return result;
|
|
},
|
|
reloadEvent: Bus.instance.on<CollectionUpdatedEvent>(),
|
|
removalEventTypes: const {
|
|
EventType.deletedFromRemote,
|
|
EventType.deletedFromEverywhere,
|
|
EventType.hide,
|
|
},
|
|
forceReloadEvents: [
|
|
Bus.instance.on<CollectionMetaEvent>(),
|
|
],
|
|
tagPrefix: tagPrefix,
|
|
selectedFiles: _selectedFiles,
|
|
sortAsyncFn: () => false,
|
|
groupType: GroupType.size,
|
|
initialFiles: null,
|
|
albumName: S.of(context).viewLargeFiles,
|
|
);
|
|
return GalleryFilesState(
|
|
child: Scaffold(
|
|
appBar: PreferredSize(
|
|
preferredSize: const Size.fromHeight(50.0),
|
|
child: AppBar(
|
|
elevation: 0,
|
|
centerTitle: false,
|
|
title: Text(
|
|
S.of(context).viewLargeFiles,
|
|
style: Theme.of(context)
|
|
.textTheme
|
|
.headlineSmall!
|
|
.copyWith(fontSize: 16),
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
),
|
|
body: SelectionState(
|
|
selectedFiles: _selectedFiles,
|
|
child: Stack(
|
|
alignment: Alignment.bottomCenter,
|
|
children: [
|
|
gallery,
|
|
FileSelectionOverlayBar(
|
|
overlayType,
|
|
_selectedFiles,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|