minor changes

This commit is contained in:
Thibault Deckers 2020-03-24 15:01:19 +09:00
parent 14d1f9241c
commit 39185f5ba8
4 changed files with 60 additions and 38 deletions

View file

@ -7,6 +7,7 @@ import 'package:aves/widgets/debug_page.dart';
import 'package:aves/widgets/stats.dart';
import 'package:flutter/material.dart';
import 'package:outline_material_icons/outline_material_icons.dart';
import 'package:pedantic/pedantic.dart';
import 'package:provider/provider.dart';
class AllCollectionPage extends StatelessWidget {
@ -90,13 +91,15 @@ class _AllCollectionAppBar extends SliverAppBar {
];
}
static void _onActionSelected(BuildContext context, CollectionLens collection, AlbumAction action) {
static void _onActionSelected(BuildContext context, CollectionLens collection, AlbumAction action) async {
// wait for the popup menu to hide before proceeding with the action
await Future.delayed(const Duration(milliseconds: 300));
switch (action) {
case AlbumAction.debug:
_goToDebug(context, collection);
unawaited(_goToDebug(context, collection));
break;
case AlbumAction.stats:
_goToStats(context, collection);
unawaited(_goToStats(context, collection));
break;
case AlbumAction.groupByAlbum:
settings.collectionGroupFactor = GroupFactor.album;

View file

@ -25,35 +25,24 @@ class SectionSliver extends StatelessWidget {
@override
Widget build(BuildContext context) {
final sections = collection.sections;
final sectionEntries = sections[sectionKey];
final childCount = sectionEntries.length;
final sliver = SliverGrid(
delegate: SliverChildBuilderDelegate(
// TODO TLAD find out why thumbnails are rebuilt (with `initState`)
(context, index) {
final sectionEntries = sections[sectionKey];
if (index >= sectionEntries.length) return null;
final entry = sectionEntries[index];
return GestureDetector(
key: ValueKey(entry.uri),
onTap: () => _showFullscreen(context, entry),
child: Selector<MediaQueryData, double>(
selector: (c, mq) => mq.size.width,
builder: (c, mqWidth, child) {
return MetaData(
metaData: ThumbnailMetadata(index, entry),
child: Thumbnail(
entry: entry,
extent: mqWidth / columnCount,
heroTag: collection.heroTag(entry),
),
);
},
),
);
},
childCount: sections[sectionKey].length,
// TODO TLAD thumbnails at the beginning of each sections are built even though they are offscreen
// because of `RenderSliverMultiBoxAdaptor.addInitialChild`
// called by `RenderSliverGrid.performLayout` (line 547)
(context, index) => index < childCount
? GridThumbnail(
collection: collection,
index: index,
entry: sectionEntries[index],
columnCount: columnCount,
)
: null,
childCount: childCount,
addAutomaticKeepAlives: false,
addRepaintBoundaries: true,
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: columnCount,
@ -70,12 +59,50 @@ class SectionSliver extends StatelessWidget {
overlapsContent: false,
);
}
}
void _showFullscreen(BuildContext context, ImageEntry entry) {
class GridThumbnail extends StatelessWidget {
final CollectionLens collection;
final int index;
final ImageEntry entry;
final int columnCount;
final GestureTapCallback onTap;
const GridThumbnail({
Key key,
this.collection,
this.index,
this.entry,
this.columnCount,
this.onTap,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
key: ValueKey(entry.uri),
onTap: () => _showFullscreen(context),
child: Selector<MediaQueryData, double>(
selector: (c, mq) => mq.size.width,
builder: (c, mqWidth, child) {
return MetaData(
metaData: ThumbnailMetadata(index, entry),
child: Thumbnail(
entry: entry,
extent: mqWidth / columnCount,
heroTag: collection.heroTag(entry),
),
);
},
),
);
}
void _showFullscreen(BuildContext context) {
Navigator.push(
context,
TransparentMaterialPageRoute(
pageBuilder: (context, _, __) => MultiFullscreenPage(
pageBuilder: (c, a, sa) => MultiFullscreenPage(
collection: collection,
initialEntry: entry,
),

View file

@ -129,13 +129,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.6"
flutter_staggered_grid_view:
dependency: "direct main"
description:
name: flutter_staggered_grid_view
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
flutter_sticky_header:
dependency: "direct main"
description:

View file

@ -29,7 +29,6 @@ dependencies:
url: https://github.com/AndreHaueisen/flushbar.git
ref: 13c55a8
flutter_native_timezone:
flutter_staggered_grid_view:
flutter_sticky_header:
git:
url: git://github.com/deckerst/flutter_sticky_header.git