Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

mob(photos): clean up memory lane sharing

AmanRajSinghMourya600726789e4a
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index df051fc021..141dc10b90 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -1120,6 +1120,11 @@
"favorite": "Favorite",
"removeFromFavorite": "Remove from favorites",
"shareLink": "Share link",
+ "memoryShareLinkDescription": "This link allows anyone who receives it to access your item. You can remove access at any time by deleting the link.\n\nThe link will expire automatically in 7 days.",
+ "deleteLink": "Delete link",
+ "deleteLinkQuestion": "Delete link?",
+ "deleteMemoryLinkMessage": "Deleting this link will revoke memory access for all users",
+ "linkDeletedSuccessfully": "Link deleted successfully",
"openLink": "Open link",
"pay": "Pay",
"noPaymentAppFound": "No payment app found",
diff --git a/mobile/apps/photos/lib/models/collection/collection_items.dart b/mobile/apps/photos/lib/models/collection/collection_items.dart
index 6ce67b2d37..81526d660b 100644
--- a/mobile/apps/photos/lib/models/collection/collection_items.dart
+++ b/mobile/apps/photos/lib/models/collection/collection_items.dart
@@ -1,3 +1,4 @@
+import 'package:photos/models/api/memory_share/memory_share.dart';
import 'package:photos/models/collection/collection.dart';
import 'package:photos/models/file/file.dart';
@@ -22,3 +23,14 @@ class SharedCollections {
return SharedCollections([], [], []);
}
}
+
+class SharedCollectionsWithMemoryLinks {
+ final SharedCollections collections;
+ final List<MemoryShare> memoryLinks;
+
+ SharedCollectionsWithMemoryLinks(this.collections, this.memoryLinks);
+
+ static SharedCollectionsWithMemoryLinks empty() {
+ return SharedCollectionsWithMemoryLinks(SharedCollections.empty(), []);
+ }
+}
diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dart
index 2c091a65c7..c02d57a507 100644
--- a/mobile/apps/photos/lib/services/collections_service.dart
+++ b/mobile/apps/photos/lib/services/collections_service.dart
@@ -39,6 +39,7 @@ import "package:photos/models/metadata/collection_magic.dart";
import "package:photos/service_locator.dart";
import 'package:photos/services/app_lifecycle_service.dart';
import "package:photos/services/favorites_service.dart";
+import 'package:photos/services/memory_share_service.dart';
import 'package:photos/services/sync/local_sync_service.dart';
import 'package:photos/services/sync/remote_sync_service.dart';
import "package:photos/utils/dialog_util.dart";
@@ -609,6 +610,18 @@ class CollectionsService {
return SharedCollections(outgoing, incoming, quickLinks);
}
+ Future<SharedCollectionsWithMemoryLinks>
+ getSharedCollectionsWithMemoryLinks() async {
+ final collections = await getSharedCollections();
+ try {
+ final memoryLinks = await MemoryShareService.instance.listMemoryShares();
+ return SharedCollectionsWithMemoryLinks(collections, memoryLinks);
+ } catch (e, s) {
+ _logger.severe("failed to load memory links", e, s);
+ return SharedCollectionsWithMemoryLinks(collections, []);
+ }
+ }
+
Future<List<Collection>> getCollectionForOnEnteSection() async {
final AlbumSortKey sortKey = localSettings.albumSortKey();
final AlbumSortDirection sortDirection = localSettings.albumSortDirection();
diff --git a/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart b/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart
index e905cc62b7..f75bcf0447 100644
--- a/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart
+++ b/mobile/apps/photos/lib/ui/home/memories/full_screen_memory.dart
@@ -6,7 +6,6 @@ import "dart:ui";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";
-import "package:flutter/services.dart";
import "package:hugeicons/hugeicons.dart";
import "package:photos/core/configuration.dart";
import "package:photos/core/event_bus.dart";
@@ -24,14 +23,12 @@ import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/theme/text_style.dart";
import "package:photos/ui/actions/file/file_actions.dart";
-import "package:photos/ui/components/alert_bottom_sheet.dart";
import "package:photos/ui/components/base_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
import "package:photos/ui/components/settings/settings_grouped_card.dart";
import "package:photos/ui/home/memories/custom_listener.dart";
import "package:photos/ui/home/memories/memory_progress_indicator.dart";
-import "package:photos/ui/notification/toast.dart";
+import "package:photos/ui/sharing/memory_link_details_sheet.dart";
import "package:photos/ui/viewer/file/file_widget.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
import "package:photos/ui/viewer/file_details/favorite_widget.dart";
@@ -885,7 +882,19 @@ Future<void> _showMemoryShareSheet(
}
if (shouldShareLink) {
- await _showMemoryLinkDetailsSheet(context, inheritedData, memoryTitle);
+ final shareLinkData = await _getOrCreateMemoryLink(
+ context,
+ inheritedData,
+ memoryTitle,
+ );
+ if (!context.mounted || shareLinkData == null) {
+ return;
+ }
+ await showMemoryLinkDetailsSheet(
+ context,
+ shareUrl: shareLinkData.$1,
+ shareId: shareLinkData.$2,
+ );
return;
}
@@ -894,134 +903,6 @@ Future<void> _showMemoryShareSheet(
await share(context, [currentFile]);
}
-Future<void> _showMemoryLinkDetailsSheet(
- BuildContext context,
- FullScreenMemoryData inheritedData,
- String memoryTitle,
-) async {
- final shareLinkData = await _getOrCreateMemoryLink(
- context,
- inheritedData,
- memoryTitle,
- );
- if (!context.mounted || shareLinkData == null) {
- return;
- }
- final shareUrl = shareLinkData.$1;
- final int shareId = shareLinkData.$2;
-
- final l10n = AppLocalizations.of(context);
- await showBaseBottomSheet<void>(
- context,
- title: l10n.shareLink,
- padding: const EdgeInsets.all(16),
- child: Builder(
- builder: (context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(l10n.memoryShareLinkDescription, style: textTheme.smallMuted),
- const SizedBox(height: 14),
- Container(
- width: double.infinity,
- decoration: BoxDecoration(
- color: colorScheme.fillDark,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Stack(
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(12, 16, 12, 16),
- child: SelectableText(shareUrl, style: textTheme.small),
- ),
- Positioned(
- right: 0,
- top: 0,
- child: IconButton(
- tooltip: l10n.copyLink,
- iconSize: 20,
- visualDensity: VisualDensity.compact,
- onPressed: () async {
- await Clipboard.setData(ClipboardData(text: shareUrl));
- if (context.mounted) {
- showShortToast(context, l10n.linkCopiedToClipboard);
- }
- },
- icon: HugeIcon(
- icon: HugeIcons.strokeRoundedCopy01,
- color: colorScheme.textBase,
- size: 20,
- ),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 24),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: l10n.shareLink,
- shouldSurfaceExecutionStates: false,
- onTap: () async {
- await shareText(shareUrl, context: context);
- },
- ),
- const SizedBox(height: 16),
- Center(
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.critical,
- labelText: l10n.deleteLink,
- onTap: () async {
- final shouldDelete = await showAlertBottomSheet<bool>(
- context,
- title: l10n.deleteLinkQuestion,
- message: l10n.deleteMemoryLinkMessage,
- assetPath: "assets/warning-grey.png",
- buttons: [
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.critical,
- labelText: l10n.deleteLink,
- onTap: () async {
- try {
- await MemoryShareService.instance.deleteMemoryShare(
- shareId,
- );
- if (context.mounted) {
- showShortToast(
- context,
- l10n.linkDeletedSuccessfully,
- );
- Navigator.of(context).pop(true);
- }
- } catch (e) {
- if (context.mounted) {
- showShortToast(context, l10n.somethingWentWrong);
- Navigator.of(context).pop(false);
- }
- }
- },
- ),
- ],
- );
- if (shouldDelete != true) {
- return;
- }
- if (context.mounted) {
- Navigator.of(context).pop();
- }
- },
- ),
- ),
- ],
- );
- },
- ),
- );
-}
-
Future<(String, int)?> _getOrCreateMemoryLink(
BuildContext context,
FullScreenMemoryData inheritedData,
diff --git a/mobile/apps/photos/lib/ui/sharing/memory_link_details_sheet.dart b/mobile/apps/photos/lib/ui/sharing/memory_link_details_sheet.dart
new file mode 100644
index 0000000000..593a75d62f
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/sharing/memory_link_details_sheet.dart
@@ -0,0 +1,128 @@
+import "package:flutter/material.dart";
+import "package:flutter/services.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/services/memory_share_service.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/components/alert_bottom_sheet.dart";
+import "package:photos/ui/components/base_bottom_sheet.dart";
+import "package:photos/ui/components/buttons/button_widget_v2.dart";
+import "package:photos/ui/notification/toast.dart";
+import "package:photos/utils/share_util.dart";
+
+Future<bool?> showMemoryLinkDetailsSheet(
+ BuildContext context, {
+ required String shareUrl,
+ required int shareId,
+}) {
+ final l10n = AppLocalizations.of(context);
+ return showBaseBottomSheet<bool>(
+ context,
+ title: l10n.shareLink,
+ padding: const EdgeInsets.all(16),
+ child: Builder(
+ builder: (context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(l10n.memoryShareLinkDescription, style: textTheme.smallMuted),
+ const SizedBox(height: 14),
+ Container(
+ width: double.infinity,
+ decoration: BoxDecoration(
+ color: colorScheme.fillDark,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ child: Stack(
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(12, 16, 12, 16),
+ child: SelectableText(shareUrl, style: textTheme.small),
+ ),
+ Positioned(
+ right: 0,
+ top: 0,
+ child: IconButton(
+ tooltip: l10n.copyLink,
+ iconSize: 20,
+ visualDensity: VisualDensity.compact,
+ onPressed: () async {
+ await Clipboard.setData(ClipboardData(text: shareUrl));
+ if (context.mounted) {
+ showShortToast(context, l10n.linkCopiedToClipboard);
+ }
+ },
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedCopy01,
+ color: colorScheme.textBase,
+ size: 20,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: 24),
+ ButtonWidgetV2(
+ buttonType: ButtonTypeV2.primary,
+ labelText: l10n.shareLink,
+ shouldSurfaceExecutionStates: false,
+ onTap: () async {
+ await shareText(shareUrl, context: context);
+ },
+ ),
+ const SizedBox(height: 16),
+ Center(
+ child: ButtonWidgetV2(
+ buttonType: ButtonTypeV2.critical,
+ labelText: l10n.deleteLink,
+ onTap: () async {
+ final shouldDelete = await showAlertBottomSheet<bool>(
+ context,
+ title: l10n.deleteLinkQuestion,
+ message: l10n.deleteMemoryLinkMessage,
+ assetPath: "assets/warning-grey.png",
+ buttons: [
+ ButtonWidgetV2(
+ buttonType: ButtonTypeV2.critical,
+ labelText: l10n.deleteLink,
+ onTap: () async {
+ try {
+ await MemoryShareService.instance.deleteMemoryShare(
+ shareId,
+ );
+ if (context.mounted) {
+ showShortToast(
+ context,
+ l10n.linkDeletedSuccessfully,
+ );
+ Navigator.of(context).pop(true);
+ }
+ } catch (_) {
+ if (context.mounted) {
+ showShortToast(context, l10n.somethingWentWrong);
+ Navigator.of(context).pop(false);
+ }
+ }
+ },
+ ),
+ ],
+ );
+ if (shouldDelete != true) {
+ return;
+ }
+ if (context.mounted) {
+ Navigator.of(context).pop(true);
+ }
+ },
+ ),
+ ),
+ ],
+ );
+ },
+ ),
+ );
+}
diff --git a/mobile/apps/photos/lib/ui/tabs/shared/all_memory_links_page.dart b/mobile/apps/photos/lib/ui/tabs/shared/all_memory_links_page.dart
new file mode 100644
index 0000000000..5d092afd67
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/tabs/shared/all_memory_links_page.dart
@@ -0,0 +1,109 @@
+import "package:flutter/material.dart";
+import "package:photos/models/api/memory_share/memory_share.dart";
+import "package:photos/services/memory_share_service.dart";
+import "package:photos/ui/components/title_bar_title_widget.dart";
+import "package:photos/ui/sharing/memory_link_details_sheet.dart";
+import "package:photos/ui/tabs/shared/memory_link_item.dart";
+
+class AllMemoryLinksPage extends StatefulWidget {
+ final List<MemoryShare> memoryShares;
+ final String titleHeroTag;
+
+ const AllMemoryLinksPage({
+ required this.memoryShares,
+ required this.titleHeroTag,
+ super.key,
+ });
+
+ @override
+ State<AllMemoryLinksPage> createState() => _AllMemoryLinksPageState();
+}
+
+class _AllMemoryLinksPageState extends State<AllMemoryLinksPage> {
+ Future<void> _openMemoryLink(MemoryShare share) async {
+ final deleted = await showMemoryLinkDetailsSheet(
+ context,
+ shareUrl: share.url,
+ shareId: share.id,
+ );
+ if (deleted != true || !mounted) {
+ return;
+ }
+
+ setState(() {
+ widget.memoryShares
+ .removeWhere((memoryShare) => memoryShare.id == share.id);
+ });
+
+ if (widget.memoryShares.isEmpty && mounted) {
+ Navigator.of(context).pop();
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ toolbarHeight: 48,
+ leadingWidth: 48,
+ leading: GestureDetector(
+ onTap: () {
+ Navigator.pop(context);
+ },
+ child: const Icon(Icons.arrow_back_outlined),
+ ),
+ ),
+ body: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ TitleBarTitleWidget(
+ title: "Memory Links",
+ heroTag: widget.titleHeroTag,
+ ),
+ Text(widget.memoryShares.length.toString()),
+ ],
+ ),
+ ),
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ vertical: 20,
+ horizontal: 16,
+ ),
+ child: ListView.separated(
+ physics: const BouncingScrollPhysics(),
+ itemBuilder: (context, index) {
+ final share = widget.memoryShares[index];
+ final title =
+ MemoryShareService.instance.getMemoryShareTitle(share) ??
+ "Memory link";
+ return GestureDetector(
+ onTap: () async {
+ await _openMemoryLink(share);
+ },
+ behavior: HitTestBehavior.opaque,
+ child: MemoryLinkAlbumItem(
+ title: title,
+ fileCount: share.fileCount,
+ previewUploadedFileID: share.previewUploadedFileID,
+ shareUrl: share.url,
+ ),
+ );
+ },
+ separatorBuilder: (context, index) {
+ return const SizedBox(height: 10);
+ },
+ itemCount: widget.memoryShares.length,
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/tabs/shared/memory_link_item.dart b/mobile/apps/photos/lib/ui/tabs/shared/memory_link_item.dart
index 4e967f1b8d..000ed8f81d 100644
--- a/mobile/apps/photos/lib/ui/tabs/shared/memory_link_item.dart
+++ b/mobile/apps/photos/lib/ui/tabs/shared/memory_link_item.dart
@@ -1,6 +1,8 @@
import "package:flutter/material.dart";
+import "package:logging/logging.dart";
import "package:photos/db/files_db.dart";
import 'package:photos/models/file/file.dart';
+import "package:photos/services/memory_share_service.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";
@@ -8,17 +10,51 @@ import "package:photos/ui/viewer/file/thumbnail_widget.dart";
class MemoryLinkAlbumItem extends StatelessWidget {
static const heroTagPrefix = "memory_link";
+ static final _logger = Logger("MemoryLinkAlbumItem");
final String title;
final int? fileCount;
final int? previewUploadedFileID;
+ final String? shareUrl;
const MemoryLinkAlbumItem({
super.key,
required this.title,
this.fileCount,
this.previewUploadedFileID,
+ this.shareUrl,
});
+ Future<EnteFile?> _loadPreviewFile() async {
+ final uploadedID = previewUploadedFileID;
+ if (uploadedID != null) {
+ final localFile = await FilesDB.instance.getAnyUploadedFile(uploadedID);
+ if (localFile != null) {
+ return localFile;
+ }
+ }
+
+ final resolvedShareUrl = shareUrl;
+ if (resolvedShareUrl == null || resolvedShareUrl.isEmpty) {
+ return null;
+ }
+
+ try {
+ final files = await MemoryShareService.instance
+ .getPublicMemoryFiles(resolvedShareUrl);
+ if (files.isEmpty) {
+ return null;
+ }
+ return files.first;
+ } catch (e, s) {
+ _logger.warning(
+ "Failed to resolve preview file for memory link $resolvedShareUrl",
+ e,
+ s,
+ );
+ return null;
+ }
+ }
+
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
@@ -42,13 +78,7 @@ class MemoryLinkAlbumItem extends StatelessWidget {
width: 60,
height: 60,
child: FutureBuilder<EnteFile?>(
- future: () {
- final uploadedID = previewUploadedFileID;
- if (uploadedID == null) {
- return Future.value(null);
- }
- return FilesDB.instance.getAnyUploadedFile(uploadedID);
- }(),
+ future: _loadPreviewFile(),
builder: (context, snapshot) {
if (snapshot.hasData && snapshot.data != null) {
final String heroTag =
diff --git a/mobile/apps/photos/lib/ui/tabs/shared_collections_tab.dart b/mobile/apps/photos/lib/ui/tabs/shared_collections_tab.dart
index 08b0745e6d..c170bd3ac6 100644
--- a/mobile/apps/photos/lib/ui/tabs/shared_collections_tab.dart
+++ b/mobile/apps/photos/lib/ui/tabs/shared_collections_tab.dart
@@ -14,10 +14,12 @@ import "package:photos/events/local_photos_updated_event.dart";
import "package:photos/events/tab_changed_event.dart";
import "package:photos/events/user_logged_out_event.dart";
import "package:photos/generated/l10n.dart";
+import "package:photos/models/api/memory_share/memory_share.dart";
import "package:photos/models/collection/collection_items.dart";
import "package:photos/models/search/generic_search_result.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/collections_service.dart";
+import "package:photos/services/memory_share_service.dart";
import "package:photos/services/search_service.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/collections/album/row_item.dart";
@@ -25,10 +27,12 @@ import "package:photos/ui/collections/collection_list_page.dart";
import "package:photos/ui/common/loading_widget.dart";
import "package:photos/ui/components/banners/shared_empty_offline_state_widget.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
+import "package:photos/ui/sharing/memory_link_details_sheet.dart";
import "package:photos/ui/social/widgets/feed_preview_widget.dart";
import "package:photos/ui/tabs/section_title.dart";
import "package:photos/ui/tabs/shared/all_quick_links_page.dart";
import "package:photos/ui/tabs/shared/empty_state.dart";
+import "package:photos/ui/tabs/shared/memory_link_item.dart";
import "package:photos/ui/tabs/shared/quick_link_album_item.dart";
import "package:photos/ui/viewer/gallery/collect_photos_card_widget.dart";
import "package:photos/ui/viewer/gallery/collection_page.dart";
@@ -187,30 +191,29 @@ class _SharedCollectionsTabState extends State<SharedCollectionsTab>
super.build(context);
final bool offlineUiMode =
isOfflineMode && !Configuration.instance.hasConfiguredAccount();
- return FutureBuilder<SharedCollections>(
+ return FutureBuilder<SharedCollectionsWithMemoryLinks>(
future: offlineUiMode
- ? Future.value(SharedCollections.empty())
- : Future.value(
- CollectionsService.instance.getSharedCollections(),
- ),
+ ? Future.value(SharedCollectionsWithMemoryLinks.empty())
+ : CollectionsService.instance.getSharedCollectionsWithMemoryLinks(),
builder: (context, snapshot) {
if (snapshot.hasData) {
+ final data = snapshot.data!;
if (offlineUiMode) {
return const SafeArea(
child: SharedEmptyOfflineStateWidget(),
);
}
- final collections = snapshot.data!;
- final hasSharedCollections = collections.incoming.isNotEmpty ||
- collections.quickLinks.isNotEmpty ||
- collections.outgoing.isNotEmpty;
- if (!hasSharedCollections) {
- return const SafeArea(
- child: SharedEmptyStateWidget(),
- );
+ if (data.collections.incoming.isEmpty &&
+ data.collections.quickLinks.isEmpty &&
+ data.collections.outgoing.isEmpty &&
+ data.memoryLinks.isEmpty) {
+ return const Center(child: SharedEmptyStateWidget());
}
return SafeArea(
- child: _getSharedCollectionsGallery(collections),
+ child: _getSharedCollectionsGallery(
+ data.collections,
+ data.memoryLinks,
+ ),
);
} else if (snapshot.hasError) {
_logger.severe(
@@ -228,8 +231,12 @@ class _SharedCollectionsTabState extends State<SharedCollectionsTab>
);
}
- Widget _getSharedCollectionsGallery(SharedCollections collections) {
+ Widget _getSharedCollectionsGallery(
+ SharedCollections collections,
+ List<MemoryShare> memoryLinks,
+ ) {
const maxQuickLinks = 4;
+ const maxMemoryLinks = 4;
final numberOfQuickLinks = collections.quickLinks.length;
final double screenWidth = MediaQuery.sizeOf(context).width;
final int albumsCountInRow = max(screenWidth ~/ maxThumbnailWidth, 3);
@@ -495,6 +502,57 @@ class _SharedCollectionsTabState extends State<SharedCollectionsTab>
],
)
: const SizedBox.shrink(),
+ memoryLinks.isNotEmpty
+ ? Column(
+ children: [
+ const SectionOptions(
+ Hero(
+ tag: "memory_links",
+ child: SectionTitle(title: "Memory Links"),
+ ),
+ ),
+ const SizedBox(height: 2),
+ ListView.separated(
+ shrinkWrap: true,
+ padding: const EdgeInsets.only(
+ bottom: 12,
+ left: 12,
+ right: 12,
+ ),
+ physics: const NeverScrollableScrollPhysics(),
+ itemBuilder: (context, index) {
+ final share = memoryLinks[index];
+ final title = MemoryShareService.instance
+ .getMemoryShareTitle(share) ??
+ "Memory link";
+ return GestureDetector(
+ onTap: () async {
+ final deleted = await showMemoryLinkDetailsSheet(
+ context,
+ shareUrl: share.url,
+ shareId: share.id,
+ );
+ if (deleted == true && mounted) {
+ setState(() {});
+ }
+ },
+ child: MemoryLinkAlbumItem(
+ title: title,
+ fileCount: share.fileCount,
+ previewUploadedFileID:
+ share.previewUploadedFileID,
+ shareUrl: share.url,
+ ),
+ );
+ },
+ separatorBuilder: (context, index) {
+ return const SizedBox(height: 4);
+ },
+ itemCount: min(memoryLinks.length, maxMemoryLinks),
+ ),
+ ],
+ )
+ : const SizedBox.shrink(),
const SizedBox(height: 2),
ValueListenableBuilder(
valueListenable: _canLoadDeferredWidgets,
diff --git a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart
index b42ed27271..cbe452ccbf 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/memory_lane_page.dart
@@ -21,13 +21,10 @@ import "package:photos/services/memory_share_service.dart";
import "package:photos/theme/colors.dart";
import "package:photos/theme/effects.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/alert_bottom_sheet.dart";
-import "package:photos/ui/components/base_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import "package:photos/ui/notification/toast.dart";
+import "package:photos/ui/sharing/memory_link_details_sheet.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/face/face_thumbnail_cache.dart";
-import "package:photos/utils/share_util.dart";
class MemoryLanePage extends StatefulWidget {
final PersonEntity person;
@@ -625,7 +622,16 @@ class _MemoryLanePageState extends State<MemoryLanePage>
tooltip: l10n.shareLink,
onTap: () async {
_pausePlayback();
- await _showMemoryLaneLinkDetailsSheet(context);
+ final shareLinkData =
+ await _getOrCreateMemoryLaneLinkData(context);
+ if (!context.mounted || shareLinkData == null) {
+ return;
+ }
+ await showMemoryLinkDetailsSheet(
+ context,
+ shareUrl: shareLinkData.$1,
+ shareId: shareLinkData.$2,
+ );
},
),
if (_showShareAction) const SizedBox(width: 12),
@@ -1072,137 +1078,6 @@ class _MemoryLanePageState extends State<MemoryLanePage>
);
}
- Future<void> _showMemoryLaneLinkDetailsSheet(BuildContext context) async {
- final shareLinkData = await _getOrCreateMemoryLaneLinkData(context);
- if (!context.mounted || shareLinkData == null) {
- return;
- }
- final l10n = context.l10n;
- final shareUrl = shareLinkData.$1;
- final int shareId = shareLinkData.$2;
- await showBaseBottomSheet<void>(
- context,
- title: l10n.shareLink,
- padding: const EdgeInsets.all(16),
- child: Builder(
- builder: (context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- l10n.memoryShareLinkDescription,
- style: textTheme.smallMuted,
- ),
- const SizedBox(height: 14),
- Container(
- width: double.infinity,
- decoration: BoxDecoration(
- color: colorScheme.fillDark,
- borderRadius: BorderRadius.circular(8),
- ),
- child: Stack(
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(12, 16, 44, 16),
- child: SelectableText(shareUrl, style: textTheme.small),
- ),
- Positioned(
- right: 0,
- top: 0,
- child: IconButton(
- tooltip: l10n.copyLink,
- iconSize: 20,
- visualDensity: VisualDensity.compact,
- onPressed: () async {
- await Clipboard.setData(
- ClipboardData(text: shareUrl),
- );
- if (context.mounted) {
- showShortToast(
- context,
- l10n.linkCopiedToClipboard,
- );
- }
- },
- icon: Icon(
- Icons.copy_rounded,
- color: colorScheme.textBase,
- size: 20,
- ),
- ),
- ),
- ],
- ),
- ),
- const SizedBox(height: 24),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: l10n.shareLink,
- shouldSurfaceExecutionStates: false,
- onTap: () async {
- await shareText(shareUrl, context: context);
- },
- ),
- const SizedBox(height: 16),
- Center(
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.critical,
- labelText: l10n.deleteLink,
- onTap: () async {
- final shouldDelete = await showAlertBottomSheet<bool>(
- context,
- title: l10n.deleteLinkQuestion,
- message: l10n.deleteMemoryLinkMessage,
- assetPath: "assets/warning-grey.png",
- buttons: [
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.critical,
- labelText: l10n.deleteLink,
- onTap: () async {
- try {
- await MemoryShareService.instance
- .deleteMemoryShare(
- shareId,
- );
- if (context.mounted) {
- showShortToast(
- context,
- l10n.linkDeletedSuccessfully,
- );
- Navigator.of(context).pop(true);
- }
- } catch (_) {
- if (context.mounted) {
- showShortToast(
- context,
- l10n.somethingWentWrong,
- );
- Navigator.of(context).pop(false);
- }
- }
- },
- ),
- ],
- );
- if (shouldDelete != true) {
- return;
- }
- if (context.mounted) {
- Navigator.of(context).pop();
- }
- },
- ),
- ),
- ],
- );
- },
- ),
- );
- }
-
Future<(String, int)?> _getOrCreateMemoryLaneLinkData(
BuildContext context,
) async {