π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Get a bare-bones structure of the new gallery working
ashilkn828ade260927
diff --git a/mobile/lib/models/gallery/gallery_sections.dart b/mobile/lib/models/gallery/gallery_sections.dartindex e17e295001..48d562462f 100644--- a/mobile/lib/models/gallery/gallery_sections.dart+++ b/mobile/lib/models/gallery/gallery_sections.dart@@ -1,22 +1,36 @@import "dart:core";+import "package:flutter/material.dart";import "package:photos/models/file/file.dart";+import "package:photos/models/gallery/fixed_extent_section_layout.dart";+import "package:photos/service_locator.dart";import "package:photos/ui/viewer/gallery/component/group/type.dart";import "package:uuid/uuid.dart";class GallerySections {final List<EnteFile> allFiles;final GroupType groupType;++ //TODO: Add support for sort orderfinal bool sortOrderAsc;+ final double widthAvailable;+ final double headerExtent;+ final BuildContext context;GallerySections({required this.allFiles,required this.groupType,+ required this.widthAvailable,+ required this.context,this.sortOrderAsc = true,- });+ this.headerExtent = 85,+ }) {+ init();+ }- late final List<String> _groupIDs;- late final Map<String, List<EnteFile>> _groupIDToFilesMap;- late Map<String, GroupHeaderData> _groupIdToheaderDataMap;+ final List<String> _groupIDs = [];+ final Map<String, List<EnteFile>> _groupIDToFilesMap = {};+ final Map<String, GroupHeaderData> _groupIdToheaderDataMap = {};+ late final int crossAxisCount;List<String> get groupIDs => _groupIDs;Map<String, List<EnteFile>> get groupIDToFilesMap => _groupIDToFilesMap;@@ -29,7 +43,7 @@ class GallerySections {List<EnteFile> dailyFiles = [];for (int index = 0; index < allFiles.length; index++) {if (index > 0 &&- groupType.areFromSameGroup(allFiles[index - 1], allFiles[index])) {+ !groupType.areFromSameGroup(allFiles[index - 1], allFiles[index])) {_createNewGroup(dailyFiles);dailyFiles = [];}@@ -38,6 +52,8 @@ class GallerySections {if (dailyFiles.isNotEmpty) {_createNewGroup(dailyFiles);}++ crossAxisCount = localSettings.getPhotoGridSize();}void _createNewGroup(@@ -47,15 +63,72 @@ class GallerySections {_groupIDs.add(uuid);_groupIDToFilesMap[uuid] = dailyFiles;_groupIdToheaderDataMap[uuid] = GroupHeaderData(- title: dailyFiles.first.creationTime!.toString(),+ title: groupType.getTitle(+ context,+ dailyFiles.first,+ lastFile: dailyFiles.last,+ ),+ groupType: groupType,);}++ List<FixedExtentSectionLayout> getSectionLayouts() {+ int currentIndex = 0;+ double currentOffset = 0.0;+ final tileHeight = widthAvailable / crossAxisCount;+ final sectionLayouts = <FixedExtentSectionLayout>[];++ // TODO: spacing+ for (final key in _groupIDToFilesMap.keys) {+ final filesInGroup = _groupIDToFilesMap[key]!;+ final numberOfGridRows = (filesInGroup.length / crossAxisCount).ceil();+ final firstIndex = currentIndex == 0 ? currentIndex : currentIndex + 1;+ final lastIndex = firstIndex + numberOfGridRows;+ final minOffset = currentOffset;+ final maxOffset =+ minOffset + (numberOfGridRows * tileHeight) + headerExtent;+ sectionLayouts.add(+ FixedExtentSectionLayout(+ firstIndex: firstIndex,+ lastIndex: lastIndex,+ minOffset: minOffset,+ maxOffset: maxOffset,+ headerExtent: headerExtent,+ tileHeight: tileHeight,+ spacing: 0,+ builder: (context, index) {+ if (index == firstIndex) {+ return SizedBox(+ height: headerExtent,+ child: Placeholder(+ child: Text(_groupIdToheaderDataMap[key]!.title),+ ),+ );+ } else {+ return SizedBox(+ height: tileHeight,+ child: const Placeholder(+ child: Text("Grid row"),+ ),+ );+ }+ },+ ),+ );+ currentIndex = lastIndex;+ currentOffset = maxOffset;+ }++ return sectionLayouts;+ }}class GroupHeaderData {final String title;+ final GroupType groupType;GroupHeaderData({required this.title,+ required this.groupType,});}diff --git a/mobile/lib/ui/viewer/gallery/gallery.dart b/mobile/lib/ui/viewer/gallery/gallery.dartindex ea33d1b466..a3e837f2b7 100644--- a/mobile/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/lib/ui/viewer/gallery/gallery.dart@@ -10,10 +10,11 @@ import 'package:photos/events/files_updated_event.dart';import 'package:photos/events/tab_changed_event.dart';import 'package:photos/models/file/file.dart';import 'package:photos/models/file_load_result.dart';+import "package:photos/models/gallery/gallery_sections.dart";import 'package:photos/models/selected_files.dart';import 'package:photos/ui/common/loading_widget.dart';import "package:photos/ui/viewer/gallery/component/group/type.dart";-import "package:photos/ui/viewer/gallery/component/multiple_groups_gallery_view.dart";+import "package:photos/ui/viewer/gallery/component/sectioned_sliver_list.dart";import 'package:photos/ui/viewer/gallery/empty_state.dart';import "package:photos/ui/viewer/gallery/state/gallery_context_state.dart";import "package:photos/ui/viewer/gallery/state/gallery_files_inherited_widget.dart";@@ -380,27 +381,39 @@ class GalleryState extends State<Gallery> {inSelectionMode: widget.inSelectionMode,type: widget.groupType,// Replace this with the new gallery and use `_allGalleryFiles`- child: MultipleGroupsGalleryView(- itemScroller: _itemScroller,- groupedFiles: currentGroupedFiles,- disableScroll: widget.disableScroll,- emptyState: widget.emptyState,- asyncLoader: widget.asyncLoader,- removalEventTypes: widget.removalEventTypes,- tagPrefix: widget.tagPrefix,- scrollBottomSafeArea: widget.scrollBottomSafeArea,- limitSelectionToOne: widget.limitSelectionToOne,- enableFileGrouping:- widget.enableFileGrouping && widget.groupType.showGroupHeader(),- logTag: _logTag,- logger: _logger,- reloadEvent: widget.reloadEvent,- header: widget.header,- footer: widget.footer,- selectedFiles: widget.selectedFiles,- showSelectAllByDefault:- widget.showSelectAllByDefault && widget.groupType.showGroupHeader(),- isScrollablePositionedList: widget.isScrollablePositionedList,+ // child: MultipleGroupsGalleryView(+ // itemScroller: _itemScroller,+ // groupedFiles: currentGroupedFiles,+ // disableScroll: widget.disableScroll,+ // emptyState: widget.emptyState,+ // asyncLoader: widget.asyncLoader,+ // removalEventTypes: widget.removalEventTypes,+ // tagPrefix: widget.tagPrefix,+ // scrollBottomSafeArea: widget.scrollBottomSafeArea,+ // limitSelectionToOne: widget.limitSelectionToOne,+ // enableFileGrouping:+ // widget.enableFileGrouping && widget.groupType.showGroupHeader(),+ // logTag: _logTag,+ // logger: _logger,+ // reloadEvent: widget.reloadEvent,+ // header: widget.header,+ // footer: widget.footer,+ // selectedFiles: widget.selectedFiles,+ // showSelectAllByDefault:+ // widget.showSelectAllByDefault && widget.groupType.showGroupHeader(),+ // isScrollablePositionedList: widget.isScrollablePositionedList,+ // ),+ child: CustomScrollView(+ slivers: [+ SectionedListSliver(+ sectionLayouts: GallerySections(+ allFiles: _allGalleryFiles,+ groupType: widget.groupType,+ widthAvailable: MediaQuery.sizeOf(context).width,+ context: context,+ ).getSectionLayouts(),+ ),+ ],),);}