From 210e4f845f26ac4a1712ff26a75b1ca02656557d Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 9 Oct 2021 02:40:15 +0800 Subject: [PATCH] Support link share dirs in Sharing --- lib/bloc/list_sharing.dart | 18 ++++++++++++ lib/widget/shared_file_viewer.dart | 45 +++++++++++++++--------------- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/lib/bloc/list_sharing.dart b/lib/bloc/list_sharing.dart index fe5c5ac3..a73369cc 100644 --- a/lib/bloc/list_sharing.dart +++ b/lib/bloc/list_sharing.dart @@ -2,11 +2,13 @@ import 'package:bloc/bloc.dart'; import 'package:kiwi/kiwi.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/file.dart'; import 'package:nc_photos/entity/file_util.dart' as file_util; import 'package:nc_photos/entity/share.dart'; import 'package:nc_photos/entity/share/data_source.dart'; import 'package:nc_photos/event/event.dart'; +import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util; import 'package:nc_photos/use_case/find_file.dart'; class ListSharingItem { @@ -175,6 +177,22 @@ class ListSharingBloc extends Bloc { final shareRepo = ShareRepo(ShareRemoteDataSource()); final shares = await shareRepo.listAll(ev.account); final futures = shares.map((e) async { + // include link share dirs + if (e.itemType == ShareItemType.folder) { + final webdavPath = + "${api_util.getWebdavRootUrlRelative(ev.account)}/${e.path}"; + if (webdavPath.startsWith( + remote_storage_util.getRemoteLinkSharesDir(ev.account))) { + return ListSharingItem( + e, + File( + path: webdavPath, + isCollection: true, + ), + ); + } + } + if (!file_util.isSupportedMime(e.mimeType)) { return null; } diff --git a/lib/widget/shared_file_viewer.dart b/lib/widget/shared_file_viewer.dart index 1cfb70bd..bb5d6754 100644 --- a/lib/widget/shared_file_viewer.dart +++ b/lib/widget/shared_file_viewer.dart @@ -82,31 +82,32 @@ class _SharedFileViewerState extends State { title: Text(path.withoutExtension(widget.file.filename)), pinned: true, ), - SliverToBoxAdapter( - child: SizedBox( - height: 256, - child: FittedBox( - alignment: Alignment.center, - fit: BoxFit.cover, - clipBehavior: Clip.hardEdge, - child: CachedNetworkImage( - cacheManager: CoverCacheManager.inst, - imageUrl: previewUrl, - httpHeaders: { - "Authorization": - Api.getAuthorizationHeaderValue(widget.account), - }, - fadeInDuration: const Duration(), - filterQuality: FilterQuality.high, - errorWidget: (context, url, error) { - // just leave it empty - return Container(); - }, - imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, + if (widget.file.isCollection != true) + SliverToBoxAdapter( + child: SizedBox( + height: 256, + child: FittedBox( + alignment: Alignment.center, + fit: BoxFit.cover, + clipBehavior: Clip.hardEdge, + child: CachedNetworkImage( + cacheManager: CoverCacheManager.inst, + imageUrl: previewUrl, + httpHeaders: { + "Authorization": + Api.getAuthorizationHeaderValue(widget.account), + }, + fadeInDuration: const Duration(), + filterQuality: FilterQuality.high, + errorWidget: (context, url, error) { + // just leave it empty + return Container(); + }, + imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, + ), ), ), ), - ), SliverToBoxAdapter( child: Padding( padding: const EdgeInsets.all(16),