2022-09-07 08:30:09 +00:00
|
|
|
// @dart=2.9
|
|
|
|
|
2020-05-05 12:56:24 +00:00
|
|
|
import 'dart:async';
|
2022-11-24 10:54:59 +00:00
|
|
|
import 'dart:io';
|
2021-09-15 11:22:58 +00:00
|
|
|
|
2022-11-17 09:40:13 +00:00
|
|
|
import 'package:collection/collection.dart';
|
2020-04-18 18:46:38 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2020-10-30 19:57:14 +00:00
|
|
|
import 'package:logging/logging.dart';
|
2020-05-30 21:15:21 +00:00
|
|
|
import 'package:photos/core/configuration.dart';
|
2020-11-15 07:19:44 +00:00
|
|
|
import 'package:photos/core/event_bus.dart';
|
2022-08-27 07:30:40 +00:00
|
|
|
import 'package:photos/ente_theme_data.dart';
|
2021-02-02 16:35:38 +00:00
|
|
|
import 'package:photos/events/subscription_purchased_event.dart';
|
2022-11-24 10:54:59 +00:00
|
|
|
import 'package:photos/models/backup_status.dart';
|
2020-10-29 12:56:30 +00:00
|
|
|
import 'package:photos/models/collection.dart';
|
2022-09-06 16:49:02 +00:00
|
|
|
import 'package:photos/models/device_collection.dart';
|
2022-07-03 10:09:01 +00:00
|
|
|
import 'package:photos/models/gallery_type.dart';
|
2021-09-20 06:41:38 +00:00
|
|
|
import 'package:photos/models/magic_metadata.dart';
|
2020-07-15 20:29:29 +00:00
|
|
|
import 'package:photos/models/selected_files.dart';
|
2020-10-13 05:22:20 +00:00
|
|
|
import 'package:photos/services/collections_service.dart';
|
2022-11-24 10:54:59 +00:00
|
|
|
import 'package:photos/services/sync_service.dart';
|
2022-12-07 08:41:52 +00:00
|
|
|
import 'package:photos/services/update_service.dart';
|
2022-08-27 07:30:40 +00:00
|
|
|
import 'package:photos/ui/common/dialogs.dart';
|
2022-07-01 14:18:05 +00:00
|
|
|
import 'package:photos/ui/common/rename_dialog.dart';
|
2022-12-08 13:40:27 +00:00
|
|
|
import 'package:photos/ui/sharing/album_participants_page.dart';
|
2022-11-20 11:55:12 +00:00
|
|
|
import 'package:photos/ui/sharing/share_collection_page.dart';
|
2022-11-24 10:54:59 +00:00
|
|
|
import 'package:photos/ui/tools/free_space_page.dart';
|
|
|
|
import 'package:photos/utils/data_util.dart';
|
2020-07-15 19:14:37 +00:00
|
|
|
import 'package:photos/utils/dialog_util.dart';
|
2021-10-30 05:43:56 +00:00
|
|
|
import 'package:photos/utils/magic_util.dart';
|
2022-11-20 04:33:24 +00:00
|
|
|
import 'package:photos/utils/navigation_util.dart';
|
2022-09-13 06:44:10 +00:00
|
|
|
import 'package:photos/utils/toast_util.dart';
|
2022-11-24 10:54:59 +00:00
|
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
2020-04-18 18:46:38 +00:00
|
|
|
|
2021-05-02 11:19:05 +00:00
|
|
|
class GalleryAppBarWidget extends StatefulWidget {
|
2022-05-08 04:34:55 +00:00
|
|
|
final GalleryType type;
|
2020-04-18 18:46:38 +00:00
|
|
|
final String title;
|
2020-07-15 20:29:29 +00:00
|
|
|
final SelectedFiles selectedFiles;
|
2022-08-31 18:39:39 +00:00
|
|
|
final DeviceCollection deviceCollection;
|
2020-10-29 12:56:30 +00:00
|
|
|
final Collection collection;
|
2020-04-18 18:46:38 +00:00
|
|
|
|
2022-07-04 08:43:01 +00:00
|
|
|
const GalleryAppBarWidget(
|
2020-07-15 17:17:53 +00:00
|
|
|
this.type,
|
2020-07-15 20:29:29 +00:00
|
|
|
this.title,
|
2020-10-29 12:56:30 +00:00
|
|
|
this.selectedFiles, {
|
2022-07-03 07:47:15 +00:00
|
|
|
Key key,
|
2022-08-31 18:39:39 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
|
2020-10-30 19:57:14 +00:00
|
|
|
final _logger = Logger("GalleryAppBar");
|
2020-11-15 07:19:44 +00:00
|
|
|
StreamSubscription _userAuthEventSubscription;
|
2021-01-08 16:40:03 +00:00
|
|
|
Function() _selectedFilesListener;
|
2021-09-23 10:41:48 +00:00
|
|
|
String _appBarTitle;
|
2022-04-22 16:05:30 +00:00
|
|
|
final GlobalKey shareButtonKey = GlobalKey();
|
2022-10-11 01:35:09 +00:00
|
|
|
|
2020-04-30 15:09:41 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
2021-01-08 16:40:03 +00:00
|
|
|
_selectedFilesListener = () {
|
2020-07-15 20:29:29 +00:00
|
|
|
setState(() {});
|
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;
|
2020-04-30 15:09:41 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
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) {
|
2022-10-12 08:26:37 +00:00
|
|
|
return widget.type == GalleryType.homepage
|
|
|
|
? const SizedBox.shrink()
|
|
|
|
: AppBar(
|
|
|
|
backgroundColor: widget.type == GalleryType.homepage
|
|
|
|
? const Color(0x00000000)
|
|
|
|
: null,
|
|
|
|
elevation: 0,
|
|
|
|
centerTitle: false,
|
|
|
|
title: widget.type == GalleryType.homepage
|
|
|
|
? const SizedBox.shrink()
|
|
|
|
: TextButton(
|
|
|
|
child: Text(
|
|
|
|
_appBarTitle,
|
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.headline5
|
|
|
|
.copyWith(fontSize: 16),
|
|
|
|
),
|
|
|
|
onPressed: () => _renameAlbum(context),
|
|
|
|
),
|
|
|
|
actions: _getDefaultActions(context),
|
|
|
|
);
|
2020-04-18 18:46:38 +00:00
|
|
|
}
|
|
|
|
|
2021-09-22 14:17:45 +00:00
|
|
|
Future<dynamic> _renameAlbum(BuildContext context) async {
|
2022-07-03 07:47:15 +00:00
|
|
|
if (widget.type != GalleryType.ownedCollection) {
|
2021-09-22 14:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-11-09 06:58:37 +00:00
|
|
|
final result = await showDialog<String>(
|
2021-09-22 14:27:50 +00:00
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
2022-06-09 04:51:59 +00:00
|
|
|
return RenameDialog(_appBarTitle, 'Album');
|
2021-09-22 14:27:50 +00:00
|
|
|
},
|
|
|
|
barrierColor: Colors.black.withOpacity(0.85),
|
|
|
|
);
|
2021-09-23 10:41:48 +00:00
|
|
|
// indicates user cancelled the rename request
|
2021-11-09 06:58:37 +00:00
|
|
|
if (result == null || result.trim() == _appBarTitle.trim()) {
|
2021-09-22 14:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-06-09 04:51:59 +00:00
|
|
|
final dialog = createProgressDialog(context, "Changing name...");
|
2021-09-22 14:17:45 +00:00
|
|
|
await dialog.show();
|
|
|
|
try {
|
2021-09-23 11:33:25 +00:00
|
|
|
await CollectionsService.instance.rename(widget.collection, result);
|
2021-09-22 14:17:45 +00:00
|
|
|
await dialog.hide();
|
2021-09-22 14:27:50 +00:00
|
|
|
if (mounted) {
|
2021-09-23 10:41:48 +00:00
|
|
|
_appBarTitle = result;
|
2021-09-22 14:27:50 +00:00
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2021-09-22 14:17:45 +00:00
|
|
|
await dialog.hide();
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-11 01:35:09 +00:00
|
|
|
Future<dynamic> _leaveAlbum(BuildContext context) async {
|
|
|
|
final DialogUserChoice result = await showChoiceDialog(
|
|
|
|
context,
|
|
|
|
"Leave shared album?",
|
|
|
|
"You will leave the album, and it will stop being visible to you.",
|
|
|
|
firstAction: "Cancel",
|
|
|
|
secondAction: "Yes, Leave",
|
|
|
|
secondActionColor:
|
|
|
|
Theme.of(context).colorScheme.enteTheme.colorScheme.warning700,
|
|
|
|
);
|
|
|
|
if (result != DialogUserChoice.secondChoice) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final dialog = createProgressDialog(context, "Leaving album...");
|
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
await CollectionsService.instance.leaveAlbum(widget.collection);
|
|
|
|
await dialog.hide();
|
|
|
|
if (mounted) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
await dialog.hide();
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-24 10:54:59 +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 {
|
2022-11-24 10:54:59 +00:00
|
|
|
final dialog = createProgressDialog(context, "Calculating...");
|
|
|
|
await dialog.show();
|
|
|
|
BackupStatus status;
|
|
|
|
try {
|
|
|
|
status = await SyncService.instance
|
|
|
|
.getBackupStatus(pathID: widget.deviceCollection.id);
|
|
|
|
} catch (e) {
|
|
|
|
await dialog.hide();
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await dialog.hide();
|
|
|
|
if (status.localIDs.isEmpty) {
|
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"✨ All clear",
|
2022-11-24 11:09:05 +00:00
|
|
|
"You've no files in this album that can be deleted",
|
2022-11-24 10:54:59 +00:00
|
|
|
);
|
|
|
|
} else {
|
2022-11-24 11:09:05 +00:00
|
|
|
final bool result = await routeToPage(
|
|
|
|
context,
|
|
|
|
FreeSpacePage(status, clearSpaceForFolder: true),
|
|
|
|
);
|
2022-11-24 10:54:59 +00:00
|
|
|
if (result == true) {
|
|
|
|
_showSpaceFreedDialog(status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void _showSpaceFreedDialog(BackupStatus status) {
|
|
|
|
final AlertDialog alert = AlertDialog(
|
|
|
|
title: const Text("Success"),
|
|
|
|
content: Text(
|
|
|
|
"You have successfully freed up " + formatBytes(status.size) + "!",
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
child: Text(
|
|
|
|
"Rate us",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context).colorScheme.greenAlternative,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context, rootNavigator: true).pop('dialog');
|
|
|
|
// TODO: Replace with https://pub.dev/packages/in_app_review
|
2022-12-07 08:41:52 +00:00
|
|
|
final url = UpdateService.instance.getRateDetails().item2;
|
|
|
|
launchUrlString(url);
|
2022-11-24 10:54:59 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
child: const Text(
|
|
|
|
"Ok",
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
showToast(
|
|
|
|
context,
|
|
|
|
"Also empty \"Recently Deleted\" from \"Settings\" -> \"Storage\" to claim the freed space",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
Navigator.of(context, rootNavigator: true).pop('dialog');
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
showConfettiDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return alert;
|
|
|
|
},
|
|
|
|
barrierColor: Colors.black87,
|
|
|
|
confettiAlignment: Alignment.topCenter,
|
|
|
|
useRootNavigator: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
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>[];
|
2021-01-08 16:17:26 +00:00
|
|
|
if (Configuration.instance.hasConfiguredAccount() &&
|
2022-05-30 11:13:55 +00:00
|
|
|
widget.selectedFiles.files.isEmpty &&
|
2022-12-08 13:40:27 +00:00
|
|
|
(widget.type == GalleryType.ownedCollection ||
|
|
|
|
widget.type == GalleryType.sharedCollection) &&
|
2022-11-26 07:56:54 +00:00
|
|
|
widget.collection?.type != CollectionType.favorites) {
|
2021-09-23 09:52:59 +00:00
|
|
|
actions.add(
|
|
|
|
Tooltip(
|
2022-05-30 11:13:55 +00:00
|
|
|
message: "Share",
|
2021-09-23 09:52:59 +00:00
|
|
|
child: IconButton(
|
2022-11-02 04:06:19 +00:00
|
|
|
icon: const Icon(Icons.people_outlined),
|
2022-08-27 07:30:40 +00:00
|
|
|
onPressed: () async {
|
2022-09-01 09:39:59 +00:00
|
|
|
await _showShareCollectionDialog();
|
2021-09-23 09:52:59 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2020-04-30 15:09:41 +00:00
|
|
|
}
|
2022-10-11 01:35:09 +00:00
|
|
|
final List<PopupMenuItem> items = [];
|
2022-07-03 07:47:15 +00:00
|
|
|
if (widget.type == GalleryType.ownedCollection) {
|
2022-10-11 01:35:09 +00:00
|
|
|
if (widget.collection.type != CollectionType.favorites) {
|
|
|
|
items.add(
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 1,
|
|
|
|
child: Row(
|
|
|
|
children: const [
|
|
|
|
Icon(Icons.edit),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(8),
|
2022-03-21 09:32:24 +00:00
|
|
|
),
|
2022-10-11 01:35:09 +00:00
|
|
|
Text("Rename album"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
final bool isArchived = widget.collection.isArchived();
|
2022-11-17 09:51:17 +00:00
|
|
|
// Do not show archive option for favorite collection. If collection is
|
|
|
|
// already archived, allow user to unarchive that collection.
|
|
|
|
if (isArchived || widget.collection.type != CollectionType.favorites) {
|
|
|
|
items.add(
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 2,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Icon(isArchived ? Icons.unarchive : Icons.archive_outlined),
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
),
|
|
|
|
Text(isArchived ? "Unarchive album" : "Archive album"),
|
|
|
|
],
|
|
|
|
),
|
2022-10-11 01:35:09 +00:00
|
|
|
),
|
2022-11-17 09:51:17 +00:00
|
|
|
);
|
|
|
|
}
|
2022-10-11 01:35:09 +00:00
|
|
|
if (widget.collection.type != CollectionType.favorites) {
|
|
|
|
items.add(
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 3,
|
|
|
|
child: Row(
|
|
|
|
children: const [
|
|
|
|
Icon(Icons.delete_outline),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(8),
|
2022-09-13 06:44:10 +00:00
|
|
|
),
|
2022-10-11 01:35:09 +00:00
|
|
|
Text("Delete album"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} // ownedCollection open ends
|
|
|
|
|
|
|
|
if (widget.type == GalleryType.sharedCollection) {
|
|
|
|
items.add(
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 4,
|
|
|
|
child: Row(
|
|
|
|
children: const [
|
|
|
|
Icon(Icons.logout),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
),
|
|
|
|
Text("Leave album"),
|
|
|
|
],
|
|
|
|
),
|
2022-06-11 08:23:52 +00:00
|
|
|
),
|
|
|
|
);
|
2021-09-23 02:34:15 +00:00
|
|
|
}
|
2022-11-24 10:54:59 +00:00
|
|
|
if (widget.type == GalleryType.localFolder) {
|
|
|
|
items.add(
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 5,
|
|
|
|
child: Row(
|
|
|
|
children: const [
|
2022-11-24 11:09:05 +00:00
|
|
|
Icon(Icons.delete_sweep_outlined),
|
2022-11-24 10:54:59 +00:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(8),
|
|
|
|
),
|
|
|
|
Text("Free up device space"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-10-20 10:52:51 +00:00
|
|
|
if (items.isNotEmpty) {
|
|
|
|
actions.add(
|
|
|
|
PopupMenuButton(
|
|
|
|
itemBuilder: (context) {
|
|
|
|
return items;
|
|
|
|
},
|
|
|
|
onSelected: (value) async {
|
|
|
|
if (value == 1) {
|
|
|
|
await _renameAlbum(context);
|
|
|
|
} else if (value == 2) {
|
|
|
|
await changeCollectionVisibility(
|
|
|
|
context,
|
|
|
|
widget.collection,
|
|
|
|
widget.collection.isArchived()
|
|
|
|
? visibilityVisible
|
|
|
|
: visibilityArchive,
|
|
|
|
);
|
|
|
|
} else if (value == 3) {
|
|
|
|
await _trashCollection();
|
|
|
|
} else if (value == 4) {
|
|
|
|
await _leaveAlbum(context);
|
2022-11-24 10:54:59 +00:00
|
|
|
} else if (value == 5) {
|
2022-11-24 13:08:27 +00:00
|
|
|
await _deleteBackedUpFiles(context);
|
2022-10-20 10:52:51 +00:00
|
|
|
} else {
|
|
|
|
showToast(context, "Something went wrong");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-10-11 01:35:09 +00:00
|
|
|
|
2020-04-30 15:09:41 +00:00
|
|
|
return actions;
|
|
|
|
}
|
|
|
|
|
2022-09-13 06:44:10 +00:00
|
|
|
Future<void> _trashCollection() async {
|
2022-11-17 09:40:13 +00:00
|
|
|
final collectionWithThumbnail =
|
|
|
|
await CollectionsService.instance.getCollectionsWithThumbnails();
|
|
|
|
final bool isEmptyCollection = collectionWithThumbnail
|
|
|
|
.firstWhereOrNull(
|
|
|
|
(element) => element.collection.id == widget.collection.id,
|
|
|
|
)
|
|
|
|
?.thumbnail ==
|
|
|
|
null;
|
2022-11-17 09:49:34 +00:00
|
|
|
if (!isEmptyCollection) {
|
|
|
|
final result = await showChoiceDialog(
|
|
|
|
context,
|
|
|
|
"Delete album?",
|
|
|
|
"Files that are unique to this album "
|
|
|
|
"will be moved to trash, and this album will be deleted.",
|
|
|
|
firstAction: "Cancel",
|
|
|
|
secondAction: "Delete album",
|
|
|
|
secondActionColor: Colors.red,
|
|
|
|
);
|
|
|
|
if (result != DialogUserChoice.secondChoice) {
|
|
|
|
return;
|
|
|
|
}
|
2022-09-13 06:44:10 +00:00
|
|
|
}
|
|
|
|
final dialog = createProgressDialog(
|
|
|
|
context,
|
|
|
|
"Please wait, deleting album",
|
|
|
|
);
|
|
|
|
await dialog.show();
|
|
|
|
try {
|
2022-11-17 09:40:13 +00:00
|
|
|
await CollectionsService.instance
|
|
|
|
.trashCollection(widget.collection, isEmptyCollection);
|
2022-09-13 06:44:10 +00:00
|
|
|
showShortToast(context, "Successfully deleted album");
|
|
|
|
await dialog.hide();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
} catch (e, s) {
|
|
|
|
_logger.severe("failed to trash collection", e, s);
|
|
|
|
await dialog.hide();
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-17 14:23:37 +00:00
|
|
|
Future<void> _showShareCollectionDialog() async {
|
2022-12-08 11:12:51 +00:00
|
|
|
final collection = widget.collection;
|
2022-01-07 16:04:51 +00:00
|
|
|
try {
|
2022-12-08 13:40:27 +00:00
|
|
|
if (collection == null ||
|
|
|
|
(widget.type != GalleryType.ownedCollection &&
|
|
|
|
widget.type != GalleryType.sharedCollection)) {
|
2022-09-07 10:58:38 +00:00
|
|
|
throw Exception(
|
2022-12-08 13:40:27 +00:00
|
|
|
"Cannot share empty collection of typex ${widget.type}",
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (Configuration.instance.getUserID() == widget.collection.owner.id) {
|
|
|
|
unawaited(
|
|
|
|
routeToPage(
|
|
|
|
context,
|
|
|
|
ShareCollectionPage(collection),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
unawaited(
|
|
|
|
routeToPage(
|
|
|
|
context,
|
|
|
|
AlbumParticipantsPage(collection),
|
|
|
|
),
|
2022-09-07 10:58:38 +00:00
|
|
|
);
|
2020-10-29 12:56:30 +00:00
|
|
|
}
|
2022-01-07 16:04:51 +00:00
|
|
|
} catch (e, s) {
|
|
|
|
_logger.severe(e, s);
|
|
|
|
showGenericErrorDialog(context);
|
2020-10-29 12:56:30 +00:00
|
|
|
}
|
2020-05-17 12:39:38 +00:00
|
|
|
}
|
2020-04-18 18:46:38 +00:00
|
|
|
}
|