drawer: special album icons
This commit is contained in:
parent
c7b7a6f4b4
commit
52c836a796
12 changed files with 42 additions and 66 deletions
|
@ -3,7 +3,7 @@ import 'package:aves/model/image_file_service.dart';
|
|||
import 'package:aves/model/image_metadata.dart';
|
||||
import 'package:aves/model/metadata_db.dart';
|
||||
import "package:collection/collection.dart";
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
class ImageCollection with ChangeNotifier {
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:collection';
|
|||
import 'package:aves/model/image_file_service.dart';
|
||||
import 'package:aves/model/image_metadata.dart';
|
||||
import 'package:aves/model/metadata_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:geocoder/geocoder.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:aves/model/image_entry.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class ImageFileService {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:aves/model/image_entry.dart';
|
||||
import 'package:aves/model/image_metadata.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class MetadataService {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:aves/model/image_collection.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
final Settings settings = Settings._private();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class AndroidAppService {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:aves/model/image_collection.dart';
|
||||
import 'package:aves/model/image_entry.dart';
|
||||
import 'package:aves/widgets/album/filtered_collection_page.dart';
|
||||
import 'package:aves/widgets/common/icons.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
@ -70,7 +71,7 @@ class AllCollectionDrawer extends StatelessWidget {
|
|||
Divider(),
|
||||
...albums.map((album) => _buildFilteredCollectionNavTile(
|
||||
context: context,
|
||||
leading: Icon(Icons.photo_album),
|
||||
leading: IconUtils.getAlbumIcon(context, album) ?? Icon(Icons.photo_album),
|
||||
title: collection.getUniqueAlbumName(album, albums),
|
||||
filter: (entry) => entry.directory == album,
|
||||
)),
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:typed_data';
|
|||
|
||||
import 'package:aves/model/image_entry.dart';
|
||||
import 'package:aves/model/image_file_service.dart';
|
||||
import 'package:aves/widgets/album/thumbnail_tags.dart';
|
||||
import 'package:aves/widgets/common/icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:transparent_image/transparent_image.dart';
|
||||
|
||||
|
@ -123,14 +123,14 @@ class ThumbnailImage extends StatelessWidget {
|
|||
}),
|
||||
),
|
||||
if (entry.isVideo)
|
||||
VideoTag(
|
||||
VideoIcon(
|
||||
entry: entry,
|
||||
iconSize: iconSize,
|
||||
)
|
||||
else if (entry.isGif)
|
||||
GifTag(iconSize: iconSize)
|
||||
GifIcon(iconSize: iconSize)
|
||||
else if (entry.hasGps)
|
||||
GpsTag(iconSize: iconSize)
|
||||
GpsIcon(iconSize: iconSize)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import 'package:aves/model/image_collection.dart';
|
||||
import 'package:aves/model/image_entry.dart';
|
||||
import 'package:aves/utils/android_file_utils.dart';
|
||||
import 'package:aves/widgets/album/sections.dart';
|
||||
import 'package:aves/widgets/album/thumbnail.dart';
|
||||
import 'package:aves/widgets/common/draggable_scrollbar.dart';
|
||||
import 'package:aves/widgets/common/icons.dart';
|
||||
import 'package:aves/widgets/fullscreen/image_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_sticky_header/flutter_sticky_header.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class ThumbnailCollection extends AnimatedWidget {
|
||||
final ImageCollection collection;
|
||||
|
@ -99,7 +98,7 @@ class SectionSliver extends StatelessWidget {
|
|||
switch (collection.groupFactor) {
|
||||
case GroupFactor.album:
|
||||
header = SectionHeader(
|
||||
leading: getAlbumIcon(context, sectionKey),
|
||||
leading: IconUtils.getAlbumIcon(context, sectionKey),
|
||||
title: collection.getUniqueAlbumName(sectionKey, sections.keys.toList()),
|
||||
);
|
||||
break;
|
||||
|
@ -135,17 +134,6 @@ class SectionSliver extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
Widget getAlbumIcon(BuildContext context, String albumDirectory) {
|
||||
if (androidFileUtils.isCameraPath(albumDirectory)) {
|
||||
return Icon(Icons.photo_camera);
|
||||
} else if (androidFileUtils.isScreenshotsPath(albumDirectory)) {
|
||||
return Icon(Icons.smartphone);
|
||||
} else if (androidFileUtils.isKakaoTalkPath(albumDirectory)) {
|
||||
return SvgPicture.asset('assets/kakaotalk.svg', width: IconTheme.of(context).size);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future _showFullscreen(BuildContext context, ImageEntry entry) {
|
||||
return Navigator.push(
|
||||
context,
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import 'package:aves/model/image_entry.dart';
|
||||
import 'package:aves/utils/android_file_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class VideoTag extends StatelessWidget {
|
||||
class VideoIcon extends StatelessWidget {
|
||||
final ImageEntry entry;
|
||||
final double iconSize;
|
||||
|
||||
const VideoTag({Key key, this.entry, this.iconSize}) : super(key: key);
|
||||
const VideoIcon({Key key, this.entry, this.iconSize}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Tag(
|
||||
return OverlayIcon(
|
||||
icon: Icons.play_circle_outline,
|
||||
iconSize: iconSize,
|
||||
text: entry.durationText,
|
||||
|
@ -17,40 +19,40 @@ class VideoTag extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class GifTag extends StatelessWidget {
|
||||
class GifIcon extends StatelessWidget {
|
||||
final double iconSize;
|
||||
|
||||
const GifTag({Key key, this.iconSize}) : super(key: key);
|
||||
const GifIcon({Key key, this.iconSize}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Tag(
|
||||
return OverlayIcon(
|
||||
icon: Icons.gif,
|
||||
iconSize: iconSize,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GpsTag extends StatelessWidget {
|
||||
class GpsIcon extends StatelessWidget {
|
||||
final double iconSize;
|
||||
|
||||
const GpsTag({Key key, this.iconSize}) : super(key: key);
|
||||
const GpsIcon({Key key, this.iconSize}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Tag(
|
||||
return OverlayIcon(
|
||||
icon: Icons.place,
|
||||
iconSize: iconSize,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Tag extends StatelessWidget {
|
||||
class OverlayIcon extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final double iconSize;
|
||||
final String text;
|
||||
|
||||
const Tag({Key key, this.icon, this.iconSize, this.text}) : super(key: key);
|
||||
const OverlayIcon({Key key, this.icon, this.iconSize, this.text}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -80,3 +82,16 @@ class Tag extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IconUtils {
|
||||
static Widget getAlbumIcon(BuildContext context, String albumDirectory) {
|
||||
if (androidFileUtils.isCameraPath(albumDirectory)) {
|
||||
return Icon(Icons.photo_camera);
|
||||
} else if (androidFileUtils.isScreenshotsPath(albumDirectory)) {
|
||||
return Icon(Icons.smartphone);
|
||||
} else if (androidFileUtils.isKakaoTalkPath(albumDirectory)) {
|
||||
return SvgPicture.asset('assets/kakaotalk.svg', width: IconTheme.of(context).size);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -99,14 +99,17 @@ class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
|||
IconButton(
|
||||
icon: Icon(Icons.add),
|
||||
onPressed: controller == null ? null : () => zoomBy(1),
|
||||
tooltip: 'Zoom in',
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.remove),
|
||||
onPressed: controller == null ? null : () => zoomBy(-1),
|
||||
tooltip: 'Zoom out',
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.open_in_new),
|
||||
onPressed: () => AndroidAppService.openMap(widget.geoUri),
|
||||
tooltip: 'Show on map...',
|
||||
),
|
||||
])
|
||||
],
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
// This is a basic Flutter widget test.
|
||||
//
|
||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// utility that Flutter provides. For example, you can send tap and scroll
|
||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:aves/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(AvesApp());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
|
||||
// Tap the '+' icon and trigger a frame.
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
await tester.pump();
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue