home: added albums/tags items to drawer
This commit is contained in:
parent
86e0c1b081
commit
f73c72973a
7 changed files with 111 additions and 60 deletions
|
@ -64,9 +64,11 @@ class _HomePageState extends State<HomePage> {
|
||||||
(entryMap) => localMediaCollection.add(ImageEntry.fromMap(entryMap)),
|
(entryMap) => localMediaCollection.add(ImageEntry.fromMap(entryMap)),
|
||||||
onDone: () async {
|
onDone: () async {
|
||||||
debugPrint('mediastore stream done');
|
debugPrint('mediastore stream done');
|
||||||
|
localMediaCollection.updateAlbums();
|
||||||
await localMediaCollection.loadCatalogMetadata();
|
await localMediaCollection.loadCatalogMetadata();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
await localMediaCollection.catalogEntries();
|
await localMediaCollection.catalogEntries();
|
||||||
|
localMediaCollection.updateTags();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
await localMediaCollection.loadAddresses();
|
await localMediaCollection.loadAddresses();
|
||||||
await localMediaCollection.locateEntries();
|
await localMediaCollection.locateEntries();
|
||||||
|
|
|
@ -9,6 +9,7 @@ class ImageCollection with ChangeNotifier {
|
||||||
final List<ImageEntry> _rawEntries;
|
final List<ImageEntry> _rawEntries;
|
||||||
GroupFactor groupFactor = GroupFactor.date;
|
GroupFactor groupFactor = GroupFactor.date;
|
||||||
SortFactor sortFactor = SortFactor.date;
|
SortFactor sortFactor = SortFactor.date;
|
||||||
|
Set<String> albums = Set(), tags = Set();
|
||||||
|
|
||||||
ImageCollection({
|
ImageCollection({
|
||||||
@required List<ImageEntry> entries,
|
@required List<ImageEntry> entries,
|
||||||
|
@ -20,9 +21,9 @@ class ImageCollection with ChangeNotifier {
|
||||||
|
|
||||||
int get videoCount => _rawEntries.where((entry) => entry.isVideo).length;
|
int get videoCount => _rawEntries.where((entry) => entry.isVideo).length;
|
||||||
|
|
||||||
int get albumCount => 42;
|
int get albumCount => albums.length;
|
||||||
|
|
||||||
int get tagCount => 42;
|
int get tagCount => tags.length;
|
||||||
|
|
||||||
Map<dynamic, List<ImageEntry>> get sections {
|
Map<dynamic, List<ImageEntry>> get sections {
|
||||||
switch (sortFactor) {
|
switch (sortFactor) {
|
||||||
|
@ -75,6 +76,10 @@ class ImageCollection with ChangeNotifier {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateAlbums() => albums = _rawEntries.map((entry) => entry.bucketDisplayName).toSet();
|
||||||
|
|
||||||
|
updateTags() => tags = _rawEntries.expand((entry) => entry.xmpSubjects).toSet();
|
||||||
|
|
||||||
loadCatalogMetadata() async {
|
loadCatalogMetadata() async {
|
||||||
debugPrint('$runtimeType loadCatalogMetadata start');
|
debugPrint('$runtimeType loadCatalogMetadata start');
|
||||||
final start = DateTime.now();
|
final start = DateTime.now();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:aves/model/image_collection.dart';
|
import 'package:aves/model/image_collection.dart';
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/widgets/album/filtered_collection_page.dart';
|
import 'package:aves/widgets/album/filtered_collection_page.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
@ -11,80 +12,99 @@ class AllCollectionDrawer extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final albums = collection.albums.toList()..sort(compareAsciiUpperCaseNatural);
|
||||||
|
final tags = collection.tags.toList()..sort(compareAsciiUpperCaseNatural);
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||||
children: [
|
children: [
|
||||||
DrawerHeader(
|
DrawerHeader(
|
||||||
child: DefaultTextStyle(
|
child: Column(
|
||||||
style: TextStyle(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
color: Colors.white,
|
children: [
|
||||||
),
|
Row(
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Row(
|
CircleAvatar(
|
||||||
children: [
|
child: Padding(
|
||||||
CircleAvatar(
|
padding: EdgeInsets.only(top: 6.0),
|
||||||
child: Padding(
|
child: SvgPicture.asset(
|
||||||
padding: EdgeInsets.only(top: 6.0),
|
'assets/aves_logo.svg',
|
||||||
child: SvgPicture.asset(
|
width: 50,
|
||||||
'assets/aves_logo.svg',
|
|
||||||
width: 50,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
radius: 32,
|
|
||||||
),
|
),
|
||||||
SizedBox(width: 16),
|
),
|
||||||
Text('Aves',
|
backgroundColor: Colors.white,
|
||||||
style: TextStyle(
|
radius: 32,
|
||||||
fontSize: 42,
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
SizedBox(height: 8),
|
SizedBox(width: 16),
|
||||||
Row(
|
Text('Aves',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 42,
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 72,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text('${collection.imageCount}'),
|
||||||
|
Text('${collection.videoCount}'),
|
||||||
|
Text('${collection.albumCount}'),
|
||||||
|
Text('${collection.tagCount}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Text('images'),
|
||||||
width: 72,
|
Text('videos'),
|
||||||
child: Column(
|
Text('albums'),
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
Text('tags'),
|
||||||
children: [
|
|
||||||
Text('${collection.imageCount}'),
|
|
||||||
Text('${collection.videoCount}'),
|
|
||||||
Text('${collection.albumCount}'),
|
|
||||||
Text('${collection.tagCount}'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text('images'),
|
|
||||||
Text('videos'),
|
|
||||||
Text('albums'),
|
|
||||||
Text('tags'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).accentColor,
|
color: Theme.of(context).accentColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_buildFilteredCollectionNavTile(context, 'Videos', (entry) => entry.isVideo),
|
_buildFilteredCollectionNavTile(
|
||||||
|
context: context,
|
||||||
|
leading: Icon(Icons.video_library),
|
||||||
|
title: 'Videos',
|
||||||
|
filter: (entry) => entry.isVideo,
|
||||||
|
),
|
||||||
|
Divider(),
|
||||||
|
...albums.map((album) => _buildFilteredCollectionNavTile(
|
||||||
|
context: context,
|
||||||
|
leading: Icon(Icons.photo_library),
|
||||||
|
title: album,
|
||||||
|
filter: (entry) => entry.bucketDisplayName == album,
|
||||||
|
)),
|
||||||
|
Divider(),
|
||||||
|
...tags.map((tag) => _buildFilteredCollectionNavTile(
|
||||||
|
context: context,
|
||||||
|
leading: Icon(Icons.label_outline),
|
||||||
|
title: tag,
|
||||||
|
filter: (entry) => entry.xmpSubjects.contains(tag),
|
||||||
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildFilteredCollectionNavTile(BuildContext context, String title, bool Function(ImageEntry) filter) {
|
_buildFilteredCollectionNavTile({BuildContext context, Widget leading, String title, bool Function(ImageEntry) filter}) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
leading: leading,
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
|
dense: true,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
|
|
|
@ -22,6 +22,7 @@ class FilteredCollectionPage extends StatelessWidget {
|
||||||
floating: true,
|
floating: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ class FullscreenBodyState extends State<FullscreenBody> with SingleTickerProvide
|
||||||
if (notification is BackUpNotification) goToVerticalPage(0);
|
if (notification is BackUpNotification) goToVerticalPage(0);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
child: InfoPage(entry: entry),
|
child: InfoPage(collection: collection, entry: entry),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:aves/model/image_collection.dart';
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/utils/file_utils.dart';
|
import 'package:aves/utils/file_utils.dart';
|
||||||
import 'package:aves/widgets/fullscreen/info/location_section.dart';
|
import 'package:aves/widgets/fullscreen/info/location_section.dart';
|
||||||
|
@ -7,9 +8,14 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class InfoPage extends StatefulWidget {
|
class InfoPage extends StatefulWidget {
|
||||||
|
final ImageCollection collection;
|
||||||
final ImageEntry entry;
|
final ImageEntry entry;
|
||||||
|
|
||||||
const InfoPage({this.entry});
|
const InfoPage({
|
||||||
|
Key key,
|
||||||
|
@required this.collection,
|
||||||
|
@required this.entry,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => InfoPageState();
|
State<StatefulWidget> createState() => InfoPageState();
|
||||||
|
@ -52,7 +58,7 @@ class InfoPageState extends State<InfoPage> {
|
||||||
InfoRow('Size', formatFilesize(entry.sizeBytes)),
|
InfoRow('Size', formatFilesize(entry.sizeBytes)),
|
||||||
InfoRow('Path', entry.path),
|
InfoRow('Path', entry.path),
|
||||||
LocationSection(entry: entry),
|
LocationSection(entry: entry),
|
||||||
XmpTagSection(entry: entry),
|
XmpTagSection(collection: widget.collection, entry: entry),
|
||||||
MetadataSection(entry: entry),
|
MetadataSection(entry: entry),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
|
import 'package:aves/model/image_collection.dart';
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
|
import 'package:aves/widgets/album/filtered_collection_page.dart';
|
||||||
import 'package:aves/widgets/fullscreen/info/info_page.dart';
|
import 'package:aves/widgets/fullscreen/info/info_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class XmpTagSection extends AnimatedWidget {
|
class XmpTagSection extends AnimatedWidget {
|
||||||
|
final ImageCollection collection;
|
||||||
final ImageEntry entry;
|
final ImageEntry entry;
|
||||||
|
|
||||||
const XmpTagSection({Key key, this.entry}) : super(key: key, listenable: entry);
|
const XmpTagSection({
|
||||||
|
Key key,
|
||||||
|
@required this.collection,
|
||||||
|
@required this.entry,
|
||||||
|
}) : super(key: key, listenable: entry);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -20,9 +27,19 @@ class XmpTagSection extends AnimatedWidget {
|
||||||
children: tags
|
children: tags
|
||||||
.map((tag) => Padding(
|
.map((tag) => Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 4.0),
|
padding: EdgeInsets.symmetric(horizontal: 4.0),
|
||||||
child: Chip(
|
child: ActionChip(
|
||||||
backgroundColor: Theme.of(context).accentColor,
|
|
||||||
label: Text(tag),
|
label: Text(tag),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => FilteredCollectionPage(
|
||||||
|
collection: collection,
|
||||||
|
filter: (entry) => entry.xmpSubjects.contains(tag),
|
||||||
|
title: tag,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor: Theme.of(context).accentColor,
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
|
Loading…
Reference in a new issue