mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-08 18:28:53 +01:00
Dynamic album that reflects dir contents
This commit is contained in:
parent
8e46c604a8
commit
b53c48808f
9 changed files with 603 additions and 137 deletions
|
@ -4,6 +4,7 @@ import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:nc_photos/entity/album.dart';
|
import 'package:nc_photos/entity/album.dart';
|
||||||
|
import 'package:nc_photos/entity/file.dart';
|
||||||
import 'package:nc_photos/iterable_extension.dart';
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
|
|
||||||
abstract class AlbumProvider with EquatableMixin {
|
abstract class AlbumProvider with EquatableMixin {
|
||||||
|
@ -15,6 +16,8 @@ abstract class AlbumProvider with EquatableMixin {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AlbumStaticProvider._type:
|
case AlbumStaticProvider._type:
|
||||||
return AlbumStaticProvider.fromJson(content.cast<String, dynamic>());
|
return AlbumStaticProvider.fromJson(content.cast<String, dynamic>());
|
||||||
|
case AlbumDirProvider._type:
|
||||||
|
return AlbumDirProvider.fromJson(content.cast<String, dynamic>());
|
||||||
default:
|
default:
|
||||||
_log.shout("[fromJson] Unknown type: $type");
|
_log.shout("[fromJson] Unknown type: $type");
|
||||||
throw ArgumentError.value(type, "type");
|
throw ArgumentError.value(type, "type");
|
||||||
|
@ -25,6 +28,8 @@ abstract class AlbumProvider with EquatableMixin {
|
||||||
String getType() {
|
String getType() {
|
||||||
if (this is AlbumStaticProvider) {
|
if (this is AlbumStaticProvider) {
|
||||||
return AlbumStaticProvider._type;
|
return AlbumStaticProvider._type;
|
||||||
|
} else if (this is AlbumDirProvider) {
|
||||||
|
return AlbumDirProvider._type;
|
||||||
} else {
|
} else {
|
||||||
throw StateError("Unknwon subtype");
|
throw StateError("Unknwon subtype");
|
||||||
}
|
}
|
||||||
|
@ -57,6 +62,9 @@ class AlbumStaticProvider extends AlbumProvider {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
factory AlbumStaticProvider.of(Album parent) =>
|
||||||
|
(parent.provider as AlbumStaticProvider);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
toString({bool isDeep = false}) {
|
toString({bool isDeep = false}) {
|
||||||
final itemsStr =
|
final itemsStr =
|
||||||
|
@ -83,3 +91,40 @@ class AlbumStaticProvider extends AlbumProvider {
|
||||||
|
|
||||||
static const _type = "static";
|
static const _type = "static";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AlbumDirProvider extends AlbumProvider {
|
||||||
|
AlbumDirProvider({
|
||||||
|
@required this.dirs,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory AlbumDirProvider.fromJson(Map<String, dynamic> json) {
|
||||||
|
return AlbumDirProvider(
|
||||||
|
dirs: (json["dirs"] as List)
|
||||||
|
.map((e) => File.fromJson(e.cast<String, dynamic>()))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
toString({bool isDeep = false}) {
|
||||||
|
return "$runtimeType {"
|
||||||
|
"dirs: ${dirs.map((e) => e.path).toReadableString()}, "
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
get props => [
|
||||||
|
dirs,
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
_toContentJson() {
|
||||||
|
return {
|
||||||
|
"dirs": dirs.map((e) => e.toJson()).toList(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<File> dirs;
|
||||||
|
|
||||||
|
static const _type = "dir";
|
||||||
|
}
|
||||||
|
|
|
@ -21,4 +21,8 @@ extension IterableExtension<T> on Iterable<T> {
|
||||||
/// equality function [equalFn]
|
/// equality function [equalFn]
|
||||||
bool containsIf(T element, bool Function(T a, T b) equalFn) =>
|
bool containsIf(T element, bool Function(T a, T b) equalFn) =>
|
||||||
any((e) => equalFn(e, element));
|
any((e) => equalFn(e, element));
|
||||||
|
|
||||||
|
/// Same as [contains] but uses [identical] to compare the objects
|
||||||
|
bool containsIdentical(T element) =>
|
||||||
|
containsIf(element, (a, b) => identical(a, b));
|
||||||
}
|
}
|
||||||
|
|
48
lib/use_case/populate_album.dart
Normal file
48
lib/use_case/populate_album.dart
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:nc_photos/account.dart';
|
||||||
|
import 'package:nc_photos/entity/album.dart';
|
||||||
|
import 'package:nc_photos/entity/album/provider.dart';
|
||||||
|
import 'package:nc_photos/entity/file.dart';
|
||||||
|
import 'package:nc_photos/entity/file/data_source.dart';
|
||||||
|
import 'package:nc_photos/use_case/scan_dir.dart';
|
||||||
|
|
||||||
|
class PopulateAlbum {
|
||||||
|
Future<List<AlbumItem>> call(Account account, Album album) async {
|
||||||
|
if (album.provider is AlbumStaticProvider) {
|
||||||
|
_log.warning(
|
||||||
|
"[call] Populate only make sense for dynamic albums: ${album.name}");
|
||||||
|
return AlbumStaticProvider.of(album).items;
|
||||||
|
}
|
||||||
|
if (album.provider is AlbumDirProvider) {
|
||||||
|
return _populateDirAlbum(account, album);
|
||||||
|
} else {
|
||||||
|
throw ArgumentError(
|
||||||
|
"Unknown album provider: ${album.provider.runtimeType}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<AlbumItem>> _populateDirAlbum(
|
||||||
|
Account account, Album album) async {
|
||||||
|
assert(album.provider is AlbumDirProvider);
|
||||||
|
final provider = album.provider as AlbumDirProvider;
|
||||||
|
final products = <AlbumItem>[];
|
||||||
|
for (final d in provider.dirs) {
|
||||||
|
final stream = ScanDir(FileRepo(FileCachedDataSource()))(account, d);
|
||||||
|
await for (final result in stream) {
|
||||||
|
if (result is Exception || result is Error) {
|
||||||
|
_log.shout(
|
||||||
|
"[_populateDirAlbum] Failed while scanning dir" +
|
||||||
|
(kDebugMode ? ": $d" : ""),
|
||||||
|
result);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
products.addAll(
|
||||||
|
(result as List).cast<File>().map((f) => AlbumFileItem(file: f)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
|
||||||
|
static final _log = Logger("use_case.populate_album.PopulateAlbum");
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ class AlbumGridItem extends StatelessWidget {
|
||||||
@required this.cover,
|
@required this.cover,
|
||||||
@required this.title,
|
@required this.title,
|
||||||
this.subtitle,
|
this.subtitle,
|
||||||
|
this.isDynamic = false,
|
||||||
this.isSelected = false,
|
this.isSelected = false,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.onLongPress,
|
this.onLongPress,
|
||||||
|
@ -45,10 +46,23 @@ class AlbumGridItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (isDynamic)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.topEnd,
|
||||||
|
child: Icon(
|
||||||
|
Icons.auto_awesome,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
if (isSelected)
|
if (isSelected)
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -86,6 +100,7 @@ class AlbumGridItem extends StatelessWidget {
|
||||||
final Widget cover;
|
final Widget cover;
|
||||||
final String title;
|
final String title;
|
||||||
final String subtitle;
|
final String subtitle;
|
||||||
|
final bool isDynamic;
|
||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
final VoidCallback onLongPress;
|
final VoidCallback onLongPress;
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:nc_photos/account.dart';
|
import 'package:nc_photos/account.dart';
|
||||||
import 'package:nc_photos/api/api.dart';
|
|
||||||
import 'package:nc_photos/api/api_util.dart' as api_util;
|
import 'package:nc_photos/api/api_util.dart' as api_util;
|
||||||
import 'package:nc_photos/entity/album.dart';
|
import 'package:nc_photos/entity/album.dart';
|
||||||
import 'package:nc_photos/entity/album/provider.dart';
|
import 'package:nc_photos/entity/album/provider.dart';
|
||||||
|
@ -15,13 +13,12 @@ import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||||
import 'package:nc_photos/iterable_extension.dart';
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
import 'package:nc_photos/list_extension.dart';
|
import 'package:nc_photos/list_extension.dart';
|
||||||
import 'package:nc_photos/pref.dart';
|
|
||||||
import 'package:nc_photos/snack_bar_manager.dart';
|
import 'package:nc_photos/snack_bar_manager.dart';
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/use_case/resync_album.dart';
|
import 'package:nc_photos/use_case/resync_album.dart';
|
||||||
import 'package:nc_photos/use_case/update_album.dart';
|
import 'package:nc_photos/use_case/update_album.dart';
|
||||||
|
import 'package:nc_photos/widget/album_viewer_mixin.dart';
|
||||||
import 'package:nc_photos/widget/photo_list_item.dart';
|
import 'package:nc_photos/widget/photo_list_item.dart';
|
||||||
import 'package:nc_photos/widget/popup_menu_zoom.dart';
|
|
||||||
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
||||||
import 'package:nc_photos/widget/viewer.dart';
|
import 'package:nc_photos/widget/viewer.dart';
|
||||||
import 'package:quiver/iterables.dart';
|
import 'package:quiver/iterables.dart';
|
||||||
|
@ -57,11 +54,13 @@ class AlbumViewer extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AlbumViewerState extends State<AlbumViewer>
|
class _AlbumViewerState extends State<AlbumViewer>
|
||||||
with WidgetsBindingObserver, SelectableItemStreamListMixin<AlbumViewer> {
|
with
|
||||||
|
WidgetsBindingObserver,
|
||||||
|
SelectableItemStreamListMixin<AlbumViewer>,
|
||||||
|
AlbumViewerMixin<AlbumViewer> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_thumbZoomLevel = Pref.inst().getAlbumViewerZoomLevel(0);
|
|
||||||
_initAlbum();
|
_initAlbum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +73,6 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
get itemStreamListCellSize => _thumbSize;
|
|
||||||
|
|
||||||
void _initAlbum() {
|
void _initAlbum() {
|
||||||
assert(widget.album.provider is AlbumStaticProvider);
|
assert(widget.album.provider is AlbumStaticProvider);
|
||||||
ResyncAlbum()(widget.account, widget.album).then((album) {
|
ResyncAlbum()(widget.account, widget.album).then((album) {
|
||||||
|
@ -90,26 +86,17 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
setState(() {
|
setState(() {
|
||||||
_album = album;
|
_album = album;
|
||||||
_transformItems();
|
_transformItems();
|
||||||
_initCover();
|
initCover(widget.account, _backingFiles);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _initCover() {
|
|
||||||
try {
|
|
||||||
final coverFile =
|
|
||||||
_backingFiles.firstWhere((element) => element.hasPreview);
|
|
||||||
_coverPreviewUrl = api_util.getFilePreviewUrl(widget.account, coverFile,
|
|
||||||
width: 1024, height: 600);
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
Widget _buildContent(BuildContext context) {
|
||||||
if (_album == null) {
|
if (_album == null) {
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
_buildNormalAppBar(context),
|
buildNormalAppBar(context, widget.account, widget.album),
|
||||||
const SliverToBoxAdapter(
|
const SliverToBoxAdapter(
|
||||||
child: const LinearProgressIndicator(),
|
child: const LinearProgressIndicator(),
|
||||||
),
|
),
|
||||||
|
@ -137,104 +124,18 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
|
|
||||||
Widget _buildAppBar(BuildContext context) {
|
Widget _buildAppBar(BuildContext context) {
|
||||||
if (isSelectionMode) {
|
if (isSelectionMode) {
|
||||||
return _buildSelectionAppBar(context);
|
return buildSelectionAppBar(context, [
|
||||||
} else {
|
|
||||||
return _buildNormalAppBar(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildSelectionAppBar(BuildContext context) {
|
|
||||||
return Theme(
|
|
||||||
data: Theme.of(context).copyWith(
|
|
||||||
appBarTheme: AppTheme.getContextualAppBarTheme(context),
|
|
||||||
),
|
|
||||||
child: SliverAppBar(
|
|
||||||
pinned: true,
|
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
clearSelectedItems();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(AppLocalizations.of(context)
|
|
||||||
.selectionAppBarTitle(selectedListItems.length)),
|
|
||||||
actions: [
|
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.remove),
|
icon: const Icon(Icons.remove),
|
||||||
tooltip:
|
tooltip: AppLocalizations.of(context).removeSelectedFromAlbumTooltip,
|
||||||
AppLocalizations.of(context).removeSelectedFromAlbumTooltip,
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_onSelectionAppBarRemovePressed();
|
_onSelectionAppBarRemovePressed();
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
]);
|
||||||
),
|
} else {
|
||||||
);
|
return buildNormalAppBar(context, widget.account, _album);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildNormalAppBar(BuildContext context) {
|
|
||||||
Widget cover;
|
|
||||||
try {
|
|
||||||
if (_coverPreviewUrl != null) {
|
|
||||||
cover = Opacity(
|
|
||||||
opacity:
|
|
||||||
Theme.of(context).brightness == Brightness.light ? 0.25 : 0.35,
|
|
||||||
child: FittedBox(
|
|
||||||
clipBehavior: Clip.hardEdge,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
child: CachedNetworkImage(
|
|
||||||
imageUrl: _coverPreviewUrl,
|
|
||||||
httpHeaders: {
|
|
||||||
"Authorization":
|
|
||||||
Api.getAuthorizationHeaderValue(widget.account),
|
|
||||||
},
|
|
||||||
filterQuality: FilterQuality.high,
|
|
||||||
errorWidget: (context, url, error) {
|
|
||||||
// just leave it empty
|
|
||||||
return Container();
|
|
||||||
},
|
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (_) {}
|
|
||||||
|
|
||||||
return SliverAppBar(
|
|
||||||
floating: true,
|
|
||||||
expandedHeight: 160,
|
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
|
||||||
background: cover,
|
|
||||||
title: Text(
|
|
||||||
(_album ?? widget.album).name,
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppTheme.getPrimaryTextColor(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
PopupMenuButton(
|
|
||||||
icon: const Icon(Icons.zoom_in),
|
|
||||||
tooltip: AppLocalizations.of(context).zoomTooltip,
|
|
||||||
itemBuilder: (context) => [
|
|
||||||
PopupMenuZoom(
|
|
||||||
initialValue: _thumbZoomLevel,
|
|
||||||
minValue: 0,
|
|
||||||
maxValue: 2,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_thumbZoomLevel = value.round();
|
|
||||||
});
|
|
||||||
Pref.inst().setAlbumViewerZoomLevel(_thumbZoomLevel);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onItemTap(int index) {
|
void _onItemTap(int index) {
|
||||||
|
@ -272,7 +173,7 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
setState(() {
|
setState(() {
|
||||||
_album = newAlbum;
|
_album = newAlbum;
|
||||||
_transformItems();
|
_transformItems();
|
||||||
_initCover();
|
initCover(widget.account, _backingFiles);
|
||||||
});
|
});
|
||||||
}).catchError((e, stacktrace) {
|
}).catchError((e, stacktrace) {
|
||||||
_log.shout("[_onSelectionRemovePressed] Failed while updating album", e,
|
_log.shout("[_onSelectionRemovePressed] Failed while updating album", e,
|
||||||
|
@ -301,7 +202,7 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
final f = _backingFiles[i];
|
final f = _backingFiles[i];
|
||||||
|
|
||||||
final previewUrl = api_util.getFilePreviewUrl(widget.account, f,
|
final previewUrl = api_util.getFilePreviewUrl(widget.account, f,
|
||||||
width: _thumbSize, height: _thumbSize);
|
width: thumbSize, height: thumbSize);
|
||||||
if (file_util.isSupportedImageFormat(f)) {
|
if (file_util.isSupportedImageFormat(f)) {
|
||||||
yield _ImageListItem(
|
yield _ImageListItem(
|
||||||
file: f,
|
file: f,
|
||||||
|
@ -353,26 +254,9 @@ class _AlbumViewerState extends State<AlbumViewer>
|
||||||
static List<AlbumItem> _getAlbumItemsOf(Album a) =>
|
static List<AlbumItem> _getAlbumItemsOf(Album a) =>
|
||||||
AlbumStaticProvider.of(a).items;
|
AlbumStaticProvider.of(a).items;
|
||||||
|
|
||||||
int get _thumbSize {
|
|
||||||
switch (_thumbZoomLevel) {
|
|
||||||
case 1:
|
|
||||||
return 176;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
return 256;
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
default:
|
|
||||||
return 112;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Album _album;
|
Album _album;
|
||||||
var _backingFiles = <File>[];
|
var _backingFiles = <File>[];
|
||||||
|
|
||||||
String _coverPreviewUrl;
|
|
||||||
var _thumbZoomLevel = 0;
|
|
||||||
|
|
||||||
static final _log = Logger("widget.album_viewer._AlbumViewerState");
|
static final _log = Logger("widget.album_viewer._AlbumViewerState");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
141
lib/widget/album_viewer_mixin.dart
Normal file
141
lib/widget/album_viewer_mixin.dart
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
import 'package:nc_photos/account.dart';
|
||||||
|
import 'package:nc_photos/api/api.dart';
|
||||||
|
import 'package:nc_photos/api/api_util.dart' as api_util;
|
||||||
|
import 'package:nc_photos/entity/album.dart';
|
||||||
|
import 'package:nc_photos/entity/file.dart';
|
||||||
|
import 'package:nc_photos/pref.dart';
|
||||||
|
import 'package:nc_photos/theme.dart';
|
||||||
|
import 'package:nc_photos/widget/popup_menu_zoom.dart';
|
||||||
|
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
||||||
|
|
||||||
|
mixin AlbumViewerMixin<T extends StatefulWidget>
|
||||||
|
on SelectableItemStreamListMixin<T> {
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
super.initState();
|
||||||
|
_thumbZoomLevel = Pref.inst().getAlbumViewerZoomLevel(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
File initCover(Account account, List<File> backingFiles) {
|
||||||
|
try {
|
||||||
|
final coverFile =
|
||||||
|
backingFiles.firstWhere((element) => element.hasPreview);
|
||||||
|
_coverPreviewUrl = api_util.getFilePreviewUrl(account, coverFile,
|
||||||
|
width: 1024, height: 600);
|
||||||
|
return coverFile;
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
Widget buildNormalAppBar(BuildContext context, Account account, Album album) {
|
||||||
|
Widget cover;
|
||||||
|
try {
|
||||||
|
if (_coverPreviewUrl != null) {
|
||||||
|
cover = Opacity(
|
||||||
|
opacity:
|
||||||
|
Theme.of(context).brightness == Brightness.light ? 0.25 : 0.35,
|
||||||
|
child: FittedBox(
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: _coverPreviewUrl,
|
||||||
|
httpHeaders: {
|
||||||
|
"Authorization": Api.getAuthorizationHeaderValue(account),
|
||||||
|
},
|
||||||
|
filterQuality: FilterQuality.high,
|
||||||
|
errorWidget: (context, url, error) {
|
||||||
|
// just leave it empty
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
|
return SliverAppBar(
|
||||||
|
floating: true,
|
||||||
|
expandedHeight: 160,
|
||||||
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
|
background: cover,
|
||||||
|
title: Text(
|
||||||
|
album.name,
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppTheme.getPrimaryTextColor(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
PopupMenuButton(
|
||||||
|
icon: const Icon(Icons.zoom_in),
|
||||||
|
tooltip: AppLocalizations.of(context).zoomTooltip,
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuZoom(
|
||||||
|
initialValue: _thumbZoomLevel,
|
||||||
|
minValue: 0,
|
||||||
|
maxValue: 2,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
_thumbZoomLevel = value.round();
|
||||||
|
});
|
||||||
|
Pref.inst().setAlbumViewerZoomLevel(_thumbZoomLevel);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildSelectionAppBar(BuildContext context, List<Widget> actions) {
|
||||||
|
return Theme(
|
||||||
|
data: Theme.of(context).copyWith(
|
||||||
|
appBarTheme: AppTheme.getContextualAppBarTheme(context),
|
||||||
|
),
|
||||||
|
child: SliverAppBar(
|
||||||
|
pinned: true,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
clearSelectedItems();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
title: Text(AppLocalizations.of(context)
|
||||||
|
.selectionAppBarTitle(selectedListItems.length)),
|
||||||
|
actions: actions,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
get itemStreamListCellSize => thumbSize;
|
||||||
|
|
||||||
|
@protected
|
||||||
|
int get thumbSize {
|
||||||
|
switch (_thumbZoomLevel) {
|
||||||
|
case 1:
|
||||||
|
return 176;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
return 256;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
return 112;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _coverPreviewUrl;
|
||||||
|
var _thumbZoomLevel = 0;
|
||||||
|
}
|
301
lib/widget/dynamic_album_viewer.dart
Normal file
301
lib/widget/dynamic_album_viewer.dart
Normal file
|
@ -0,0 +1,301 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:nc_photos/account.dart';
|
||||||
|
import 'package:nc_photos/api/api_util.dart' as api_util;
|
||||||
|
import 'package:nc_photos/entity/album.dart';
|
||||||
|
import 'package:nc_photos/entity/album/cover_provider.dart';
|
||||||
|
import 'package:nc_photos/entity/file.dart';
|
||||||
|
import 'package:nc_photos/entity/file/data_source.dart';
|
||||||
|
import 'package:nc_photos/entity/file_util.dart' as file_util;
|
||||||
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
|
import 'package:nc_photos/k.dart' as k;
|
||||||
|
import 'package:nc_photos/list_extension.dart';
|
||||||
|
import 'package:nc_photos/snack_bar_manager.dart';
|
||||||
|
import 'package:nc_photos/theme.dart';
|
||||||
|
import 'package:nc_photos/use_case/populate_album.dart';
|
||||||
|
import 'package:nc_photos/use_case/remove.dart';
|
||||||
|
import 'package:nc_photos/use_case/update_album.dart';
|
||||||
|
import 'package:nc_photos/widget/album_viewer_mixin.dart';
|
||||||
|
import 'package:nc_photos/widget/photo_list_item.dart';
|
||||||
|
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
||||||
|
import 'package:nc_photos/widget/viewer.dart';
|
||||||
|
|
||||||
|
class DynamicAlbumViewerArguments {
|
||||||
|
DynamicAlbumViewerArguments(this.account, this.album);
|
||||||
|
|
||||||
|
final Account account;
|
||||||
|
final Album album;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DynamicAlbumViewer extends StatefulWidget {
|
||||||
|
static const routeName = "/dynamic-album-viewer";
|
||||||
|
|
||||||
|
DynamicAlbumViewer({
|
||||||
|
Key key,
|
||||||
|
@required this.account,
|
||||||
|
@required this.album,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
DynamicAlbumViewer.fromArgs(DynamicAlbumViewerArguments args, {Key key})
|
||||||
|
: this(
|
||||||
|
key: key,
|
||||||
|
account: args.account,
|
||||||
|
album: args.album,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
createState() => _DynamicAlbumViewerState();
|
||||||
|
|
||||||
|
final Account account;
|
||||||
|
final Album album;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DynamicAlbumViewerState extends State<DynamicAlbumViewer>
|
||||||
|
with
|
||||||
|
WidgetsBindingObserver,
|
||||||
|
SelectableItemStreamListMixin<DynamicAlbumViewer>,
|
||||||
|
AlbumViewerMixin<DynamicAlbumViewer> {
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
super.initState();
|
||||||
|
_initAlbum();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
build(BuildContext context) {
|
||||||
|
return AppTheme(
|
||||||
|
child: Scaffold(
|
||||||
|
body: Builder(builder: (context) => _buildContent(context)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initAlbum() {
|
||||||
|
PopulateAlbum()(widget.account, widget.album).then((items) {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_album = widget.album;
|
||||||
|
_transformItems(items);
|
||||||
|
final coverFile = initCover(widget.account, _backingFiles);
|
||||||
|
if (coverFile != null &&
|
||||||
|
_album.coverProvider is AlbumAutoCoverProvider) {
|
||||||
|
// cache the result for later use
|
||||||
|
if (coverFile.path !=
|
||||||
|
(_album.coverProvider as AlbumAutoCoverProvider)
|
||||||
|
.coverFile
|
||||||
|
?.path) {
|
||||||
|
_log.info("[_initAlbum] Updating album cover");
|
||||||
|
_album = _album.copyWith(
|
||||||
|
coverProvider: AlbumAutoCoverProvider(coverFile: coverFile));
|
||||||
|
UpdateAlbum(AlbumRepo(AlbumCachedDataSource()))(
|
||||||
|
widget.account, _album);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildContent(BuildContext context) {
|
||||||
|
if (_album == null) {
|
||||||
|
return CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
buildNormalAppBar(context, widget.account, widget.album),
|
||||||
|
const SliverToBoxAdapter(
|
||||||
|
child: const LinearProgressIndicator(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return buildItemStreamListOuter(
|
||||||
|
context,
|
||||||
|
child: Theme(
|
||||||
|
data: Theme.of(context).copyWith(
|
||||||
|
accentColor: AppTheme.getOverscrollIndicatorColor(context),
|
||||||
|
),
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
_buildAppBar(context),
|
||||||
|
SliverPadding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
sliver: buildItemStreamList(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAppBar(BuildContext context) {
|
||||||
|
if (isSelectionMode) {
|
||||||
|
return buildSelectionAppBar(context, [
|
||||||
|
PopupMenuButton(
|
||||||
|
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: _SelectionAppBarOption.delete,
|
||||||
|
child: Text(AppLocalizations.of(context).deleteSelectedTooltip),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onSelected: (option) {
|
||||||
|
if (option == _SelectionAppBarOption.delete) {
|
||||||
|
_onSelectionAppBarDeletePressed();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return buildNormalAppBar(context, widget.account, _album);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onItemTap(int index) {
|
||||||
|
Navigator.pushNamed(context, Viewer.routeName,
|
||||||
|
arguments: ViewerArguments(widget.account, _backingFiles, index));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSelectionAppBarDeletePressed() async {
|
||||||
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
|
content: Text(AppLocalizations.of(context)
|
||||||
|
.deleteSelectedProcessingNotification(selectedListItems.length)),
|
||||||
|
duration: k.snackBarDurationShort,
|
||||||
|
));
|
||||||
|
|
||||||
|
final selectedIndexes =
|
||||||
|
selectedListItems.map((e) => itemStreamListItems.indexOf(e)).toList();
|
||||||
|
final selectedFiles = _backingFiles.takeIndex(selectedIndexes).toList();
|
||||||
|
setState(() {
|
||||||
|
clearSelectedItems();
|
||||||
|
});
|
||||||
|
|
||||||
|
final fileRepo = FileRepo(FileCachedDataSource());
|
||||||
|
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||||
|
final failures = <File>[];
|
||||||
|
for (final f in selectedFiles) {
|
||||||
|
try {
|
||||||
|
await Remove(fileRepo, albumRepo).call(widget.account, f);
|
||||||
|
} catch (e, stacktrace) {
|
||||||
|
_log.shout(
|
||||||
|
"[_onSelectionAppBarDeletePressed] Failed while removing file" +
|
||||||
|
(kDebugMode ? ": ${f.path}" : ""),
|
||||||
|
e,
|
||||||
|
stacktrace);
|
||||||
|
failures.add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failures.isEmpty) {
|
||||||
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
|
content: Text(
|
||||||
|
AppLocalizations.of(context).deleteSelectedSuccessNotification),
|
||||||
|
duration: k.snackBarDurationNormal,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
|
content: Text(AppLocalizations.of(context)
|
||||||
|
.deleteSelectedFailureNotification(failures.length)),
|
||||||
|
duration: k.snackBarDurationNormal,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
final successes =
|
||||||
|
selectedFiles.where((element) => !failures.containsIdentical(element));
|
||||||
|
if (successes.isNotEmpty) {
|
||||||
|
setState(() {
|
||||||
|
_backingFiles
|
||||||
|
.removeWhere((element) => successes.containsIdentical(element));
|
||||||
|
_onBackingFilesUpdated();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _transformItems(List<AlbumItem> items) {
|
||||||
|
_backingFiles = items
|
||||||
|
.whereType<AlbumFileItem>()
|
||||||
|
.map((e) => e.file)
|
||||||
|
.where((element) => file_util.isSupportedFormat(element))
|
||||||
|
.sorted(compareFileDateTimeDescending);
|
||||||
|
_onBackingFilesUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onBackingFilesUpdated() {
|
||||||
|
itemStreamListItems = () sync* {
|
||||||
|
for (int i = 0; i < _backingFiles.length; ++i) {
|
||||||
|
final f = _backingFiles[i];
|
||||||
|
|
||||||
|
final previewUrl = api_util.getFilePreviewUrl(widget.account, f,
|
||||||
|
width: thumbSize, height: thumbSize);
|
||||||
|
if (file_util.isSupportedImageFormat(f)) {
|
||||||
|
yield _ImageListItem(
|
||||||
|
file: f,
|
||||||
|
account: widget.account,
|
||||||
|
previewUrl: previewUrl,
|
||||||
|
onTap: () => _onItemTap(i),
|
||||||
|
);
|
||||||
|
} else if (file_util.isSupportedVideoFormat(f)) {
|
||||||
|
yield _VideoListItem(
|
||||||
|
account: widget.account,
|
||||||
|
previewUrl: previewUrl,
|
||||||
|
onTap: () => _onItemTap(i),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
_log.shout(
|
||||||
|
"[_onBackingFilesUpdated] Unsupported file format: ${f.contentType}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
|
||||||
|
Album _album;
|
||||||
|
var _backingFiles = <File>[];
|
||||||
|
|
||||||
|
static final _log =
|
||||||
|
Logger("widget.dynamic_album_viewer._DynamicAlbumViewerState");
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ImageListItem extends SelectableItemStreamListItem {
|
||||||
|
_ImageListItem({
|
||||||
|
@required this.file,
|
||||||
|
@required this.account,
|
||||||
|
@required this.previewUrl,
|
||||||
|
VoidCallback onTap,
|
||||||
|
}) : super(onTap: onTap, isSelectable: true);
|
||||||
|
|
||||||
|
@override
|
||||||
|
buildWidget(BuildContext context) {
|
||||||
|
return PhotoListImage(
|
||||||
|
account: account,
|
||||||
|
previewUrl: previewUrl,
|
||||||
|
isGif: file.contentType == "image/gif",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final File file;
|
||||||
|
final Account account;
|
||||||
|
final String previewUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VideoListItem extends SelectableItemStreamListItem {
|
||||||
|
_VideoListItem({
|
||||||
|
@required this.account,
|
||||||
|
@required this.previewUrl,
|
||||||
|
VoidCallback onTap,
|
||||||
|
}) : super(onTap: onTap, isSelectable: true);
|
||||||
|
|
||||||
|
@override
|
||||||
|
buildWidget(BuildContext context) {
|
||||||
|
return PhotoListVideo(
|
||||||
|
account: account,
|
||||||
|
previewUrl: previewUrl,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Account account;
|
||||||
|
final String previewUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum _SelectionAppBarOption {
|
||||||
|
delete,
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ import 'package:nc_photos/use_case/remove.dart';
|
||||||
import 'package:nc_photos/widget/album_grid_item.dart';
|
import 'package:nc_photos/widget/album_grid_item.dart';
|
||||||
import 'package:nc_photos/widget/album_viewer.dart';
|
import 'package:nc_photos/widget/album_viewer.dart';
|
||||||
import 'package:nc_photos/widget/archive_viewer.dart';
|
import 'package:nc_photos/widget/archive_viewer.dart';
|
||||||
|
import 'package:nc_photos/widget/dynamic_album_viewer.dart';
|
||||||
import 'package:nc_photos/widget/home_app_bar.dart';
|
import 'package:nc_photos/widget/home_app_bar.dart';
|
||||||
import 'package:nc_photos/widget/new_album_dialog.dart';
|
import 'package:nc_photos/widget/new_album_dialog.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
@ -180,11 +181,15 @@ class _HomeAlbumsState extends State<HomeAlbums> {
|
||||||
if (item.album.provider is AlbumStaticProvider) {
|
if (item.album.provider is AlbumStaticProvider) {
|
||||||
subtitle = AppLocalizations.of(context)
|
subtitle = AppLocalizations.of(context)
|
||||||
.albumSize(AlbumStaticProvider.of(item.album).items.length);
|
.albumSize(AlbumStaticProvider.of(item.album).items.length);
|
||||||
|
} else if (item.album.provider is AlbumDirProvider) {
|
||||||
|
subtitle =
|
||||||
|
(item.album.provider as AlbumDirProvider).dirs.first.strippedPath;
|
||||||
}
|
}
|
||||||
return AlbumGridItem(
|
return AlbumGridItem(
|
||||||
cover: _buildAlbumCover(context, item.album),
|
cover: _buildAlbumCover(context, item.album),
|
||||||
title: item.album.name,
|
title: item.album.name,
|
||||||
subtitle: subtitle,
|
subtitle: subtitle,
|
||||||
|
isDynamic: item.album.provider is! AlbumStaticProvider,
|
||||||
isSelected: _selectedItems.contains(item),
|
isSelected: _selectedItems.contains(item),
|
||||||
onTap: () => _onItemTap(item),
|
onTap: () => _onItemTap(item),
|
||||||
onLongPress: _isSelectionMode ? null : () => _onItemLongPress(item),
|
onLongPress: _isSelectionMode ? null : () => _onItemLongPress(item),
|
||||||
|
@ -306,8 +311,13 @@ class _HomeAlbumsState extends State<HomeAlbums> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (item.album.provider is AlbumStaticProvider) {
|
||||||
Navigator.of(context).pushNamed(AlbumViewer.routeName,
|
Navigator.of(context).pushNamed(AlbumViewer.routeName,
|
||||||
arguments: AlbumViewerArguments(widget.account, item.album));
|
arguments: AlbumViewerArguments(widget.account, item.album));
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pushNamed(DynamicAlbumViewer.routeName,
|
||||||
|
arguments: DynamicAlbumViewerArguments(widget.account, item.album));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/widget/album_viewer.dart';
|
import 'package:nc_photos/widget/album_viewer.dart';
|
||||||
import 'package:nc_photos/widget/archive_viewer.dart';
|
import 'package:nc_photos/widget/archive_viewer.dart';
|
||||||
import 'package:nc_photos/widget/connect.dart';
|
import 'package:nc_photos/widget/connect.dart';
|
||||||
|
import 'package:nc_photos/widget/dynamic_album_viewer.dart';
|
||||||
import 'package:nc_photos/widget/home.dart';
|
import 'package:nc_photos/widget/home.dart';
|
||||||
import 'package:nc_photos/widget/root_picker.dart';
|
import 'package:nc_photos/widget/root_picker.dart';
|
||||||
import 'package:nc_photos/widget/settings.dart';
|
import 'package:nc_photos/widget/settings.dart';
|
||||||
|
@ -90,6 +91,7 @@ class _MyAppState extends State<MyApp> implements SnackBarHandler {
|
||||||
route ??= _handleAlbumViewerRoute(settings);
|
route ??= _handleAlbumViewerRoute(settings);
|
||||||
route ??= _handleSettingsRoute(settings);
|
route ??= _handleSettingsRoute(settings);
|
||||||
route ??= _handleArchiveViewerRoute(settings);
|
route ??= _handleArchiveViewerRoute(settings);
|
||||||
|
route ??= _handleDynamicAlbumViewerRoute(settings);
|
||||||
return route;
|
return route;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +214,22 @@ class _MyAppState extends State<MyApp> implements SnackBarHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Route<dynamic> _handleDynamicAlbumViewerRoute(RouteSettings settings) {
|
||||||
|
try {
|
||||||
|
if (settings.name == DynamicAlbumViewer.routeName &&
|
||||||
|
settings.arguments != null) {
|
||||||
|
final DynamicAlbumViewerArguments args = settings.arguments;
|
||||||
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => DynamicAlbumViewer.fromArgs(args),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_log.severe(
|
||||||
|
"[_handleDynamicAlbumViewerRoute] Failed while handling route", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||||
|
|
||||||
AppEventListener<ThemeChangedEvent> _themeChangedListener;
|
AppEventListener<ThemeChangedEvent> _themeChangedListener;
|
||||||
|
|
Loading…
Reference in a new issue