π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Populate grid rows with placeholders
ashilknbb756273834a
diff --git a/mobile/lib/models/gallery/fixed_extent_grid_row.dart b/mobile/lib/models/gallery/fixed_extent_grid_row.dartnew file mode 100644index 0000000000..69cf23b3fb--- /dev/null+++ b/mobile/lib/models/gallery/fixed_extent_grid_row.dart@@ -0,0 +1,168 @@+import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';++class FixedExtentGridRow extends MultiChildRenderObjectWidget {+ final double width, height, spacing;+ final TextDirection textDirection;++ const FixedExtentGridRow({+ super.key,+ required this.width,+ required this.height,+ required this.spacing,+ required this.textDirection,+ required super.children,+ });++ @override+ RenderObject createRenderObject(BuildContext context) {+ return RenderFixedExtentGridRow(+ width: width,+ height: height,+ spacing: spacing,+ textDirection: textDirection,+ );+ }++ @override+ void updateRenderObject(+ BuildContext context,+ RenderFixedExtentGridRow renderObject,+ ) {+ renderObject.width = width;+ renderObject.height = height;+ renderObject.spacing = spacing;+ renderObject.textDirection = textDirection;+ }++ @override+ void debugFillProperties(DiagnosticPropertiesBuilder properties) {+ super.debugFillProperties(properties);+ properties.add(DoubleProperty('width', width));+ properties.add(DoubleProperty('height', height));+ properties.add(DoubleProperty('spacing', spacing));+ properties.add(EnumProperty<TextDirection>('textDirection', textDirection));+ }+}++class _GridRowParentData extends ContainerBoxParentData<RenderBox> {}++class RenderFixedExtentGridRow extends RenderBox+ with+ ContainerRenderObjectMixin<RenderBox, _GridRowParentData>,+ RenderBoxContainerDefaultsMixin<RenderBox, _GridRowParentData> {+ RenderFixedExtentGridRow({+ List<RenderBox>? children,+ required double width,+ required double height,+ required double spacing,+ required TextDirection textDirection,+ }) : _width = width,+ _height = height,+ _spacing = spacing,+ _textDirection = textDirection {+ addAll(children);+ }++ double get width => _width;+ double _width;++ set width(double value) {+ if (_width == value) return;+ _width = value;+ markNeedsLayout();+ }++ double get height => _height;+ double _height;++ set height(double value) {+ if (_height == value) return;+ _height = value;+ markNeedsLayout();+ }++ double get spacing => _spacing;+ double _spacing;++ set spacing(double value) {+ if (_spacing == value) return;+ _spacing = value;+ markNeedsLayout();+ }++ TextDirection get textDirection => _textDirection;+ TextDirection _textDirection;++ set textDirection(TextDirection value) {+ if (_textDirection == value) return;+ _textDirection = value;+ markNeedsLayout();+ }++ @override+ void setupParentData(RenderBox child) {+ if (child.parentData is! _GridRowParentData) {+ child.parentData = _GridRowParentData();+ }+ }++ double get intrinsicWidth => width * childCount + spacing * (childCount - 1);++ @override+ double computeMinIntrinsicWidth(double height) => intrinsicWidth;++ @override+ double computeMaxIntrinsicWidth(double height) => intrinsicWidth;++ @override+ double computeMinIntrinsicHeight(double width) => height;++ @override+ double computeMaxIntrinsicHeight(double width) => height;++ @override+ void performLayout() {+ var child = firstChild;+ if (child == null) {+ size = constraints.smallest;+ return;+ }+ size = Size(constraints.maxWidth, height);+ final childConstraints = BoxConstraints.tight(Size(width, height));+ final flipMainAxis = textDirection == TextDirection.rtl;+ var offset = Offset(flipMainAxis ? size.width - width : 0, 0);+ final dx = (flipMainAxis ? -1 : 1) * (width + spacing);+ while (child != null) {+ child.layout(childConstraints, parentUsesSize: false);+ final childParentData = child.parentData! as _GridRowParentData;+ childParentData.offset = offset;+ offset += Offset(dx, 0);+ child = childParentData.nextSibling;+ }+ }++ @override+ double? computeDistanceToActualBaseline(TextBaseline baseline) {+ return defaultComputeDistanceToHighestActualBaseline(baseline);+ }++ @override+ bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {+ return defaultHitTestChildren(result, position: position);+ }++ @override+ void paint(PaintingContext context, Offset offset) {+ defaultPaint(context, offset);+ }++ @override+ void debugFillProperties(DiagnosticPropertiesBuilder properties) {+ super.debugFillProperties(properties);+ properties.add(DoubleProperty('width', width));+ properties.add(DoubleProperty('height', height));+ properties.add(DoubleProperty('spacing', spacing));+ properties.add(EnumProperty<TextDirection>('textDirection', textDirection));+ }+}diff --git a/mobile/lib/models/gallery/gallery_sections.dart b/mobile/lib/models/gallery/gallery_sections.dartindex 48d562462f..f0601fc969 100644--- a/mobile/lib/models/gallery/gallery_sections.dart+++ b/mobile/lib/models/gallery/gallery_sections.dart@@ -2,6 +2,7 @@ import "dart:core";import "package:flutter/material.dart";import "package:photos/models/file/file.dart";+import "package:photos/models/gallery/fixed_extent_grid_row.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";@@ -87,6 +88,8 @@ class GallerySections {final minOffset = currentOffset;final maxOffset =minOffset + (numberOfGridRows * tileHeight) + headerExtent;++ int currentGroupIndex = 0;sectionLayouts.add(FixedExtentSectionLayout(firstIndex: firstIndex,@@ -105,11 +108,30 @@ class GallerySections {),);} else {- return SizedBox(+ final gridRowChildren = <Widget>[];+ for (int i in Iterable<int>.generate(crossAxisCount)) {+ if (currentGroupIndex < filesInGroup.length) {+ gridRowChildren.add(+ SizedBox(+ width: tileHeight,+ height: tileHeight,+ child: Text(+ i.toString(),+ ),+ ),+ );+ currentGroupIndex++;+ } else {+ break;+ }+ }+ return FixedExtentGridRow(+ width: tileHeight,height: tileHeight,- child: const Placeholder(- child: Text("Grid row"),- ),+ //TODO: spacing+ spacing: 0,+ textDirection: TextDirection.ltr,+ children: gridRowChildren,);}},diff --git a/mobile/lib/ui/viewer/gallery/gallery.dart b/mobile/lib/ui/viewer/gallery/gallery.dartindex a3e837f2b7..b99634c1ce 100644--- a/mobile/lib/ui/viewer/gallery/gallery.dart+++ b/mobile/lib/ui/viewer/gallery/gallery.dart@@ -403,17 +403,20 @@ class GalleryState extends State<Gallery> {// 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(),- ),- ],+ child: Scrollbar(+ interactive: true,+ child: CustomScrollView(+ slivers: [+ SectionedListSliver(+ sectionLayouts: GallerySections(+ allFiles: _allGalleryFiles,+ groupType: widget.groupType,+ widthAvailable: MediaQuery.sizeOf(context).width,+ context: context,+ ).getSectionLayouts(),+ ),+ ],+ ),),);}