2022-12-19 09:36:27 +00:00
|
|
|
import 'package:fast_base58/fast_base58.dart';
|
2022-12-14 17:35:08 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-12-19 09:36:27 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2022-12-15 04:06:51 +00:00
|
|
|
import 'package:photos/core/configuration.dart';
|
2023-04-07 03:37:57 +00:00
|
|
|
import "package:photos/generated/l10n.dart";
|
2022-12-14 17:35:08 +00:00
|
|
|
import 'package:photos/models/collection.dart';
|
|
|
|
import 'package:photos/models/device_collection.dart';
|
2023-01-05 11:17:34 +00:00
|
|
|
import 'package:photos/models/file.dart';
|
2023-05-26 07:03:29 +00:00
|
|
|
import "package:photos/models/file_type.dart";
|
2023-01-05 04:04:34 +00:00
|
|
|
import 'package:photos/models/files_split.dart';
|
2022-12-14 17:35:08 +00:00
|
|
|
import 'package:photos/models/gallery_type.dart';
|
2023-05-25 05:51:56 +00:00
|
|
|
import "package:photos/models/metadata/common_keys.dart";
|
2022-12-15 04:06:51 +00:00
|
|
|
import 'package:photos/models/selected_files.dart';
|
2022-12-15 10:02:46 +00:00
|
|
|
import 'package:photos/services/collections_service.dart';
|
2022-12-15 11:24:51 +00:00
|
|
|
import 'package:photos/services/hidden_service.dart';
|
2022-12-14 17:35:08 +00:00
|
|
|
import 'package:photos/theme/ente_theme.dart';
|
2022-12-15 10:02:46 +00:00
|
|
|
import 'package:photos/ui/actions/collection/collection_file_actions.dart';
|
|
|
|
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
|
2023-06-06 09:57:17 +00:00
|
|
|
import 'package:photos/ui/collections/collection_action_sheet.dart';
|
2022-12-22 10:31:10 +00:00
|
|
|
import 'package:photos/ui/components/action_sheet_widget.dart';
|
2022-12-14 17:35:08 +00:00
|
|
|
import 'package:photos/ui/components/blur_menu_item_widget.dart';
|
|
|
|
import 'package:photos/ui/components/bottom_action_bar/expanded_menu_widget.dart';
|
2023-03-10 08:08:51 +00:00
|
|
|
import 'package:photos/ui/components/buttons/button_widget.dart';
|
2022-12-22 10:31:10 +00:00
|
|
|
import 'package:photos/ui/components/models/button_type.dart';
|
2022-12-22 17:13:14 +00:00
|
|
|
import 'package:photos/ui/sharing/manage_links_widget.dart';
|
2023-05-26 13:10:39 +00:00
|
|
|
import "package:photos/ui/tools/collage/collage_creator_page.dart";
|
2022-12-15 11:24:51 +00:00
|
|
|
import 'package:photos/utils/delete_file_util.dart';
|
|
|
|
import 'package:photos/utils/magic_util.dart';
|
2022-12-22 17:13:14 +00:00
|
|
|
import 'package:photos/utils/navigation_util.dart';
|
2022-12-19 09:36:27 +00:00
|
|
|
import 'package:photos/utils/toast_util.dart';
|
2022-12-14 17:35:08 +00:00
|
|
|
|
|
|
|
class FileSelectionActionWidget extends StatefulWidget {
|
|
|
|
final GalleryType type;
|
|
|
|
final Collection? collection;
|
|
|
|
final DeviceCollection? deviceCollection;
|
2022-12-15 04:06:51 +00:00
|
|
|
final SelectedFiles selectedFiles;
|
2022-12-14 17:35:08 +00:00
|
|
|
|
|
|
|
const FileSelectionActionWidget(
|
2022-12-15 04:06:51 +00:00
|
|
|
this.type,
|
|
|
|
this.selectedFiles, {
|
2022-12-14 17:35:08 +00:00
|
|
|
Key? key,
|
|
|
|
this.collection,
|
|
|
|
this.deviceCollection,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<FileSelectionActionWidget> createState() =>
|
|
|
|
_FileSelectionActionWidgetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FileSelectionActionWidgetState extends State<FileSelectionActionWidget> {
|
2022-12-15 04:06:51 +00:00
|
|
|
late int currentUserID;
|
2023-01-05 04:04:34 +00:00
|
|
|
late FilesSplit split;
|
2022-12-15 10:02:46 +00:00
|
|
|
late CollectionActions collectionActions;
|
2023-01-28 04:23:48 +00:00
|
|
|
late bool isCollectionOwner;
|
2022-12-15 04:06:51 +00:00
|
|
|
|
2023-02-22 07:38:31 +00:00
|
|
|
// _cachedCollectionForSharedLink is primarily used to avoid creating duplicate
|
2022-12-19 09:36:27 +00:00
|
|
|
// links if user keeps on creating Create link button after selecting
|
|
|
|
// few files. This link is reset on any selection changed;
|
|
|
|
Collection? _cachedCollectionForSharedLink;
|
|
|
|
|
2022-12-15 04:06:51 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
currentUserID = Configuration.instance.getUserID()!;
|
2023-01-05 11:17:34 +00:00
|
|
|
split = FilesSplit.split(<File>[], currentUserID);
|
2022-12-15 04:06:51 +00:00
|
|
|
widget.selectedFiles.addListener(_selectFileChangeListener);
|
2022-12-15 10:02:46 +00:00
|
|
|
collectionActions = CollectionActions(CollectionsService.instance);
|
2023-01-28 04:23:48 +00:00
|
|
|
isCollectionOwner =
|
|
|
|
widget.collection != null && widget.collection!.isOwner(currentUserID);
|
2022-12-15 04:06:51 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
widget.selectedFiles.removeListener(_selectFileChangeListener);
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _selectFileChangeListener() {
|
2022-12-19 09:36:27 +00:00
|
|
|
if (_cachedCollectionForSharedLink != null) {
|
|
|
|
_cachedCollectionForSharedLink = null;
|
|
|
|
}
|
2023-01-05 04:04:34 +00:00
|
|
|
split = FilesSplit.split(widget.selectedFiles.files, currentUserID);
|
2022-12-15 04:06:51 +00:00
|
|
|
if (mounted) {
|
|
|
|
setState(() => {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 17:35:08 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-12-15 04:06:51 +00:00
|
|
|
final bool showPrefix =
|
|
|
|
split.pendingUploads.isNotEmpty || split.ownedByOtherUsers.isNotEmpty;
|
|
|
|
final String suffix = showPrefix
|
|
|
|
? " (${split.ownedByCurrentUser.length})"
|
|
|
|
""
|
|
|
|
: "";
|
2023-01-28 04:23:48 +00:00
|
|
|
final int removeCount = split.ownedByCurrentUser.length +
|
|
|
|
(isCollectionOwner ? split.ownedByOtherUsers.length : 0);
|
|
|
|
final String removeSuffix = showPrefix
|
|
|
|
? " ($removeCount)"
|
|
|
|
""
|
|
|
|
: "";
|
2022-12-16 10:08:35 +00:00
|
|
|
final String suffixInPending = split.ownedByOtherUsers.isNotEmpty
|
2022-12-16 07:55:07 +00:00
|
|
|
? " (${split.ownedByCurrentUser.length + split.pendingUploads.length})"
|
|
|
|
""
|
|
|
|
: "";
|
2023-01-28 04:23:48 +00:00
|
|
|
|
2022-12-16 07:55:07 +00:00
|
|
|
final bool anyOwnedFiles =
|
|
|
|
split.pendingUploads.isNotEmpty || split.ownedByCurrentUser.isNotEmpty;
|
|
|
|
final bool anyUploadedFiles = split.ownedByCurrentUser.isNotEmpty;
|
2023-01-28 04:23:48 +00:00
|
|
|
final bool showRemoveOption = widget.type.showRemoveFromAlbum();
|
2022-12-14 17:35:08 +00:00
|
|
|
debugPrint('$runtimeType building $mounted');
|
|
|
|
final colorScheme = getEnteColorScheme(context);
|
|
|
|
final List<List<BlurMenuItemWidget>> items = [];
|
|
|
|
final List<BlurMenuItemWidget> firstList = [];
|
2022-12-19 09:36:27 +00:00
|
|
|
final List<BlurMenuItemWidget> secondList = [];
|
|
|
|
|
|
|
|
if (widget.type.showCreateLink()) {
|
2022-12-19 10:32:44 +00:00
|
|
|
if (_cachedCollectionForSharedLink != null && anyUploadedFiles) {
|
|
|
|
firstList.add(
|
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.copy_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).copyLink,
|
2022-12-19 10:32:44 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
|
|
|
onTap: anyUploadedFiles ? _copyLink : null,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
firstList.add(
|
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.link_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).shareLink + suffix,
|
2022-12-19 10:32:44 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
|
|
|
onTap: anyUploadedFiles ? _onCreatedSharedLinkClicked : null,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-12-19 09:36:27 +00:00
|
|
|
}
|
|
|
|
|
2023-05-26 07:03:29 +00:00
|
|
|
bool hasVideoFile = false;
|
|
|
|
for (final file in widget.selectedFiles.files) {
|
|
|
|
if (file.fileType == FileType.video) {
|
|
|
|
hasVideoFile = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasVideoFile &&
|
|
|
|
widget.selectedFiles.files.length >=
|
2023-05-26 15:27:43 +00:00
|
|
|
CollageCreatorPage.collageItemsMin &&
|
2023-05-26 07:03:29 +00:00
|
|
|
widget.selectedFiles.files.length <=
|
2023-05-26 15:27:43 +00:00
|
|
|
CollageCreatorPage.collageItemsMax) {
|
2023-05-26 07:03:29 +00:00
|
|
|
firstList.add(
|
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.grid_view_outlined,
|
|
|
|
labelText: S.of(context).createCollage,
|
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2023-05-26 07:11:25 +00:00
|
|
|
onTap: _onCreateCollageClicked,
|
2023-05-26 07:03:29 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-16 10:08:35 +00:00
|
|
|
final showUploadIcon = widget.type == GalleryType.localFolder &&
|
|
|
|
split.ownedByCurrentUser.isEmpty;
|
2022-12-14 17:35:08 +00:00
|
|
|
if (widget.type.showAddToAlbum()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-14 17:35:08 +00:00
|
|
|
BlurMenuItemWidget(
|
2022-12-16 10:08:35 +00:00
|
|
|
leadingIcon:
|
|
|
|
showUploadIcon ? Icons.cloud_upload_outlined : Icons.add_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: showUploadIcon
|
|
|
|
? S.of(context).addToEnte
|
|
|
|
: S.of(context).addToAlbum + suffixInPending,
|
2022-12-14 17:35:08 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2022-12-16 07:55:07 +00:00
|
|
|
onTap: anyOwnedFiles ? _addToAlbum : null,
|
2022-12-14 17:35:08 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (widget.type.showMoveToAlbum()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-14 17:35:08 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.arrow_forward_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).moveToAlbum + suffix,
|
2022-12-14 17:35:08 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2022-12-16 07:55:07 +00:00
|
|
|
onTap: anyUploadedFiles ? _moveFiles : null,
|
2022-12-14 17:35:08 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-16 09:20:12 +00:00
|
|
|
if (showRemoveOption) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-14 17:35:08 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.remove_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: "${S.of(context).removeFromAlbum}$removeSuffix",
|
2022-12-14 17:35:08 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2023-01-28 07:33:25 +00:00
|
|
|
onTap: removeCount > 0 ? _removeFilesFromAlbum : null,
|
2022-12-14 17:35:08 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget.type.showDeleteOption()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-14 17:35:08 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.delete_outline,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).delete + suffixInPending,
|
2022-12-14 17:35:08 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2022-12-16 07:55:07 +00:00
|
|
|
onTap: anyOwnedFiles ? _onDeleteClick : null,
|
2022-12-14 17:35:08 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget.type.showHideOption()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-14 17:35:08 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.visibility_off_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).hide + suffix,
|
2022-12-14 17:35:08 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2022-12-16 07:55:07 +00:00
|
|
|
onTap: anyUploadedFiles ? _onHideClick : null,
|
2022-12-15 11:24:51 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
} else if (widget.type.showUnHideOption()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-15 11:24:51 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.visibility_off_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).unhide + suffix,
|
2022-12-15 11:24:51 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
|
|
|
onTap: _onUnhideClick,
|
2022-12-14 17:35:08 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (widget.type.showArchiveOption()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-14 17:35:08 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.archive_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).archive + suffix,
|
2022-12-14 17:35:08 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2022-12-16 07:55:07 +00:00
|
|
|
onTap: anyUploadedFiles ? _onArchiveClick : null,
|
2022-12-15 11:24:51 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
} else if (widget.type.showUnArchiveOption()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-15 11:24:51 +00:00
|
|
|
BlurMenuItemWidget(
|
2022-12-16 07:27:53 +00:00
|
|
|
leadingIcon: Icons.unarchive,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).unarchive + suffix,
|
2022-12-15 11:24:51 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
|
|
|
onTap: _onUnArchiveClick,
|
2022-12-14 17:35:08 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget.type.showFavoriteOption()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-14 17:35:08 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.favorite_border_rounded,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).favorite + suffix,
|
2022-12-14 17:35:08 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
2022-12-16 07:55:07 +00:00
|
|
|
onTap: anyUploadedFiles ? _onFavoriteClick : null,
|
2022-12-14 17:35:08 +00:00
|
|
|
),
|
|
|
|
);
|
2022-12-15 11:24:51 +00:00
|
|
|
} else if (widget.type.showUnFavoriteOption()) {
|
2022-12-19 09:36:27 +00:00
|
|
|
secondList.add(
|
2022-12-15 11:24:51 +00:00
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.favorite,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).removeFromFavorite + suffix,
|
2022-12-15 11:24:51 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
|
|
|
onTap: _onUnFavoriteClick,
|
|
|
|
),
|
|
|
|
);
|
2022-12-14 17:35:08 +00:00
|
|
|
}
|
|
|
|
|
2023-01-27 13:56:29 +00:00
|
|
|
if (widget.type.showRestoreOption()) {
|
|
|
|
secondList.add(
|
|
|
|
BlurMenuItemWidget(
|
2023-03-06 06:36:11 +00:00
|
|
|
leadingIcon: Icons.restore_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).restore,
|
2023-01-27 13:56:29 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
|
|
|
onTap: _restore,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget.type.showPermanentlyDeleteOption()) {
|
|
|
|
secondList.add(
|
|
|
|
BlurMenuItemWidget(
|
|
|
|
leadingIcon: Icons.delete_forever_outlined,
|
2023-04-07 03:37:57 +00:00
|
|
|
labelText: S.of(context).permanentlyDelete,
|
2023-01-27 13:56:29 +00:00
|
|
|
menuItemColor: colorScheme.fillFaint,
|
|
|
|
onTap: _permanentlyDelete,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-19 09:36:27 +00:00
|
|
|
if (firstList.isNotEmpty || secondList.isNotEmpty) {
|
|
|
|
if (firstList.isNotEmpty) {
|
|
|
|
items.add(firstList);
|
|
|
|
}
|
|
|
|
items.add(secondList);
|
2022-12-16 08:07:23 +00:00
|
|
|
return ExpandedMenuWidget(
|
|
|
|
items: items,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// TODO: Return "Select All" here
|
|
|
|
return const SizedBox.shrink();
|
2022-12-14 17:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-15 10:02:46 +00:00
|
|
|
|
|
|
|
Future<void> _moveFiles() async {
|
|
|
|
if (split.pendingUploads.isNotEmpty || split.ownedByOtherUsers.isNotEmpty) {
|
|
|
|
widget.selectedFiles
|
|
|
|
.unSelectAll(split.pendingUploads.toSet(), skipNotify: true);
|
|
|
|
widget.selectedFiles
|
|
|
|
.unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true);
|
|
|
|
}
|
2023-02-14 10:13:34 +00:00
|
|
|
showCollectionActionSheet(
|
2023-01-23 12:56:07 +00:00
|
|
|
context,
|
2023-02-14 10:13:34 +00:00
|
|
|
selectedFiles: widget.selectedFiles,
|
2023-01-25 04:57:40 +00:00
|
|
|
actionType: CollectionActionType.moveFiles,
|
2023-01-23 12:56:07 +00:00
|
|
|
);
|
2022-12-15 10:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _addToAlbum() async {
|
|
|
|
if (split.ownedByOtherUsers.isNotEmpty) {
|
|
|
|
widget.selectedFiles
|
|
|
|
.unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true);
|
|
|
|
}
|
2023-02-14 10:13:34 +00:00
|
|
|
showCollectionActionSheet(context, selectedFiles: widget.selectedFiles);
|
2022-12-15 10:02:46 +00:00
|
|
|
}
|
|
|
|
|
2022-12-15 11:24:51 +00:00
|
|
|
Future<void> _onDeleteClick() async {
|
2023-01-06 07:24:00 +00:00
|
|
|
return showDeleteSheet(context, widget.selectedFiles);
|
2022-12-15 11:24:51 +00:00
|
|
|
}
|
|
|
|
|
2022-12-15 10:02:46 +00:00
|
|
|
Future<void> _removeFilesFromAlbum() async {
|
2023-01-28 04:23:48 +00:00
|
|
|
if (split.pendingUploads.isNotEmpty) {
|
2022-12-15 16:25:29 +00:00
|
|
|
widget.selectedFiles
|
|
|
|
.unSelectAll(split.pendingUploads.toSet(), skipNotify: true);
|
2023-01-28 04:23:48 +00:00
|
|
|
}
|
|
|
|
if (!isCollectionOwner && split.ownedByOtherUsers.isNotEmpty) {
|
2022-12-15 16:25:29 +00:00
|
|
|
widget.selectedFiles
|
|
|
|
.unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true);
|
|
|
|
}
|
2023-02-03 00:14:49 +00:00
|
|
|
final bool removingOthersFile =
|
|
|
|
isCollectionOwner && split.ownedByOtherUsers.isNotEmpty;
|
2023-01-05 11:17:34 +00:00
|
|
|
await collectionActions.showRemoveFromCollectionSheetV2(
|
2022-12-15 10:02:46 +00:00
|
|
|
context,
|
|
|
|
widget.collection!,
|
|
|
|
widget.selectedFiles,
|
2023-02-03 00:14:49 +00:00
|
|
|
removingOthersFile,
|
2022-12-15 10:02:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onFavoriteClick() async {
|
|
|
|
final result = await collectionActions.updateFavorites(
|
|
|
|
context,
|
|
|
|
split.ownedByCurrentUser,
|
|
|
|
true,
|
|
|
|
);
|
|
|
|
if (result) {
|
|
|
|
widget.selectedFiles.clearAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-15 11:24:51 +00:00
|
|
|
Future<void> _onUnFavoriteClick() async {
|
|
|
|
final result = await collectionActions.updateFavorites(
|
|
|
|
context,
|
|
|
|
split.ownedByCurrentUser,
|
|
|
|
false,
|
|
|
|
);
|
|
|
|
if (result) {
|
|
|
|
widget.selectedFiles.clearAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onArchiveClick() async {
|
|
|
|
await changeVisibility(
|
|
|
|
context,
|
|
|
|
split.ownedByCurrentUser,
|
2023-05-25 05:51:56 +00:00
|
|
|
archiveVisibility,
|
2022-12-15 11:24:51 +00:00
|
|
|
);
|
|
|
|
widget.selectedFiles.clearAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onUnArchiveClick() async {
|
|
|
|
await changeVisibility(
|
|
|
|
context,
|
|
|
|
split.ownedByCurrentUser,
|
2023-05-25 05:51:56 +00:00
|
|
|
visibleVisibility,
|
2022-12-15 11:24:51 +00:00
|
|
|
);
|
|
|
|
widget.selectedFiles.clearAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onHideClick() async {
|
|
|
|
await CollectionsService.instance.hideFiles(
|
|
|
|
context,
|
|
|
|
split.ownedByCurrentUser,
|
|
|
|
);
|
|
|
|
widget.selectedFiles.clearAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _onUnhideClick() async {
|
|
|
|
if (split.pendingUploads.isNotEmpty || split.ownedByOtherUsers.isNotEmpty) {
|
|
|
|
widget.selectedFiles
|
|
|
|
.unSelectAll(split.pendingUploads.toSet(), skipNotify: true);
|
|
|
|
widget.selectedFiles
|
|
|
|
.unSelectAll(split.ownedByOtherUsers.toSet(), skipNotify: true);
|
|
|
|
}
|
2023-02-14 10:13:34 +00:00
|
|
|
showCollectionActionSheet(
|
2023-01-23 12:56:07 +00:00
|
|
|
context,
|
2023-02-14 10:13:34 +00:00
|
|
|
selectedFiles: widget.selectedFiles,
|
2023-01-25 04:57:40 +00:00
|
|
|
actionType: CollectionActionType.unHide,
|
2023-01-23 12:56:07 +00:00
|
|
|
);
|
2022-12-15 11:24:51 +00:00
|
|
|
}
|
|
|
|
|
2023-05-26 07:11:25 +00:00
|
|
|
Future<void> _onCreateCollageClicked() async {
|
2023-05-26 19:37:06 +00:00
|
|
|
final bool? result = await routeToPage(
|
2023-05-26 07:11:25 +00:00
|
|
|
context,
|
2023-06-05 06:10:40 +00:00
|
|
|
CollageCreatorPage(widget.selectedFiles.files.toList()),
|
2023-05-26 07:11:25 +00:00
|
|
|
);
|
2023-05-27 06:01:35 +00:00
|
|
|
if (result != null && result) {
|
2023-05-26 19:37:06 +00:00
|
|
|
widget.selectedFiles.clearAll();
|
|
|
|
}
|
2023-05-26 07:11:25 +00:00
|
|
|
}
|
|
|
|
|
2022-12-19 09:36:27 +00:00
|
|
|
Future<void> _onCreatedSharedLinkClicked() async {
|
|
|
|
if (split.ownedByCurrentUser.isEmpty) {
|
2023-04-07 03:37:57 +00:00
|
|
|
showShortToast(
|
2023-04-18 09:05:21 +00:00
|
|
|
context,
|
|
|
|
S.of(context).canOnlyCreateLinkForFilesOwnedByYou,
|
|
|
|
);
|
2022-12-19 09:36:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
_cachedCollectionForSharedLink ??= await collectionActions
|
|
|
|
.createSharedCollectionLink(context, split.ownedByCurrentUser);
|
2022-12-22 10:31:10 +00:00
|
|
|
final actionResult = await showActionSheet(
|
|
|
|
context: context,
|
|
|
|
buttons: [
|
2023-04-07 03:37:57 +00:00
|
|
|
ButtonWidget(
|
|
|
|
labelText: S.of(context).copyLink,
|
2022-12-22 10:31:10 +00:00
|
|
|
buttonType: ButtonType.neutral,
|
|
|
|
buttonSize: ButtonSize.large,
|
|
|
|
shouldStickToDarkTheme: true,
|
|
|
|
buttonAction: ButtonAction.first,
|
|
|
|
isInAlert: true,
|
|
|
|
),
|
2023-04-07 03:37:57 +00:00
|
|
|
ButtonWidget(
|
|
|
|
labelText: S.of(context).manageLink,
|
2022-12-22 10:31:10 +00:00
|
|
|
buttonType: ButtonType.secondary,
|
|
|
|
buttonSize: ButtonSize.large,
|
|
|
|
buttonAction: ButtonAction.second,
|
|
|
|
shouldStickToDarkTheme: true,
|
|
|
|
isInAlert: true,
|
2022-12-22 17:13:14 +00:00
|
|
|
),
|
2023-04-07 03:37:57 +00:00
|
|
|
ButtonWidget(
|
|
|
|
labelText: S.of(context).done,
|
2022-12-22 17:13:14 +00:00
|
|
|
buttonType: ButtonType.secondary,
|
|
|
|
buttonSize: ButtonSize.large,
|
|
|
|
buttonAction: ButtonAction.third,
|
|
|
|
shouldStickToDarkTheme: true,
|
|
|
|
isInAlert: true,
|
2022-12-22 10:31:10 +00:00
|
|
|
)
|
|
|
|
],
|
2023-04-07 03:37:57 +00:00
|
|
|
title: S.of(context).publicLinkCreated,
|
|
|
|
body: S.of(context).youCanManageYourLinksInTheShareTab,
|
2022-12-22 10:31:10 +00:00
|
|
|
actionSheetType: ActionSheetType.defaultActionSheet,
|
|
|
|
);
|
2023-02-09 13:18:01 +00:00
|
|
|
if (actionResult?.action != null) {
|
|
|
|
if (actionResult!.action == ButtonAction.first) {
|
|
|
|
await _copyLink();
|
|
|
|
}
|
|
|
|
if (actionResult.action == ButtonAction.second) {
|
|
|
|
routeToPage(
|
|
|
|
context,
|
|
|
|
ManageSharedLinkWidget(collection: _cachedCollectionForSharedLink),
|
|
|
|
);
|
|
|
|
}
|
2022-12-22 17:13:14 +00:00
|
|
|
}
|
2023-02-09 13:18:01 +00:00
|
|
|
|
2022-12-19 10:32:44 +00:00
|
|
|
if (mounted) {
|
|
|
|
setState(() => {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _copyLink() async {
|
2022-12-19 09:36:27 +00:00
|
|
|
if (_cachedCollectionForSharedLink != null) {
|
|
|
|
final String collectionKey = Base58Encode(
|
|
|
|
CollectionsService.instance
|
|
|
|
.getCollectionKey(_cachedCollectionForSharedLink!.id),
|
|
|
|
);
|
|
|
|
final String url =
|
|
|
|
"${_cachedCollectionForSharedLink!.publicURLs?.first?.url}#$collectionKey";
|
|
|
|
await Clipboard.setData(ClipboardData(text: url));
|
2023-04-07 03:37:57 +00:00
|
|
|
showShortToast(context, S.of(context).linkCopiedToClipboard);
|
2022-12-19 09:36:27 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-27 13:56:29 +00:00
|
|
|
|
|
|
|
void _restore() {
|
2023-02-14 10:13:34 +00:00
|
|
|
showCollectionActionSheet(
|
2023-01-27 13:56:29 +00:00
|
|
|
context,
|
2023-02-14 10:13:34 +00:00
|
|
|
selectedFiles: widget.selectedFiles,
|
2023-01-27 13:56:29 +00:00
|
|
|
actionType: CollectionActionType.restoreFiles,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _permanentlyDelete() async {
|
|
|
|
if (await deleteFromTrash(
|
|
|
|
context,
|
2023-06-05 06:10:40 +00:00
|
|
|
widget.selectedFiles.files.toList(),
|
2023-01-27 13:56:29 +00:00
|
|
|
)) {
|
|
|
|
widget.selectedFiles.clearAll();
|
|
|
|
}
|
|
|
|
}
|
2022-12-14 17:35:08 +00:00
|
|
|
}
|