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:aves/widgets/stats.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:outline_material_icons/outline_material_icons.dart'; import 'package:outline_material_icons/outline_material_icons.dart';
import 'package:pedantic/pedantic.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class AllCollectionPage extends StatelessWidget { 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) { switch (action) {
case AlbumAction.debug: case AlbumAction.debug:
_goToDebug(context, collection); unawaited(_goToDebug(context, collection));
break; break;
case AlbumAction.stats: case AlbumAction.stats:
_goToStats(context, collection); unawaited(_goToStats(context, collection));
break; break;
case AlbumAction.groupByAlbum: case AlbumAction.groupByAlbum:
settings.collectionGroupFactor = GroupFactor.album; settings.collectionGroupFactor = GroupFactor.album;

View file

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

View file

@ -129,13 +129,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.6" 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: flutter_sticky_header:
dependency: "direct main" dependency: "direct main"
description: description:

View file

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