ente/lib/ui/viewer/gallery/gallery_app_bar_widget.dart

775 lines
23 KiB
Dart
Raw Normal View History

2020-05-05 12:56:24 +00:00
import 'dart:async';
import 'dart:io';
2023-06-30 06:08:53 +00:00
import 'dart:math' as math;
2023-06-30 06:08:53 +00:00
import "package:flutter/cupertino.dart";
2020-04-18 18:46:38 +00:00
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart';
2020-11-15 07:19:44 +00:00
import 'package:photos/core/event_bus.dart';
import "package:photos/db/files_db.dart";
2021-02-02 16:35:38 +00:00
import 'package:photos/events/subscription_purchased_event.dart';
2023-04-07 05:06:43 +00:00
import "package:photos/generated/l10n.dart";
import 'package:photos/models/backup_status.dart';
2020-10-29 12:56:30 +00:00
import 'package:photos/models/collection.dart';
import 'package:photos/models/device_collection.dart';
2022-07-03 10:09:01 +00:00
import 'package:photos/models/gallery_type.dart';
import "package:photos/models/metadata/common_keys.dart";
import 'package:photos/models/selected_files.dart';
2020-10-13 05:22:20 +00:00
import 'package:photos/services/collections_service.dart';
import 'package:photos/services/sync_service.dart';
import 'package:photos/services/update_service.dart';
import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
import 'package:photos/ui/components/action_sheet_widget.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
import 'package:photos/ui/components/models/button_type.dart';
2023-06-15 12:45:26 +00:00
import "package:photos/ui/map/enable_map.dart";
import "package:photos/ui/map/map_screen.dart";
import 'package:photos/ui/sharing/album_participants_page.dart';
2023-08-04 08:35:27 +00:00
import "package:photos/ui/sharing/manage_links_widget.dart";
2022-11-20 11:55:12 +00:00
import 'package:photos/ui/sharing/share_collection_page.dart';
import 'package:photos/ui/tools/free_space_page.dart';
2023-06-27 09:15:25 +00:00
import "package:photos/ui/viewer/gallery/hooks/add_photos_sheet.dart";
import 'package:photos/ui/viewer/gallery/hooks/pick_cover_photo.dart';
import 'package:photos/utils/data_util.dart';
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/magic_util.dart';
import 'package:photos/utils/navigation_util.dart';
2022-09-13 06:44:10 +00:00
import 'package:photos/utils/toast_util.dart';
2020-04-18 18:46:38 +00:00
class GalleryAppBarWidget extends StatefulWidget {
final GalleryType type;
final String? title;
final SelectedFiles selectedFiles;
final DeviceCollection? deviceCollection;
final Collection? collection;
2020-04-18 18:46:38 +00:00
const GalleryAppBarWidget(
this.type,
this.title,
2020-10-29 12:56:30 +00:00
this.selectedFiles, {
Key? key,
this.deviceCollection,
2020-10-29 12:56:30 +00:00
this.collection,
2022-07-03 07:47:15 +00:00
}) : super(key: key);
2020-04-18 18:46:38 +00:00
@override
2022-07-03 09:45:00 +00:00
State<GalleryAppBarWidget> createState() => _GalleryAppBarWidgetState();
2020-04-18 18:46:38 +00:00
}
enum AlbumPopupAction {
rename,
delete,
map,
ownedArchive,
sharedArchive,
ownedHide,
sort,
leave,
2023-06-22 10:10:21 +00:00
freeUpSpace,
setCover,
2023-06-27 08:34:58 +00:00
addPhotos,
2023-06-30 04:31:15 +00:00
pinAlbum,
removeLink,
}
2020-04-18 18:46:38 +00:00
class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
final _logger = Logger("GalleryAppBar");
late StreamSubscription _userAuthEventSubscription;
late Function() _selectedFilesListener;
String? _appBarTitle;
late CollectionActions collectionActions;
final GlobalKey shareButtonKey = GlobalKey();
bool isQuickLink = false;
late GalleryType galleryType;
2022-10-11 01:35:09 +00:00
2020-04-30 15:09:41 +00:00
@override
void initState() {
super.initState();
2021-01-08 16:40:03 +00:00
_selectedFilesListener = () {
setState(() {});
2021-01-08 16:40:03 +00:00
};
collectionActions = CollectionActions(CollectionsService.instance);
2021-01-08 16:40:03 +00:00
widget.selectedFiles.addListener(_selectedFilesListener);
2022-07-03 09:49:33 +00:00
_userAuthEventSubscription =
Bus.instance.on<SubscriptionPurchasedEvent>().listen((event) {
2020-11-15 07:19:44 +00:00
setState(() {});
});
2021-09-23 10:41:48 +00:00
_appBarTitle = widget.title;
galleryType = widget.type;
2020-04-30 15:09:41 +00:00
}
2020-11-15 07:19:44 +00:00
@override
void dispose() {
_userAuthEventSubscription.cancel();
2021-01-08 16:40:03 +00:00
widget.selectedFiles.removeListener(_selectedFilesListener);
2020-11-15 07:19:44 +00:00
super.dispose();
}
2020-04-18 18:46:38 +00:00
@override
Widget build(BuildContext context) {
return galleryType == GalleryType.homepage
? const SizedBox.shrink()
: AppBar(
elevation: 0,
centerTitle: false,
2023-08-18 06:22:08 +00:00
title: TextButton(
child: Text(
_appBarTitle!,
style: Theme.of(context)
.textTheme
.headlineSmall!
.copyWith(fontSize: 16),
),
onPressed: () => _renameAlbum(context),
),
actions: _getDefaultActions(context),
);
2020-04-18 18:46:38 +00:00
}
Future<dynamic> _renameAlbum(BuildContext context) async {
if (galleryType != GalleryType.ownedCollection &&
2023-08-19 12:13:36 +00:00
galleryType != GalleryType.hiddenOwnedCollection &&
galleryType != GalleryType.quickLink) {
showToast(
context,
'Type of galler $galleryType is not supported for '
'rename',
);
return;
}
final result = await showTextInputDialog(
context,
title: isQuickLink
? S.of(context).enterAlbumName
: S.of(context).renameAlbum,
submitButtonLabel:
isQuickLink ? S.of(context).done : S.of(context).rename,
2023-04-07 05:06:43 +00:00
hintText: S.of(context).enterAlbumName,
alwaysShowSuccessState: true,
initialValue: widget.collection?.displayName ?? "",
2023-02-09 05:12:40 +00:00
textCapitalization: TextCapitalization.words,
onSubmit: (String text) async {
2023-02-07 05:13:22 +00:00
// indicates user cancelled the rename request
if (text == "" || text.trim() == _appBarTitle!.trim()) {
return;
}
try {
await CollectionsService.instance.rename(widget.collection!, text);
if (mounted) {
_appBarTitle = text;
if (isQuickLink) {
// update the gallery type to owned collection so that correct
// actions are shown
galleryType = GalleryType.ownedCollection;
}
2023-02-07 05:13:22 +00:00
setState(() {});
}
} catch (e, s) {
_logger.severe("Failed to rename album", e, s);
rethrow;
2023-02-07 05:13:22 +00:00
}
},
);
if (result is Exception) {
showGenericErrorDialog(context: context);
}
}
2022-10-11 01:35:09 +00:00
Future<dynamic> _leaveAlbum(BuildContext context) async {
final actionResult = await showActionSheet(
context: context,
buttons: [
ButtonWidget(
buttonType: ButtonType.critical,
isInAlert: true,
shouldStickToDarkTheme: true,
buttonAction: ButtonAction.first,
shouldSurfaceExecutionStates: true,
2023-04-07 05:06:43 +00:00
labelText: S.of(context).leaveAlbum,
onTap: () async {
await CollectionsService.instance.leaveAlbum(widget.collection!);
},
),
2023-04-07 05:06:43 +00:00
ButtonWidget(
buttonType: ButtonType.secondary,
buttonAction: ButtonAction.cancel,
isInAlert: true,
shouldStickToDarkTheme: true,
2023-04-07 05:06:43 +00:00
labelText: S.of(context).cancel,
2023-08-19 11:39:56 +00:00
),
],
2023-04-07 05:06:43 +00:00
title: S.of(context).leaveSharedAlbum,
body: S.of(context).photosAddedByYouWillBeRemovedFromTheAlbum,
2022-10-11 01:35:09 +00:00
);
if (actionResult?.action != null && mounted) {
if (actionResult!.action == ButtonAction.error) {
showGenericErrorDialog(context: context);
} else if (actionResult.action == ButtonAction.first) {
Navigator.of(context).pop();
}
2022-10-11 01:35:09 +00:00
}
}
// todo: In the new design, clicking on free up space will directly open
// the free up space page and show loading indicator while calculating
// the space which can be claimed up. This code duplication should be removed
// whenever we move to the new design for free up space.
2022-11-24 13:08:27 +00:00
Future<dynamic> _deleteBackedUpFiles(BuildContext context) async {
2023-04-07 05:27:06 +00:00
final dialog = createProgressDialog(context, S.of(context).calculating);
await dialog.show();
BackupStatus status;
try {
status = await SyncService.instance
.getBackupStatus(pathID: widget.deviceCollection!.id);
} catch (e) {
await dialog.hide();
showGenericErrorDialog(context: context);
return;
}
await dialog.hide();
if (status.localIDs.isEmpty) {
showErrorDialog(
context,
2023-04-07 05:06:43 +00:00
S.of(context).allClear,
S.of(context).youveNoFilesInThisAlbumThatCanBeDeleted,
);
} else {
final bool? result = await routeToPage(
2022-11-24 11:09:05 +00:00
context,
FreeSpacePage(status, clearSpaceForFolder: true),
);
if (result == true) {
_showSpaceFreedDialog(status);
}
}
}
void _showSpaceFreedDialog(BackupStatus status) {
showChoiceDialog(
context,
2023-04-07 05:27:06 +00:00
title: S.of(context).success,
body: S.of(context).youHaveSuccessfullyFreedUp(formatBytes(status.size)),
firstButtonLabel: S.of(context).rateUs,
firstButtonOnTap: () async {
UpdateService.instance.launchReviewUrl();
},
firstButtonType: ButtonType.primary,
2023-04-07 05:27:06 +00:00
secondButtonLabel: S.of(context).ok,
secondButtonOnTap: () async {
if (Platform.isIOS) {
showToast(
context,
2023-04-07 05:27:06 +00:00
S.of(context).remindToEmptyDeviceTrash,
);
}
},
);
}
2020-04-30 15:09:41 +00:00
List<Widget> _getDefaultActions(BuildContext context) {
2022-08-29 14:43:31 +00:00
final List<Widget> actions = <Widget>[];
2023-06-27 08:34:58 +00:00
// If the user has selected files, don't show any actions
if (widget.selectedFiles.files.isNotEmpty ||
!Configuration.instance.hasConfiguredAccount()) {
return actions;
}
2023-06-27 09:15:25 +00:00
final int userID = Configuration.instance.getUserID()!;
isQuickLink = widget.collection?.isQuickLinkCollection() ?? false;
2023-08-19 06:58:43 +00:00
if (galleryType.canAddFiles(widget.collection, userID)) {
actions.add(
Tooltip(
message: "Add Files",
child: IconButton(
icon: const Icon(Icons.add_photo_alternate_outlined),
onPressed: () async {
await _showAddPhotoDialog(context);
},
2023-06-27 09:15:25 +00:00
),
2023-08-19 06:58:43 +00:00
),
);
}
if (galleryType.isSharable()) {
2021-09-23 09:52:59 +00:00
actions.add(
Tooltip(
message: "Share",
2021-09-23 09:52:59 +00:00
child: IconButton(
icon: Icon(
isQuickLink && (widget.collection!.hasLink)
? Icons.link_outlined
: Icons.people_outlined,
),
onPressed: () async {
await _showShareCollectionDialog();
2021-09-23 09:52:59 +00:00
},
),
),
);
2020-04-30 15:09:41 +00:00
}
final List<PopupMenuItem<AlbumPopupAction>> items = [];
2023-08-19 06:58:43 +00:00
if (galleryType.canRename()) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.rename,
child: Row(
children: [
Icon(isQuickLink ? Icons.photo_album_outlined : Icons.edit),
const Padding(
padding: EdgeInsets.all(8),
),
Text(
isQuickLink
? S.of(context).convertToAlbum
: S.of(context).renameAlbum,
),
],
2022-10-11 01:35:09 +00:00
),
2023-08-19 06:58:43 +00:00
),
);
}
if (galleryType.canSetCover()) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.setCover,
child: Row(
children: [
const Icon(Icons.image_outlined),
const Padding(
padding: EdgeInsets.all(8),
2023-08-04 07:12:13 +00:00
),
2023-08-19 06:58:43 +00:00
Text(S.of(context).setCover),
],
),
2023-08-19 06:58:43 +00:00
),
);
}
if (galleryType.showMap()) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.map,
child: Row(
children: [
const Icon(Icons.map_outlined),
const Padding(
padding: EdgeInsets.all(8),
),
Text(S.of(context).map),
],
2022-10-11 01:35:09 +00:00
),
2023-08-19 06:58:43 +00:00
),
);
}
if (galleryType.canSort()) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.sort,
child: Row(
children: [
const Icon(Icons.sort_outlined),
const Padding(
padding: EdgeInsets.all(8),
2023-08-04 07:12:13 +00:00
),
2023-08-19 06:58:43 +00:00
Text(
S.of(context).sortAlbumsBy,
),
],
),
),
);
}
if (galleryType.canPin()) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.pinAlbum,
child: Row(
children: [
widget.collection!.isPinned
? const Icon(CupertinoIcons.pin_slash)
: Transform.rotate(
angle: 45 * math.pi / 180, // rotate by 45 degrees
child: const Icon(CupertinoIcons.pin),
),
const Padding(
padding: EdgeInsets.all(8),
),
Text(
widget.collection!.isPinned
? S.of(context).unpinAlbum
: S.of(context).pinAlbum,
),
],
),
),
);
}
final bool isArchived = widget.collection?.isArchived() ?? false;
final bool isHidden = widget.collection?.isHidden() ?? false;
// Do not show archive option for favorite collection. If collection is
// already archived, allow user to unarchive that collection.
if (isArchived || (galleryType.canArchive() && !isHidden)) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.ownedArchive,
child: Row(
children: [
Icon(isArchived ? Icons.unarchive : Icons.archive_outlined),
const Padding(
padding: EdgeInsets.all(8),
),
Text(
isArchived
? S.of(context).unarchiveAlbum
: S.of(context).archiveAlbum,
),
],
),
),
);
}
if (!isArchived && galleryType.canHide()) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.ownedHide,
child: Row(
children: [
Icon(
isHidden
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
),
const Padding(
padding: EdgeInsets.all(8),
),
Text(
isHidden ? S.of(context).unhide : S.of(context).hide,
),
],
),
),
);
}
2023-06-30 04:31:15 +00:00
2023-08-19 06:58:43 +00:00
if (galleryType.canDelete()) {
items.add(
PopupMenuItem(
value: isQuickLink
? AlbumPopupAction.removeLink
: AlbumPopupAction.delete,
child: Row(
children: [
Icon(
isQuickLink
? Icons.remove_circle_outline
: Icons.delete_outline,
2023-08-04 07:12:13 +00:00
),
2023-08-19 06:58:43 +00:00
const Padding(
padding: EdgeInsets.all(8),
),
2023-08-19 06:58:43 +00:00
Text(
isQuickLink
? S.of(context).removeLink
: S.of(context).deleteAlbum,
),
],
2022-10-11 01:35:09 +00:00
),
2023-08-19 06:58:43 +00:00
),
);
}
2022-10-11 01:35:09 +00:00
if (galleryType == GalleryType.sharedCollection) {
final bool hasShareeArchived = widget.collection!.hasShareeArchived();
2022-10-11 01:35:09 +00:00
items.add(
PopupMenuItem(
value: AlbumPopupAction.leave,
2022-10-11 01:35:09 +00:00
child: Row(
2023-04-07 05:27:06 +00:00
children: [
const Icon(Icons.logout),
const Padding(
2022-10-11 01:35:09 +00:00
padding: EdgeInsets.all(8),
),
2023-04-07 05:27:06 +00:00
Text(S.of(context).leaveAlbum),
2022-10-11 01:35:09 +00:00
],
),
2022-06-11 08:23:52 +00:00
),
);
//here
items.add(
PopupMenuItem(
value: AlbumPopupAction.sharedArchive,
child: Row(
children: [
Icon(
hasShareeArchived ? Icons.unarchive : Icons.archive_outlined,
),
const Padding(
padding: EdgeInsets.all(8),
),
Text(
hasShareeArchived
? S.of(context).unarchiveAlbum
: S.of(context).archiveAlbum,
),
],
),
),
);
2021-09-23 02:34:15 +00:00
}
if (galleryType == GalleryType.localFolder) {
items.add(
PopupMenuItem(
value: AlbumPopupAction.freeUpSpace,
child: Row(
2023-04-07 05:27:06 +00:00
children: [
const Icon(Icons.delete_sweep_outlined),
const Padding(
padding: EdgeInsets.all(8),
),
2023-04-07 05:27:06 +00:00
Text(S.of(context).freeUpDeviceSpace),
],
),
),
);
}
if (items.isNotEmpty) {
actions.add(
PopupMenuButton(
itemBuilder: (context) {
return items;
},
onSelected: (AlbumPopupAction value) async {
if (value == AlbumPopupAction.rename) {
await _renameAlbum(context);
2023-06-30 04:31:15 +00:00
} else if (value == AlbumPopupAction.pinAlbum) {
await updateOrder(
context,
widget.collection!,
widget.collection!.isPinned ? 0 : 1,
);
if (mounted) setState(() {});
} else if (value == AlbumPopupAction.ownedArchive) {
2023-08-19 12:48:45 +00:00
await archiveOrUnarchive();
} else if (value == AlbumPopupAction.ownedHide) {
2023-08-19 12:48:45 +00:00
await hideOrUnhide();
} else if (value == AlbumPopupAction.delete) {
await _trashCollection();
} else if (value == AlbumPopupAction.removeLink) {
await _removeQuickLink();
} else if (value == AlbumPopupAction.leave) {
await _leaveAlbum(context);
} else if (value == AlbumPopupAction.freeUpSpace) {
2022-11-24 13:08:27 +00:00
await _deleteBackedUpFiles(context);
2023-06-22 10:51:56 +00:00
} else if (value == AlbumPopupAction.setCover) {
await setCoverPhoto(context);
} else if (value == AlbumPopupAction.sort) {
await _showSortOption(context);
} else if (value == AlbumPopupAction.sharedArchive) {
final hasShareeArchived = widget.collection!.hasShareeArchived();
final int prevVisiblity =
hasShareeArchived ? archiveVisibility : visibleVisibility;
final int newVisiblity =
hasShareeArchived ? visibleVisibility : archiveVisibility;
2023-05-29 13:37:02 +00:00
await changeCollectionVisibility(
context,
collection: widget.collection!,
newVisibility: newVisiblity,
prevVisibility: prevVisiblity,
2023-05-29 13:37:02 +00:00
isOwner: false,
);
if (mounted) {
setState(() {});
}
} else if (value == AlbumPopupAction.map) {
await showOnMap();
} else {
2023-04-07 05:27:06 +00:00
showToast(context, S.of(context).somethingWentWrong);
}
},
),
);
}
2022-10-11 01:35:09 +00:00
2020-04-30 15:09:41 +00:00
return actions;
}
2023-06-22 10:51:56 +00:00
Future<void> setCoverPhoto(BuildContext context) async {
final int? coverPhotoID = await showPickCoverPhotoSheet(
context,
widget.collection!,
);
if (coverPhotoID != null) {
changeCoverPhoto(context, widget.collection!, coverPhotoID);
2023-06-22 10:51:56 +00:00
}
}
Future<void> showOnMap() async {
2023-06-15 12:45:26 +00:00
final bool result = await requestForMapEnable(context);
if (result) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => MapScreen(
filesFutureFn: () async {
return FilesDB.instance.getAllFilesCollection(
widget.collection!.id,
);
},
),
),
2023-06-15 12:45:26 +00:00
);
}
}
Future<void> _showSortOption(BuildContext bContext) async {
final bool? sortByAsc = await showMenu<bool>(
context: bContext,
position: RelativeRect.fromLTRB(
MediaQuery.of(context).size.width,
kToolbarHeight + 12,
12,
0,
),
items: [
PopupMenuItem(
value: false,
child: Text(S.of(context).sortNewestFirst),
),
PopupMenuItem(
value: true,
child: Text(S.of(context).sortOldestFirst),
),
],
);
if (sortByAsc != null) {
changeSortOrder(bContext, widget.collection!, sortByAsc);
}
}
2022-09-13 06:44:10 +00:00
Future<void> _trashCollection() async {
2023-07-06 07:59:31 +00:00
// Fetch the count by-passing the cache to avoid any stale data
final int count =
await FilesDB.instance.collectionFileCount(widget.collection!.id);
final bool isEmptyCollection = count == 0;
if (isEmptyCollection) {
final dialog = createProgressDialog(
context,
2023-04-07 05:27:06 +00:00
S.of(context).pleaseWaitDeletingAlbum,
);
await dialog.show();
try {
await CollectionsService.instance
.trashEmptyCollection(widget.collection!);
await dialog.hide();
Navigator.of(context).pop();
} catch (e, s) {
_logger.severe("failed to trash collection", e, s);
await dialog.hide();
showGenericErrorDialog(context: context);
}
} else {
final bool result = await collectionActions.deleteCollectionSheet(
context,
widget.collection!,
);
if (result == true) {
Navigator.of(context).pop();
} else {
debugPrint("No pop");
}
2022-09-13 06:44:10 +00:00
}
}
Future<void> _removeQuickLink() async {
try {
final bool result =
await CollectionActions(CollectionsService.instance).disableUrl(
context,
widget.collection!,
);
if (result && mounted) {
Navigator.of(context).pop();
}
} catch (e, s) {
_logger.severe("failed to trash collection", e, s);
showGenericErrorDialog(context: context);
}
}
2023-06-27 11:26:16 +00:00
Future<void> _showShareCollectionDialog() async {
2022-12-08 11:12:51 +00:00
final collection = widget.collection;
try {
if (collection == null ||
(galleryType != GalleryType.ownedCollection &&
galleryType != GalleryType.sharedCollection &&
2023-08-19 12:09:35 +00:00
galleryType != GalleryType.hiddenOwnedCollection &&
!isQuickLink)) {
throw Exception(
"Cannot share empty collection of type $galleryType",
);
}
if (Configuration.instance.getUserID() == widget.collection!.owner!.id) {
unawaited(
routeToPage(
context,
(isQuickLink && (collection.hasLink))
2023-08-19 12:09:35 +00:00
? ManageSharedLinkWidget(collection: collection)
: ShareCollectionPage(collection),
),
);
} else {
unawaited(
routeToPage(
context,
AlbumParticipantsPage(collection),
),
);
2020-10-29 12:56:30 +00:00
}
} catch (e, s) {
_logger.severe(e, s);
showGenericErrorDialog(context: context);
2020-10-29 12:56:30 +00:00
}
2020-05-17 12:39:38 +00:00
}
2023-06-27 09:15:25 +00:00
2023-06-27 11:26:16 +00:00
Future<void> _showAddPhotoDialog(BuildContext bContext) async {
2023-06-27 09:15:25 +00:00
final collection = widget.collection;
try {
await showAddPhotosSheet(bContext, collection!);
2023-06-27 09:15:25 +00:00
} catch (e, s) {
_logger.severe(e, s);
2023-06-27 11:26:16 +00:00
showGenericErrorDialog(context: bContext);
2023-06-27 09:15:25 +00:00
}
}
2023-08-19 12:48:45 +00:00
Future<void> hideOrUnhide() async {
final isHidden = widget.collection!.isHidden();
final int prevVisiblity = isHidden ? hiddenVisibility : visibleVisibility;
final int newVisiblity = isHidden ? visibleVisibility : hiddenVisibility;
await changeCollectionVisibility(
context,
collection: widget.collection!,
newVisibility: newVisiblity,
prevVisibility: prevVisiblity,
);
setState(() {});
}
Future<void> archiveOrUnarchive() async {
final isArchived = widget.collection!.isArchived();
final int prevVisiblity =
isArchived ? archiveVisibility : visibleVisibility;
final int newVisiblity = isArchived ? visibleVisibility : archiveVisibility;
await changeCollectionVisibility(
context,
collection: widget.collection!,
newVisibility: newVisiblity,
prevVisibility: prevVisiblity,
);
setState(() {});
}
2020-04-18 18:46:38 +00:00
}