mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Archive items to hide in photos list
This commit is contained in:
parent
954d8a869d
commit
d2768e6066
5 changed files with 545 additions and 1 deletions
|
@ -97,6 +97,58 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"archiveSelectedMenuLabel": "Archive selected",
|
||||
"@archiveSelectedMenuLabel": {
|
||||
"description": "Archive selected items"
|
||||
},
|
||||
"archiveSelectedProcessingNotification": "{count, plural, =1{Archiving 1 item} other{Archiving {count} items}}",
|
||||
"@archiveSelectedProcessingNotification": {
|
||||
"description": "Archiving the selected items",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"example": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"archiveSelectedSuccessNotification": "All items archived successfully",
|
||||
"@archiveSelectedSuccessNotification": {
|
||||
"description": "Archived all selected items successfully"
|
||||
},
|
||||
"archiveSelectedFailureNotification": "{count, plural, =1{Failed archiving 1 item} other{Failed archiving {count} items}}",
|
||||
"@archiveSelectedFailureNotification": {
|
||||
"description": "Cannot archive some of the selected items",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"example": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"unarchiveSelectedTooltip": "Unarchive selected",
|
||||
"@unarchiveSelectedTooltip": {
|
||||
"description": "Unarchive selected items"
|
||||
},
|
||||
"unarchiveSelectedProcessingNotification": "{count, plural, =1{Unarchiving 1 item} other{Unarchiving {count} items}}",
|
||||
"@unarchiveSelectedProcessingNotification": {
|
||||
"description": "Unarchiving selected items",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"example": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"unarchiveSelectedSuccessNotification": "All items unarchived successfully",
|
||||
"@unarchiveSelectedSuccessNotification": {
|
||||
"description": "Unarchived all selected items successfully"
|
||||
},
|
||||
"unarchiveSelectedFailureNotification": "{count, plural, =1{Failed unarchiving 1 item} other{Failed unarchiving {count} items}}",
|
||||
"@unarchiveSelectedFailureNotification": {
|
||||
"description": "Cannot unarchive some of the selected items",
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"example": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"deleteTooltip": "Delete",
|
||||
"@deleteTooltip": {
|
||||
"description": "Tooltip for the delete button"
|
||||
|
@ -160,6 +212,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"albumArchiveLabel": "Archive",
|
||||
"@albumArchiveLabel": {
|
||||
"description": "Archive"
|
||||
},
|
||||
"connectingToServer": "Connecting to\n{server}",
|
||||
"@connectingToServer": {
|
||||
"description": "Inform user that the app is connecting to a server",
|
||||
|
|
371
lib/widget/archive_viewer.dart
Normal file
371
lib/widget/archive_viewer.dart
Normal file
|
@ -0,0 +1,371 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.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/bloc/scan_dir.dart';
|
||||
import 'package:nc_photos/entity/album.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/exception_util.dart' as exception_util;
|
||||
import 'package:nc_photos/iterable_extension.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/pref.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/use_case/update_property.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/viewer.dart';
|
||||
|
||||
class ArchiveViewerArguments {
|
||||
ArchiveViewerArguments(this.account);
|
||||
|
||||
final Account account;
|
||||
}
|
||||
|
||||
class ArchiveViewer extends StatefulWidget {
|
||||
static const routeName = "/archive-viewer";
|
||||
|
||||
ArchiveViewer({
|
||||
Key key,
|
||||
@required this.account,
|
||||
}) : super(key: key);
|
||||
|
||||
ArchiveViewer.fromArgs(ArchiveViewerArguments args, {Key key})
|
||||
: this(
|
||||
key: key,
|
||||
account: args.account,
|
||||
);
|
||||
|
||||
@override
|
||||
createState() => _ArchiveViewerState();
|
||||
|
||||
final Account account;
|
||||
}
|
||||
|
||||
class _ArchiveViewerState extends State<ArchiveViewer>
|
||||
with WidgetsBindingObserver, SelectableItemStreamListMixin<ArchiveViewer> {
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
_initBloc();
|
||||
_thumbZoomLevel = Pref.inst().getAlbumViewerZoomLevel(0);
|
||||
}
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
return AppTheme(
|
||||
child: Scaffold(
|
||||
body: BlocListener<ScanDirBloc, ScanDirBlocState>(
|
||||
bloc: _bloc,
|
||||
listener: (context, state) => _onStateChange(context, state),
|
||||
child: BlocBuilder<ScanDirBloc, ScanDirBlocState>(
|
||||
bloc: _bloc,
|
||||
builder: (context, state) => _buildContent(context, state),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
get itemStreamListCellSize => _thumbSize;
|
||||
|
||||
void _initBloc() {
|
||||
_bloc = ScanDirBloc.of(widget.account);
|
||||
if (_bloc.state is ScanDirBlocInit) {
|
||||
_log.info("[_initBloc] Initialize bloc");
|
||||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
_onStateChange(context, _bloc.state);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context, ScanDirBlocState state) {
|
||||
return Stack(
|
||||
children: [
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state is ScanDirBlocLoading)
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: const LinearProgressIndicator(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context) {
|
||||
if (isSelectionMode) {
|
||||
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(
|
||||
icon: const Icon(Icons.unarchive),
|
||||
tooltip: AppLocalizations.of(context).unarchiveSelectedTooltip,
|
||||
onPressed: () {
|
||||
_onSelectionAppBarUnarchivePressed();
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNormalAppBar(BuildContext context) {
|
||||
return SliverAppBar(
|
||||
title: Text(AppLocalizations.of(context).albumArchiveLabel),
|
||||
floating: true,
|
||||
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 _onStateChange(BuildContext context, ScanDirBlocState state) {
|
||||
if (state is ScanDirBlocInit) {
|
||||
itemStreamListItems = [];
|
||||
} else if (state is ScanDirBlocSuccess || state is ScanDirBlocLoading) {
|
||||
_transformItems(state.files);
|
||||
} else if (state is ScanDirBlocFailure) {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(exception_util.toUserString(state.exception, context)),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
} else if (state is ScanDirBlocInconsistent) {
|
||||
_reqQuery();
|
||||
}
|
||||
}
|
||||
|
||||
void _onItemTap(int index) {
|
||||
Navigator.pushNamed(context, Viewer.routeName,
|
||||
arguments: ViewerArguments(widget.account, _backingFiles, index));
|
||||
}
|
||||
|
||||
Future<void> _onSelectionAppBarUnarchivePressed() async {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(AppLocalizations.of(context)
|
||||
.unarchiveSelectedProcessingNotification(selectedListItems.length)),
|
||||
duration: k.snackBarDurationShort,
|
||||
));
|
||||
final selectedFiles = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
.map((e) => e.file)
|
||||
.toList();
|
||||
setState(() {
|
||||
clearSelectedItems();
|
||||
});
|
||||
final fileRepo = FileRepo(FileCachedDataSource());
|
||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||
final failures = <File>[];
|
||||
for (final f in selectedFiles) {
|
||||
try {
|
||||
await UpdateProperty(fileRepo, albumRepo)
|
||||
.updateIsArchived(widget.account, f, false);
|
||||
} catch (e, stacktrace) {
|
||||
_log.shout(
|
||||
"[_onSelectionAppBarUnarchivePressed] Failed while unarchiving file" +
|
||||
(kDebugMode ? ": ${f.path}" : ""),
|
||||
e,
|
||||
stacktrace);
|
||||
failures.add(f);
|
||||
}
|
||||
}
|
||||
if (failures.isEmpty) {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).unarchiveSelectedSuccessNotification),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
} else {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(AppLocalizations.of(context)
|
||||
.unarchiveSelectedFailureNotification(failures.length)),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void _transformItems(List<File> files) {
|
||||
_backingFiles = files
|
||||
.where((element) =>
|
||||
file_util.isSupportedFormat(element) && element.isArchived == true)
|
||||
.sorted(compareFileDateTimeDescending);
|
||||
|
||||
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(
|
||||
file: f,
|
||||
account: widget.account,
|
||||
previewUrl: previewUrl,
|
||||
onTap: () => _onItemTap(i),
|
||||
);
|
||||
} else {
|
||||
_log.shout(
|
||||
"[_transformItems] Unsupported file format: ${f.contentType}");
|
||||
}
|
||||
}
|
||||
}();
|
||||
}
|
||||
|
||||
void _reqQuery() {
|
||||
_bloc.add(ScanDirBlocQuery(
|
||||
widget.account,
|
||||
widget.account.roots
|
||||
.map((e) => File(
|
||||
path:
|
||||
"${api_util.getWebdavRootUrlRelative(widget.account)}/$e"))
|
||||
.toList()));
|
||||
}
|
||||
|
||||
int get _thumbSize {
|
||||
switch (_thumbZoomLevel) {
|
||||
case 1:
|
||||
return 176;
|
||||
|
||||
case 2:
|
||||
return 256;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
return 112;
|
||||
}
|
||||
}
|
||||
|
||||
ScanDirBloc _bloc;
|
||||
|
||||
var _backingFiles = <File>[];
|
||||
|
||||
var _thumbZoomLevel = 0;
|
||||
|
||||
static final _log = Logger("widget.archive_viewer._ArchiveViewerState");
|
||||
}
|
||||
|
||||
abstract class _FileListItem extends SelectableItemStreamListItem {
|
||||
_FileListItem({
|
||||
@required this.file,
|
||||
VoidCallback onTap,
|
||||
}) : super(onTap: onTap, isSelectable: true);
|
||||
|
||||
@override
|
||||
operator ==(Object other) {
|
||||
return other is _FileListItem && file.path == other.file.path;
|
||||
}
|
||||
|
||||
@override
|
||||
get hashCode => file.path.hashCode;
|
||||
|
||||
final File file;
|
||||
}
|
||||
|
||||
class _ImageListItem extends _FileListItem {
|
||||
_ImageListItem({
|
||||
@required File file,
|
||||
@required this.account,
|
||||
@required this.previewUrl,
|
||||
VoidCallback onTap,
|
||||
}) : super(file: file, onTap: onTap);
|
||||
|
||||
@override
|
||||
buildWidget(BuildContext context) {
|
||||
return PhotoListImage(
|
||||
account: account,
|
||||
previewUrl: previewUrl,
|
||||
);
|
||||
}
|
||||
|
||||
final Account account;
|
||||
final String previewUrl;
|
||||
}
|
||||
|
||||
class _VideoListItem extends _FileListItem {
|
||||
_VideoListItem({
|
||||
@required File file,
|
||||
@required this.account,
|
||||
@required this.previewUrl,
|
||||
VoidCallback onTap,
|
||||
}) : super(file: file, onTap: onTap);
|
||||
|
||||
@override
|
||||
buildWidget(BuildContext context) {
|
||||
return PhotoListVideo(
|
||||
account: account,
|
||||
previewUrl: previewUrl,
|
||||
);
|
||||
}
|
||||
|
||||
final Account account;
|
||||
final String previewUrl;
|
||||
}
|
|
@ -23,6 +23,7 @@ import 'package:nc_photos/theme.dart';
|
|||
import 'package:nc_photos/use_case/remove.dart';
|
||||
import 'package:nc_photos/widget/album_grid_item.dart';
|
||||
import 'package:nc_photos/widget/album_viewer.dart';
|
||||
import 'package:nc_photos/widget/archive_viewer.dart';
|
||||
import 'package:nc_photos/widget/home_app_bar.dart';
|
||||
import 'package:nc_photos/widget/new_album_dialog.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
@ -98,7 +99,7 @@ class _HomeAlbumsState extends State<HomeAlbums> {
|
|||
sliver: SliverStaggeredGrid.extentBuilder(
|
||||
maxCrossAxisExtent: 256,
|
||||
mainAxisSpacing: 8,
|
||||
itemCount: _items.length + (_isSelectionMode ? 0 : 1),
|
||||
itemCount: _items.length + (_isSelectionMode ? 0 : 2),
|
||||
itemBuilder: _buildItem,
|
||||
staggeredTileBuilder: (index) {
|
||||
return const StaggeredTile.count(1, 1);
|
||||
|
@ -165,6 +166,8 @@ class _HomeAlbumsState extends State<HomeAlbums> {
|
|||
Widget _buildItem(BuildContext context, int index) {
|
||||
if (index < _items.length) {
|
||||
return _buildAlbumItem(context, index);
|
||||
} else if (index == _items.length) {
|
||||
return _buildArchiveItem(context);
|
||||
} else {
|
||||
return _buildNewAlbumItem(context);
|
||||
}
|
||||
|
@ -231,6 +234,28 @@ class _HomeAlbumsState extends State<HomeAlbums> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget _buildArchiveItem(BuildContext context) {
|
||||
return AlbumGridItem(
|
||||
cover: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
color: AppTheme.getListItemBackgroundColor(context),
|
||||
constraints: const BoxConstraints.expand(),
|
||||
child: Icon(
|
||||
Icons.archive,
|
||||
color: Colors.white.withOpacity(.8),
|
||||
size: 96,
|
||||
),
|
||||
),
|
||||
),
|
||||
title: AppLocalizations.of(context).albumArchiveLabel,
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(ArchiveViewer.routeName,
|
||||
arguments: ArchiveViewerArguments(widget.account));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNewAlbumItem(BuildContext context) {
|
||||
return AlbumGridItem(
|
||||
cover: ClipRRect(
|
||||
|
|
|
@ -25,6 +25,7 @@ import 'package:nc_photos/snack_bar_manager.dart';
|
|||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/use_case/remove.dart';
|
||||
import 'package:nc_photos/use_case/update_album.dart';
|
||||
import 'package:nc_photos/use_case/update_property.dart';
|
||||
import 'package:nc_photos/widget/album_picker_dialog.dart';
|
||||
import 'package:nc_photos/widget/home_app_bar.dart';
|
||||
import 'package:nc_photos/widget/measure.dart';
|
||||
|
@ -177,6 +178,19 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
_onSelectionAppBarDeletePressed(context);
|
||||
},
|
||||
),
|
||||
PopupMenuButton(
|
||||
tooltip: MaterialLocalizations.of(context).moreButtonTooltip,
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: _SelectionAppBarMenuOption.archive,
|
||||
child:
|
||||
Text(AppLocalizations.of(context).archiveSelectedMenuLabel),
|
||||
),
|
||||
],
|
||||
onSelected: (option) {
|
||||
_onSelectionAppBarMenuSelected(context, option);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -367,6 +381,63 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
}
|
||||
}
|
||||
|
||||
void _onSelectionAppBarMenuSelected(
|
||||
BuildContext context, _SelectionAppBarMenuOption option) {
|
||||
switch (option) {
|
||||
case _SelectionAppBarMenuOption.archive:
|
||||
_onSelectionAppBarArchivePressed(context);
|
||||
break;
|
||||
|
||||
default:
|
||||
_log.shout("[_onSelectionAppBarMenuSelected] Unknown option: $option");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onSelectionAppBarArchivePressed(BuildContext context) async {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(AppLocalizations.of(context)
|
||||
.archiveSelectedProcessingNotification(selectedListItems.length)),
|
||||
duration: k.snackBarDurationShort,
|
||||
));
|
||||
final selectedFiles = selectedListItems
|
||||
.whereType<_FileListItem>()
|
||||
.map((e) => e.file)
|
||||
.toList();
|
||||
setState(() {
|
||||
clearSelectedItems();
|
||||
});
|
||||
final fileRepo = FileRepo(FileCachedDataSource());
|
||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||
final failures = <File>[];
|
||||
for (final f in selectedFiles) {
|
||||
try {
|
||||
await UpdateProperty(fileRepo, albumRepo)
|
||||
.updateIsArchived(widget.account, f, true);
|
||||
} catch (e, stacktrace) {
|
||||
_log.shout(
|
||||
"[_onSelectionAppBarArchivePressed] Failed while archiving file" +
|
||||
(kDebugMode ? ": ${f.path}" : ""),
|
||||
e,
|
||||
stacktrace);
|
||||
failures.add(f);
|
||||
}
|
||||
}
|
||||
if (failures.isEmpty) {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).archiveSelectedSuccessNotification),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
} else {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(AppLocalizations.of(context)
|
||||
.archiveSelectedFailureNotification(failures.length)),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void _onRefreshSelected() {
|
||||
_hasFiredMetadataTask.value = false;
|
||||
_reqRefresh();
|
||||
|
@ -596,6 +667,10 @@ class _VideoListItem extends _FileListItem {
|
|||
final String previewUrl;
|
||||
}
|
||||
|
||||
enum _SelectionAppBarMenuOption {
|
||||
archive,
|
||||
}
|
||||
|
||||
extension on DateTime {
|
||||
String toDailySubtitleString() {
|
||||
final format = DateFormat(DateFormat.YEAR_MONTH_DAY);
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:nc_photos/pref.dart';
|
|||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/widget/album_viewer.dart';
|
||||
import 'package:nc_photos/widget/archive_viewer.dart';
|
||||
import 'package:nc_photos/widget/connect.dart';
|
||||
import 'package:nc_photos/widget/home.dart';
|
||||
import 'package:nc_photos/widget/root_picker.dart';
|
||||
|
@ -83,6 +84,7 @@ class _MyAppState extends State<MyApp> implements SnackBarHandler {
|
|||
route ??= _handleRootPickerRoute(settings);
|
||||
route ??= _handleAlbumViewerRoute(settings);
|
||||
route ??= _handleSettingsRoute(settings);
|
||||
route ??= _handleArchiveViewerRoute(settings);
|
||||
return route;
|
||||
}
|
||||
|
||||
|
@ -186,6 +188,21 @@ class _MyAppState extends State<MyApp> implements SnackBarHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
Route<dynamic> _handleArchiveViewerRoute(RouteSettings settings) {
|
||||
try {
|
||||
if (settings.name == ArchiveViewer.routeName &&
|
||||
settings.arguments != null) {
|
||||
final ArchiveViewerArguments args = settings.arguments;
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => ArchiveViewer.fromArgs(args),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
_log.severe("[_handleArchiveViewerRoute] Failed while handling route", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
|
||||
AppEventListener<ThemeChangedEvent> _themeChangedListener;
|
||||
|
|
Loading…
Reference in a new issue