From eca3feaf0763ce2b953d9b769536252360e64c78 Mon Sep 17 00:00:00 2001 From: cyndichin Date: Thu, 21 Mar 2024 09:50:28 -0400 Subject: [PATCH 1/4] Add FXIOS-8703 Share action to library items context menu --- firefox-ios/Client.xcodeproj/project.pbxproj | 4 +++ .../Library/BookmarksCoordinator.swift | 13 +++++-- .../Library/HistoryCoordinator.swift | 11 ++++-- .../Library/LibraryCoordinator.swift | 34 +++++++++++++++++-- .../LibraryPanelCoordinatorDelegate.swift | 10 ++++++ .../Library/ReadingListCoordinator.swift | 9 ++++- .../Library/Bookmarks/BookmarksPanel.swift | 5 +-- .../HistoryPanel+ContextMenuExtensions.swift | 1 + .../Library/LibraryPanelContextMenu.swift | 10 ++++++ .../Client/Frontend/Library/ReaderPanel.swift | 1 + 10 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift diff --git a/firefox-ios/Client.xcodeproj/project.pbxproj b/firefox-ios/Client.xcodeproj/project.pbxproj index 36b24e65d19a..32c6478090ef 100644 --- a/firefox-ios/Client.xcodeproj/project.pbxproj +++ b/firefox-ios/Client.xcodeproj/project.pbxproj @@ -712,6 +712,7 @@ 8A7A26E829D4C0FE00EA76F1 /* IntroScreenManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A26E629D4C0D800EA76F1 /* IntroScreenManagerTests.swift */; }; 8A7A26EA29D4C3C800EA76F1 /* LaunchType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A26E929D4C3C800EA76F1 /* LaunchType.swift */; }; 8A7A93EE2810ADF2005E7E1B /* ContileProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A93ED2810ADF2005E7E1B /* ContileProviderTests.swift */; }; + 8A7AE4442BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7AE4432BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift */; }; 8A7D1AC52BA3542600162F4B /* splashScreen.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A7D1AC42BA3542600162F4B /* splashScreen.json */; }; 8A832A9029DC96C50025D5DD /* LaunchScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A832A8F29DC96C50025D5DD /* LaunchScreenView.swift */; }; 8A832A9229DC99790025D5DD /* LaunchScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A832A9129DC99790025D5DD /* LaunchScreenViewModel.swift */; }; @@ -5844,6 +5845,7 @@ 8A7A26E629D4C0D800EA76F1 /* IntroScreenManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntroScreenManagerTests.swift; sourceTree = ""; }; 8A7A26E929D4C3C800EA76F1 /* LaunchType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchType.swift; sourceTree = ""; }; 8A7A93ED2810ADF2005E7E1B /* ContileProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContileProviderTests.swift; sourceTree = ""; }; + 8A7AE4432BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryPanelCoordinatorDelegate.swift; sourceTree = ""; }; 8A7D1AC42BA3542600162F4B /* splashScreen.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = splashScreen.json; sourceTree = ""; }; 8A832A8F29DC96C50025D5DD /* LaunchScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenView.swift; sourceTree = ""; }; 8A832A9129DC99790025D5DD /* LaunchScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenViewModel.swift; sourceTree = ""; }; @@ -10104,6 +10106,7 @@ children = ( 8A83B7472A264FB7002FF9AC /* LibraryCoordinator.swift */, C2D1A10C2A66C70000205DCC /* BookmarksCoordinator.swift */, + 8A7AE4432BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift */, C2506C922A6A863600F2B76E /* HistoryCoordinator.swift */, C2A72A662A76938C002ACCE2 /* DownloadsCoordinator.swift */, C2A72A682A769460002ACCE2 /* ReadingListCoordinator.swift */, @@ -13597,6 +13600,7 @@ 396E38F11EE0C8EC00CC180F /* FxAPushMessageHandler.swift in Sources */, 8A76B01629F6EB3900A82607 /* ScreenshotService.swift in Sources */, 8C1953322B85EAB500761B20 /* AutofillHeaderView.swift in Sources */, + 8A7AE4442BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift in Sources */, 8C19532E2B85E7AE00761B20 /* SelfSizingHostingController.swift in Sources */, E4CD9F6D1A77DD2800318571 /* ReaderModeStyleViewController.swift in Sources */, E13E9AB52AAB0FB5001A0E9D /* FakespotViewModel.swift in Sources */, diff --git a/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift b/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift index fd3f37734dfe..94711b53dd0b 100644 --- a/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift +++ b/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift @@ -5,7 +5,7 @@ import Foundation import Storage -protocol BookmarksCoordinatorDelegate: AnyObject { +protocol BookmarksCoordinatorDelegate: AnyObject, LibraryPanelCoordinatorDelegate { func start(from folder: FxBookmarkNode) /// Shows the bookmark detail to modify a bookmark folder @@ -37,7 +37,8 @@ class BookmarksCoordinator: BaseCoordinator, BookmarksCoordinatorDelegate { // MARK: - Properties private let profile: Profile - private weak var parentCoordinator: LibraryCoordinatorDelegate? + weak var parentCoordinator: LibraryCoordinatorDelegate? + weak var navigationHandler: LibraryNavigationHandler? private let windowUUID: WindowUUID // MARK: - Initializers @@ -46,11 +47,13 @@ class BookmarksCoordinator: BaseCoordinator, BookmarksCoordinatorDelegate { router: Router, profile: Profile, windowUUID: WindowUUID, - parentCoordinator: LibraryCoordinatorDelegate? + parentCoordinator: LibraryCoordinatorDelegate?, + navigationHandler: LibraryNavigationHandler? ) { self.profile = profile self.windowUUID = windowUUID self.parentCoordinator = parentCoordinator + self.navigationHandler = navigationHandler super.init(router: router) } @@ -88,4 +91,8 @@ class BookmarksCoordinator: BaseCoordinator, BookmarksCoordinatorDelegate { } router.push(detailController) } + + func shareLibraryItem(url: URL, sourceView: UIView) { + navigationHandler?.shareLibraryItem(url: url, sourceView: sourceView) + } } diff --git a/firefox-ios/Client/Coordinators/Library/HistoryCoordinator.swift b/firefox-ios/Client/Coordinators/Library/HistoryCoordinator.swift index c800142bcc03..1144db040b98 100644 --- a/firefox-ios/Client/Coordinators/Library/HistoryCoordinator.swift +++ b/firefox-ios/Client/Coordinators/Library/HistoryCoordinator.swift @@ -7,7 +7,7 @@ import Common import Shared import Storage -protocol HistoryCoordinatorDelegate: AnyObject { +protocol HistoryCoordinatorDelegate: AnyObject, LibraryPanelCoordinatorDelegate { func showRecentlyClosedTab() /// Shows table view controller with searched sites grouped. @@ -21,6 +21,7 @@ class HistoryCoordinator: BaseCoordinator, HistoryCoordinatorDelegate { private let windowUUID: WindowUUID private let notificationCenter: NotificationProtocol private weak var parentCoordinator: LibraryCoordinatorDelegate? + private weak var navigationHandler: LibraryNavigationHandler? // MARK: - Initializers @@ -29,12 +30,14 @@ class HistoryCoordinator: BaseCoordinator, HistoryCoordinatorDelegate { windowUUID: WindowUUID, router: Router, notificationCenter: NotificationProtocol = NotificationCenter.default, - parentCoordinator: LibraryCoordinatorDelegate? + parentCoordinator: LibraryCoordinatorDelegate?, + navigationHandler: LibraryNavigationHandler? ) { self.profile = profile self.windowUUID = windowUUID self.parentCoordinator = parentCoordinator self.notificationCenter = notificationCenter + self.navigationHandler = navigationHandler super.init(router: router) self.notificationCenter.addObserver( self, @@ -68,6 +71,10 @@ class HistoryCoordinator: BaseCoordinator, HistoryCoordinatorDelegate { router.push(asGroupListVC) } + func shareLibraryItem(url: URL, sourceView: UIView) { + navigationHandler?.shareLibraryItem(url: url, sourceView: sourceView) + } + deinit { notificationCenter.removeObserver(self) } diff --git a/firefox-ios/Client/Coordinators/Library/LibraryCoordinator.swift b/firefox-ios/Client/Coordinators/Library/LibraryCoordinator.swift index 7b36a20a5661..5c78b4abf384 100644 --- a/firefox-ios/Client/Coordinators/Library/LibraryCoordinator.swift +++ b/firefox-ios/Client/Coordinators/Library/LibraryCoordinator.swift @@ -13,9 +13,10 @@ protocol LibraryCoordinatorDelegate: AnyObject, LibraryPanelDelegate, RecentlyCl protocol LibraryNavigationHandler: AnyObject { func start(panelType: LibraryPanelType, navigationController: UINavigationController) + func shareLibraryItem(url: URL, sourceView: UIView) } -class LibraryCoordinator: BaseCoordinator, LibraryPanelDelegate, LibraryNavigationHandler { +class LibraryCoordinator: BaseCoordinator, LibraryPanelDelegate, LibraryNavigationHandler, ParentCoordinatorDelegate { private let profile: Profile private let tabManager: TabManager private var libraryViewController: LibraryViewController! @@ -75,6 +76,12 @@ class LibraryCoordinator: BaseCoordinator, LibraryPanelDelegate, LibraryNavigati } } + func shareLibraryItem(url: URL, sourceView: UIView) { + guard !childCoordinators.contains(where: { $0 is ShareExtensionCoordinator }) else { return } + let coordinator = makeShareExtensionCoordinator() + coordinator.start(url: url, sourceView: sourceView) + } + private func makeBookmarksCoordinator(navigationController: UINavigationController) { guard !childCoordinators.contains(where: { $0 is BookmarksCoordinator }) else { return } let router = DefaultRouter(navigationController: navigationController) @@ -82,7 +89,8 @@ class LibraryCoordinator: BaseCoordinator, LibraryPanelDelegate, LibraryNavigati router: router, profile: profile, windowUUID: windowUUID, - parentCoordinator: parentCoordinator + parentCoordinator: parentCoordinator, + navigationHandler: self ) add(child: bookmarksCoordinator) (navigationController.topViewController as? BookmarksPanel)?.bookmarkCoordinatorDelegate = bookmarksCoordinator @@ -95,7 +103,8 @@ class LibraryCoordinator: BaseCoordinator, LibraryPanelDelegate, LibraryNavigati profile: profile, windowUUID: windowUUID, router: router, - parentCoordinator: parentCoordinator + parentCoordinator: parentCoordinator, + navigationHandler: self ) add(child: historyCoordinator) (navigationController.topViewController as? HistoryPanel)?.historyCoordinatorDelegate = historyCoordinator @@ -119,12 +128,31 @@ class LibraryCoordinator: BaseCoordinator, LibraryPanelDelegate, LibraryNavigati let router = DefaultRouter(navigationController: navigationController) let readingListCoordinator = ReadingListCoordinator( parentCoordinator: parentCoordinator, + navigationHandler: self, router: router ) add(child: readingListCoordinator) (navigationController.topViewController as? ReadingListPanel)?.navigationHandler = readingListCoordinator } + // MARK: - ParentCoordinatorDelegate + + func didFinish(from childCoordinator: any Coordinator) { + remove(child: childCoordinator) + } + + private func makeShareExtensionCoordinator() -> ShareExtensionCoordinator { + let coordinator = ShareExtensionCoordinator( + alertContainer: UIView(), + router: router, + profile: profile, + parentCoordinator: self, + tabManager: tabManager + ) + add(child: coordinator) + return coordinator + } + // MARK: - LibraryPanelDelegate func libraryPanelDidRequestToOpenInNewTab(_ url: URL, isPrivate: Bool) { diff --git a/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift b/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift new file mode 100644 index 000000000000..1637e9e19d0a --- /dev/null +++ b/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift @@ -0,0 +1,10 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import Foundation + +/// Share navigation across the library panels +public protocol LibraryPanelCoordinatorDelegate: AnyObject { + func shareLibraryItem(_ url: URL, sourceView: UIView) +} diff --git a/firefox-ios/Client/Coordinators/Library/ReadingListCoordinator.swift b/firefox-ios/Client/Coordinators/Library/ReadingListCoordinator.swift index e7ae28d55519..86df77eb27eb 100644 --- a/firefox-ios/Client/Coordinators/Library/ReadingListCoordinator.swift +++ b/firefox-ios/Client/Coordinators/Library/ReadingListCoordinator.swift @@ -5,7 +5,7 @@ import Foundation import Storage -protocol ReadingListNavigationHandler: AnyObject { +protocol ReadingListNavigationHandler: AnyObject, LibraryPanelCoordinatorDelegate { func openUrl(_ url: URL, visitType: VisitType) } @@ -13,14 +13,17 @@ class ReadingListCoordinator: BaseCoordinator, ReadingListNavigationHandler { // MARK: - Properties private weak var parentCoordinator: LibraryCoordinatorDelegate? + private weak var navigationHandler: LibraryNavigationHandler? // MARK: - Initializers init( parentCoordinator: LibraryCoordinatorDelegate?, + navigationHandler: LibraryNavigationHandler?, router: Router ) { self.parentCoordinator = parentCoordinator + self.navigationHandler = navigationHandler super.init(router: router) } @@ -29,4 +32,8 @@ class ReadingListCoordinator: BaseCoordinator, ReadingListNavigationHandler { func openUrl(_ url: URL, visitType: VisitType) { parentCoordinator?.libraryPanel(didSelectURL: url, visitType: visitType) } + + func shareLibraryItem(url: URL, sourceView: UIView) { + navigationHandler?.shareLibraryItem(url: url, sourceView: sourceView) + } } diff --git a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift index f5c3b7201f22..bc83b65c7177 100644 --- a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift +++ b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift @@ -26,8 +26,8 @@ class BookmarksPanel: SiteTableViewController, // MARK: - Properties var bookmarksHandler: BookmarksHandler - weak var libraryPanelDelegate: LibraryPanelDelegate? - weak var bookmarkCoordinatorDelegate: BookmarksCoordinatorDelegate? + private weak var libraryPanelDelegate: LibraryPanelDelegate? + private weak var bookmarkCoordinatorDelegate: BookmarksCoordinatorDelegate? var state: LibraryPanelMainState let viewModel: BookmarksPanelViewModel private var logger: Logger @@ -541,6 +541,7 @@ extension BookmarksPanel: LibraryPanelContextMenu { extras: ["gesture": "long-press"]) }).items actions.append(removeAction) + actions.append(getShareAction(site: site, sourceView: self.view, coordinator: bookmarkCoordinatorDelegate)) return actions } diff --git a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift b/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift index bf3da61e0835..b5a094a103e5 100644 --- a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift +++ b/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift @@ -41,6 +41,7 @@ extension HistoryPanel: LibraryPanelContextMenu { actions.append(PhotonRowActions(pinTopSite)) actions.append(PhotonRowActions(removeAction)) + actions.append(getShareAction(site: site, sourceView: self.view, coordinator: historyCoordinatorDelegate)) return actions } } diff --git a/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift b/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift index 49332b944d89..122a77e27911 100644 --- a/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift +++ b/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift @@ -9,6 +9,7 @@ import Shared protocol LibraryPanelContextMenu { func getSiteDetails(for indexPath: IndexPath) -> Site? func getContextMenuActions(for site: Site, with indexPath: IndexPath) -> [PhotonRowActions]? + func getShareAction(site: Site, sourceView: UIView, coordinator: LibraryPanelCoordinatorDelegate?) -> PhotonRowActions func presentContextMenu(for indexPath: IndexPath) func presentContextMenu( for site: Site, @@ -104,4 +105,13 @@ extension LibraryPanelContextMenu { return [openInNewTabAction, openInNewPrivateTabAction] } + + func getShareAction(site: Site, sourceView: UIView, coordinator: LibraryPanelCoordinatorDelegate?) -> PhotonRowActions { + return SingleActionViewModel( + title: .ShareContextMenuTitle, + iconString: StandardImageIdentifiers.Large.shareApple) { _ in + guard let siteURL = URL(string: site.url, invalidCharacters: false) else { return } + coordinator?.shareLibraryItem(url: siteURL, sourceView: sourceView) + }.items + } } diff --git a/firefox-ios/Client/Frontend/Library/ReaderPanel.swift b/firefox-ios/Client/Frontend/Library/ReaderPanel.swift index 06da690ba629..6375d44244a0 100644 --- a/firefox-ios/Client/Frontend/Library/ReaderPanel.swift +++ b/firefox-ios/Client/Frontend/Library/ReaderPanel.swift @@ -600,6 +600,7 @@ extension ReadingListPanel: LibraryPanelContextMenu { }).items actions.append(removeAction) + actions.append(getShareAction(site: site, sourceView: self.view, coordinator: navigationHandler)) return actions } } From ed76bd289e6eff37d71680b2706d0f0639c12f61 Mon Sep 17 00:00:00 2001 From: cyndichin Date: Thu, 21 Mar 2024 10:23:21 -0400 Subject: [PATCH 2/4] add unit tests --- firefox-ios/Client.xcodeproj/project.pbxproj | 4 ++++ .../LibraryPanelCoordinatorDelegate.swift | 2 +- .../Library/Bookmarks/BookmarksPanel.swift | 4 ++-- .../Library/BookmarksCoordinatorTests.swift | 19 +++++++++++++++++- .../Library/HistoryCoordinatorTests.swift | 19 +++++++++++++++++- .../Library/LibraryCoordinatorTests.swift | 16 +++++++++++++++ .../Library/ReadingListCoordinatorTests.swift | 17 ++++++++++++++++ .../Mocks/MockLibraryNavigationHandler.swift | 20 +++++++++++++++++++ 8 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockLibraryNavigationHandler.swift diff --git a/firefox-ios/Client.xcodeproj/project.pbxproj b/firefox-ios/Client.xcodeproj/project.pbxproj index 32c6478090ef..1fac7cb3ba14 100644 --- a/firefox-ios/Client.xcodeproj/project.pbxproj +++ b/firefox-ios/Client.xcodeproj/project.pbxproj @@ -713,6 +713,7 @@ 8A7A26EA29D4C3C800EA76F1 /* LaunchType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A26E929D4C3C800EA76F1 /* LaunchType.swift */; }; 8A7A93EE2810ADF2005E7E1B /* ContileProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7A93ED2810ADF2005E7E1B /* ContileProviderTests.swift */; }; 8A7AE4442BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7AE4432BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift */; }; + 8A7AE4472BAC78230072DAEC /* MockLibraryNavigationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A7AE4452BAC76B00072DAEC /* MockLibraryNavigationHandler.swift */; }; 8A7D1AC52BA3542600162F4B /* splashScreen.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A7D1AC42BA3542600162F4B /* splashScreen.json */; }; 8A832A9029DC96C50025D5DD /* LaunchScreenView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A832A8F29DC96C50025D5DD /* LaunchScreenView.swift */; }; 8A832A9229DC99790025D5DD /* LaunchScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A832A9129DC99790025D5DD /* LaunchScreenViewModel.swift */; }; @@ -5846,6 +5847,7 @@ 8A7A26E929D4C3C800EA76F1 /* LaunchType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchType.swift; sourceTree = ""; }; 8A7A93ED2810ADF2005E7E1B /* ContileProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContileProviderTests.swift; sourceTree = ""; }; 8A7AE4432BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryPanelCoordinatorDelegate.swift; sourceTree = ""; }; + 8A7AE4452BAC76B00072DAEC /* MockLibraryNavigationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockLibraryNavigationHandler.swift; sourceTree = ""; }; 8A7D1AC42BA3542600162F4B /* splashScreen.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = splashScreen.json; sourceTree = ""; }; 8A832A8F29DC96C50025D5DD /* LaunchScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenView.swift; sourceTree = ""; }; 8A832A9129DC99790025D5DD /* LaunchScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenViewModel.swift; sourceTree = ""; }; @@ -9078,6 +9080,7 @@ 5AE371832A4DD6F50092A760 /* PasswordManagerListViewControllerSpy.swift */, C23889E42A50329200429673 /* MockParentCoordinatorDelegate.swift */, C2446B302A856D13000C527D /* MockLibraryCoordinatorDelegate.swift */, + 8A7AE4452BAC76B00072DAEC /* MockLibraryNavigationHandler.swift */, C2D80BEC2AAF3C6B00CDF7A9 /* MockBrowserCoordinator.swift */, C29B64822AD69C3E00F3244B /* MockQRCodeParentCoordinator.swift */, 21FA8FB12AE856EB0013B815 /* MockTabTrayCoordinatorDelegate.swift */, @@ -14371,6 +14374,7 @@ 8A7653C228A2E57D00924ABF /* PocketDataAdaptorTests.swift in Sources */, C8CD80D42A1E268C0097C3AE /* MockGleanPlumbEvaluationUtility.swift in Sources */, E1AEC176286E0CF500062E29 /* JumpBackInViewModelTests.swift in Sources */, + 8A7AE4472BAC78230072DAEC /* MockLibraryNavigationHandler.swift in Sources */, 8A7A26E829D4C0FE00EA76F1 /* IntroScreenManagerTests.swift in Sources */, E1AEC17A286E0CF500062E29 /* WebViewNavigationHandlerTests.swift in Sources */, D3D488591ABB54CD00A93597 /* FileAccessorTests.swift in Sources */, diff --git a/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift b/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift index 1637e9e19d0a..2507dab524a1 100644 --- a/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift +++ b/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift @@ -6,5 +6,5 @@ import Foundation /// Share navigation across the library panels public protocol LibraryPanelCoordinatorDelegate: AnyObject { - func shareLibraryItem(_ url: URL, sourceView: UIView) + func shareLibraryItem(url: URL, sourceView: UIView) } diff --git a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift index bc83b65c7177..38c71c60e1f1 100644 --- a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift +++ b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift @@ -26,8 +26,8 @@ class BookmarksPanel: SiteTableViewController, // MARK: - Properties var bookmarksHandler: BookmarksHandler - private weak var libraryPanelDelegate: LibraryPanelDelegate? - private weak var bookmarkCoordinatorDelegate: BookmarksCoordinatorDelegate? + weak var libraryPanelDelegate: LibraryPanelDelegate? + weak var bookmarkCoordinatorDelegate: BookmarksCoordinatorDelegate? var state: LibraryPanelMainState let viewModel: BookmarksPanelViewModel private var logger: Logger diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/BookmarksCoordinatorTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/BookmarksCoordinatorTests.swift index a08ecbdc5689..afaf510602f1 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/BookmarksCoordinatorTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/BookmarksCoordinatorTests.swift @@ -10,6 +10,7 @@ final class BookmarksCoordinatorTests: XCTestCase { private var router: MockRouter! private var profile: MockProfile! private var parentCoordinator: MockLibraryCoordinatorDelegate! + private var navigationHandler: MockLibraryNavigationHandler! override func setUp() { super.setUp() @@ -17,6 +18,7 @@ final class BookmarksCoordinatorTests: XCTestCase { router = MockRouter(navigationController: UINavigationController()) profile = MockProfile() parentCoordinator = MockLibraryCoordinatorDelegate() + navigationHandler = MockLibraryNavigationHandler() } override func tearDown() { @@ -25,6 +27,7 @@ final class BookmarksCoordinatorTests: XCTestCase { router = nil profile = nil parentCoordinator = nil + navigationHandler = nil } func testStart() { @@ -65,12 +68,26 @@ final class BookmarksCoordinatorTests: XCTestCase { XCTAssertEqual(router.pushCalled, 1) } + func testShowShareExtension_callsNavigationHandlerShareFunction() { + let subject = createSubject() + + subject.shareLibraryItem( + url: URL( + string: "https://www.google.com" + )!, + sourceView: UIView() + ) + + XCTAssertEqual(navigationHandler.didShareLibraryItemCalled, 1) + } + private func createSubject() -> BookmarksCoordinator { let subject = BookmarksCoordinator( router: router, profile: profile, windowUUID: .XCTestDefaultUUID, - parentCoordinator: parentCoordinator + parentCoordinator: parentCoordinator, + navigationHandler: navigationHandler ) trackForMemoryLeaks(subject) return subject diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/HistoryCoordinatorTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/HistoryCoordinatorTests.swift index e56660bbd5c8..a66744a7fb35 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/HistoryCoordinatorTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/HistoryCoordinatorTests.swift @@ -11,6 +11,7 @@ final class HistoryCoordinatorTests: XCTestCase { private var profile: MockProfile! private var parentCoordinator: MockLibraryCoordinatorDelegate! private var notificationCenter: MockNotificationCenter! + private var navigationHandler: MockLibraryNavigationHandler! override func setUp() { super.setUp() @@ -19,6 +20,7 @@ final class HistoryCoordinatorTests: XCTestCase { profile = MockProfile() notificationCenter = MockNotificationCenter() parentCoordinator = MockLibraryCoordinatorDelegate() + navigationHandler = MockLibraryNavigationHandler() } override func tearDown() { @@ -28,6 +30,7 @@ final class HistoryCoordinatorTests: XCTestCase { profile = nil parentCoordinator = nil notificationCenter = nil + navigationHandler = nil } func testShowRecentlyClosedTabs() { @@ -57,13 +60,27 @@ final class HistoryCoordinatorTests: XCTestCase { XCTAssertEqual(notificationCenter.postCallCount, 1) } + func testShowShareExtension_callsNavigationHandlerShareFunction() { + let subject = createSubject() + + subject.shareLibraryItem( + url: URL( + string: "https://www.google.com" + )!, + sourceView: UIView() + ) + + XCTAssertEqual(navigationHandler.didShareLibraryItemCalled, 1) + } + private func createSubject() -> HistoryCoordinator { let subject = HistoryCoordinator( profile: profile, windowUUID: .XCTestDefaultUUID, router: router, notificationCenter: notificationCenter, - parentCoordinator: parentCoordinator + parentCoordinator: parentCoordinator, + navigationHandler: navigationHandler ) trackForMemoryLeaks(subject) return subject diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/LibraryCoordinatorTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/LibraryCoordinatorTests.swift index c50f55ba8d76..f7a947437616 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/LibraryCoordinatorTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/LibraryCoordinatorTests.swift @@ -96,6 +96,22 @@ final class LibraryCoordinatorTests: XCTestCase { XCTAssertEqual(delegate.didFinishSettingsCalled, 1) } + func testShowShareExtension_addsShareExtensionCoordinator() { + let subject = createSubject() + + subject.shareLibraryItem( + url: URL( + string: "https://www.google.com" + )!, + sourceView: UIView() + ) + + XCTAssertEqual(subject.childCoordinators.count, 1) + XCTAssertTrue(subject.childCoordinators.first is ShareExtensionCoordinator) + XCTAssertEqual(mockRouter.presentCalled, 1) + XCTAssertTrue(mockRouter.presentedViewController is UIActivityViewController) + } + // MARK: - Helper func createSubject() -> LibraryCoordinator { let subject = LibraryCoordinator(router: mockRouter, tabManager: MockTabManager()) diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/ReadingListCoordinatorTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/ReadingListCoordinatorTests.swift index 55116353eb7e..f4aae5fe7479 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/ReadingListCoordinatorTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Library/ReadingListCoordinatorTests.swift @@ -9,17 +9,20 @@ import Storage final class ReadingListCoordinatorTests: XCTestCase { var router: MockRouter! var parentCoordinator: MockLibraryCoordinatorDelegate! + private var navigationHandler: MockLibraryNavigationHandler! override func setUp() { super.setUp() router = MockRouter(navigationController: UINavigationController()) parentCoordinator = MockLibraryCoordinatorDelegate() + navigationHandler = MockLibraryNavigationHandler() } override func tearDown() { super.tearDown() router = nil parentCoordinator = nil + navigationHandler = nil } func testOpenUrl() { @@ -35,9 +38,23 @@ final class ReadingListCoordinatorTests: XCTestCase { XCTAssertEqual(parentCoordinator.lastOpenedURL, urlToOpen) } + func testShowShareExtension_callsNavigationHandlerShareFunction() { + let subject = createSubject() + + subject.shareLibraryItem( + url: URL( + string: "https://www.google.com" + )!, + sourceView: UIView() + ) + + XCTAssertEqual(navigationHandler.didShareLibraryItemCalled, 1) + } + private func createSubject() -> ReadingListCoordinator { let subject = ReadingListCoordinator( parentCoordinator: parentCoordinator, + navigationHandler: navigationHandler, router: router ) trackForMemoryLeaks(subject) diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockLibraryNavigationHandler.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockLibraryNavigationHandler.swift new file mode 100644 index 000000000000..2d6289173a3a --- /dev/null +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Coordinators/Mocks/MockLibraryNavigationHandler.swift @@ -0,0 +1,20 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import Foundation + +@testable import Client + +class MockLibraryNavigationHandler: LibraryNavigationHandler { + var didStartCalled = 0 + var didShareLibraryItemCalled = 0 + + func start(panelType: LibraryPanelType, navigationController: UINavigationController) { + didStartCalled += 1 + } + + func shareLibraryItem(url: URL, sourceView: UIView) { + didShareLibraryItemCalled += 1 + } +} From de1b2c467b141a5cc505c6d6c272000ddd8528a2 Mon Sep 17 00:00:00 2001 From: cyndichin Date: Thu, 21 Mar 2024 10:38:08 -0400 Subject: [PATCH 3/4] adjust for iPad view --- firefox-ios/Client.xcodeproj/project.pbxproj | 4 -- .../Library/BookmarksCoordinator.swift | 4 +- .../LibraryPanelCoordinatorDelegate.swift | 2 +- .../Library/Bookmarks/BookmarksPanel.swift | 4 +- .../HistoryPanel+ContextMenuExtensions.swift | 47 ------------------- .../Library/HistoryPanel/HistoryPanel.swift | 43 +++++++++++++++++ .../Library/LibraryPanelContextMenu.swift | 6 +-- .../Client/Frontend/Library/ReaderPanel.swift | 4 +- 8 files changed, 55 insertions(+), 59 deletions(-) delete mode 100644 firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift diff --git a/firefox-ios/Client.xcodeproj/project.pbxproj b/firefox-ios/Client.xcodeproj/project.pbxproj index 1fac7cb3ba14..e4854c64ccea 100644 --- a/firefox-ios/Client.xcodeproj/project.pbxproj +++ b/firefox-ios/Client.xcodeproj/project.pbxproj @@ -924,7 +924,6 @@ 96D95016270238500079D39D /* Throttler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D95015270238500079D39D /* Throttler.swift */; }; 96EA9454293655BF00123345 /* AppSession+Enums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EA9453293655BF00123345 /* AppSession+Enums.swift */; }; 96EB6C3827D821B800A9D159 /* HistoryPanelViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EB6C3727D821B800A9D159 /* HistoryPanelViewModel.swift */; }; - 96EB6C3C27D82AEA00A9D159 /* HistoryPanel+ContextMenuExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EB6C3B27D82AEA00A9D159 /* HistoryPanel+ContextMenuExtensions.swift */; }; 96EB6C3E27D9266500A9D159 /* HistoryActionables.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EB6C3D27D9266500A9D159 /* HistoryActionables.swift */; }; 96EB6C4027DBEE9800A9D159 /* SearchGroupedItemsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EB6C3F27DBEE9800A9D159 /* SearchGroupedItemsViewController.swift */; }; 96EB6C4327DC205D00A9D159 /* SearchGroupedItemsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96EB6C4227DC205D00A9D159 /* SearchGroupedItemsViewModel.swift */; }; @@ -6168,7 +6167,6 @@ 96D95015270238500079D39D /* Throttler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Throttler.swift; sourceTree = ""; }; 96EA9453293655BF00123345 /* AppSession+Enums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppSession+Enums.swift"; sourceTree = ""; }; 96EB6C3727D821B800A9D159 /* HistoryPanelViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryPanelViewModel.swift; sourceTree = ""; }; - 96EB6C3B27D82AEA00A9D159 /* HistoryPanel+ContextMenuExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HistoryPanel+ContextMenuExtensions.swift"; sourceTree = ""; }; 96EB6C3D27D9266500A9D159 /* HistoryActionables.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryActionables.swift; sourceTree = ""; }; 96EB6C3F27DBEE9800A9D159 /* SearchGroupedItemsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchGroupedItemsViewController.swift; sourceTree = ""; }; 96EB6C4227DC205D00A9D159 /* SearchGroupedItemsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchGroupedItemsViewModel.swift; sourceTree = ""; }; @@ -10010,7 +10008,6 @@ 59A6825233896FC846499289 /* HistoryPanel.swift */, 211F00AB27F4D918001D9189 /* HistoryPanel+Search.swift */, 96EB6C3727D821B800A9D159 /* HistoryPanelViewModel.swift */, - 96EB6C3B27D82AEA00A9D159 /* HistoryPanel+ContextMenuExtensions.swift */, 96EB6C3D27D9266500A9D159 /* HistoryActionables.swift */, ); path = HistoryPanel; @@ -14316,7 +14313,6 @@ EBA3B2D22268F57E00728BDB /* BadgeWithBackdrop.swift in Sources */, 8AB5958828413F6C0090F4AE /* RecentlySavedCell.swift in Sources */, 8A83B7482A264FB7002FF9AC /* LibraryCoordinator.swift in Sources */, - 96EB6C3C27D82AEA00A9D159 /* HistoryPanel+ContextMenuExtensions.swift in Sources */, E1CD81C2290C62A600124B27 /* HostingTableViewCell.swift in Sources */, 8AA020EF2B9A37E500771DE0 /* NimbusSplashScreenFeatureLayer.swift in Sources */, 43175DB826B87D2C00C41C31 /* AdsTelemetryHelper.swift in Sources */, diff --git a/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift b/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift index 94711b53dd0b..4c6ec69fa034 100644 --- a/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift +++ b/firefox-ios/Client/Coordinators/Library/BookmarksCoordinator.swift @@ -37,8 +37,8 @@ class BookmarksCoordinator: BaseCoordinator, BookmarksCoordinatorDelegate { // MARK: - Properties private let profile: Profile - weak var parentCoordinator: LibraryCoordinatorDelegate? - weak var navigationHandler: LibraryNavigationHandler? + private weak var parentCoordinator: LibraryCoordinatorDelegate? + private weak var navigationHandler: LibraryNavigationHandler? private let windowUUID: WindowUUID // MARK: - Initializers diff --git a/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift b/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift index 2507dab524a1..13ba88ee5bec 100644 --- a/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift +++ b/firefox-ios/Client/Coordinators/Library/LibraryPanelCoordinatorDelegate.swift @@ -5,6 +5,6 @@ import Foundation /// Share navigation across the library panels -public protocol LibraryPanelCoordinatorDelegate: AnyObject { +protocol LibraryPanelCoordinatorDelegate: AnyObject { func shareLibraryItem(url: URL, sourceView: UIView) } diff --git a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift index 38c71c60e1f1..12b14d89a946 100644 --- a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift +++ b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift @@ -541,7 +541,9 @@ extension BookmarksPanel: LibraryPanelContextMenu { extras: ["gesture": "long-press"]) }).items actions.append(removeAction) - actions.append(getShareAction(site: site, sourceView: self.view, coordinator: bookmarkCoordinatorDelegate)) + + let cell = tableView.cellForRow(at: indexPath) + actions.append(getShareAction(site: site, sourceView: cell ?? self.view, delegate: bookmarkCoordinatorDelegate)) return actions } diff --git a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift b/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift deleted file mode 100644 index b5a094a103e5..000000000000 --- a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel+ContextMenuExtensions.swift +++ /dev/null @@ -1,47 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import Common -import UIKit -import Storage - -extension HistoryPanel: LibraryPanelContextMenu { - func presentContextMenu( - for site: Site, - with indexPath: IndexPath, - completionHandler: @escaping () -> PhotonActionSheet? - ) { - guard let contextMenu = completionHandler() else { return } - - present(contextMenu, animated: true, completion: nil) - } - - func getSiteDetails(for indexPath: IndexPath) -> Site? { - return siteAt(indexPath: indexPath) - } - - func getContextMenuActions(for site: Site, with indexPath: IndexPath) -> [PhotonRowActions]? { - guard var actions = getDefaultContextMenuActions( - for: site, - libraryPanelDelegate: libraryPanelDelegate - ) else { return nil } - - let removeAction = SingleActionViewModel(title: .DeleteFromHistoryContextMenuTitle, - iconString: StandardImageIdentifiers.Large.delete, - tapHandler: { _ in - self.removeHistoryItem(at: indexPath) - }) - - let pinTopSite = SingleActionViewModel(title: .AddToShortcutsActionTitle, - iconString: StandardImageIdentifiers.Large.pin, - tapHandler: { _ in - self.pinToTopSites(site) - }) - - actions.append(PhotonRowActions(pinTopSite)) - actions.append(PhotonRowActions(removeAction)) - actions.append(getShareAction(site: site, sourceView: self.view, coordinator: historyCoordinatorDelegate)) - return actions - } -} diff --git a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift b/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift index cd4e67a39d7d..fce429a99157 100644 --- a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift +++ b/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift @@ -18,6 +18,7 @@ private class FetchInProgressError: MaybeErrorType { @objcMembers class HistoryPanel: UIViewController, LibraryPanel, + LibraryPanelContextMenu, Themeable { struct UX { static let WelcomeScreenItemWidth = 170 @@ -629,6 +630,48 @@ class HistoryPanel: UIViewController, object: .selectedHistoryItem, value: .historyPanelNonGroupItem) } + + // MARK: - LibraryPanelContextMenu + + func presentContextMenu( + for site: Site, + with indexPath: IndexPath, + completionHandler: @escaping () -> PhotonActionSheet? + ) { + guard let contextMenu = completionHandler() else { return } + + present(contextMenu, animated: true, completion: nil) + } + + func getSiteDetails(for indexPath: IndexPath) -> Site? { + return siteAt(indexPath: indexPath) + } + + func getContextMenuActions(for site: Site, with indexPath: IndexPath) -> [PhotonRowActions]? { + guard var actions = getDefaultContextMenuActions( + for: site, + libraryPanelDelegate: libraryPanelDelegate + ) else { return nil } + + let removeAction = SingleActionViewModel(title: .DeleteFromHistoryContextMenuTitle, + iconString: StandardImageIdentifiers.Large.delete, + tapHandler: { _ in + self.removeHistoryItem(at: indexPath) + }) + + let pinTopSite = SingleActionViewModel(title: .AddToShortcutsActionTitle, + iconString: StandardImageIdentifiers.Large.pin, + tapHandler: { _ in + self.pinToTopSites(site) + }) + + actions.append(PhotonRowActions(pinTopSite)) + actions.append(PhotonRowActions(removeAction)) + + let cell = tableView.cellForRow(at: indexPath) + actions.append(getShareAction(site: site, sourceView: cell ?? self.view, delegate: historyCoordinatorDelegate)) + return actions + } } // MARK: - UITableViewDelegate related helpers diff --git a/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift b/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift index 122a77e27911..9fdb5cdaf9d1 100644 --- a/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift +++ b/firefox-ios/Client/Frontend/Library/LibraryPanelContextMenu.swift @@ -9,7 +9,7 @@ import Shared protocol LibraryPanelContextMenu { func getSiteDetails(for indexPath: IndexPath) -> Site? func getContextMenuActions(for site: Site, with indexPath: IndexPath) -> [PhotonRowActions]? - func getShareAction(site: Site, sourceView: UIView, coordinator: LibraryPanelCoordinatorDelegate?) -> PhotonRowActions + func getShareAction(site: Site, sourceView: UIView, delegate: LibraryPanelCoordinatorDelegate?) -> PhotonRowActions func presentContextMenu(for indexPath: IndexPath) func presentContextMenu( for site: Site, @@ -106,12 +106,12 @@ extension LibraryPanelContextMenu { return [openInNewTabAction, openInNewPrivateTabAction] } - func getShareAction(site: Site, sourceView: UIView, coordinator: LibraryPanelCoordinatorDelegate?) -> PhotonRowActions { + func getShareAction(site: Site, sourceView: UIView, delegate: LibraryPanelCoordinatorDelegate?) -> PhotonRowActions { return SingleActionViewModel( title: .ShareContextMenuTitle, iconString: StandardImageIdentifiers.Large.shareApple) { _ in guard let siteURL = URL(string: site.url, invalidCharacters: false) else { return } - coordinator?.shareLibraryItem(url: siteURL, sourceView: sourceView) + delegate?.shareLibraryItem(url: siteURL, sourceView: sourceView) }.items } } diff --git a/firefox-ios/Client/Frontend/Library/ReaderPanel.swift b/firefox-ios/Client/Frontend/Library/ReaderPanel.swift index 6375d44244a0..543c90165b80 100644 --- a/firefox-ios/Client/Frontend/Library/ReaderPanel.swift +++ b/firefox-ios/Client/Frontend/Library/ReaderPanel.swift @@ -600,7 +600,9 @@ extension ReadingListPanel: LibraryPanelContextMenu { }).items actions.append(removeAction) - actions.append(getShareAction(site: site, sourceView: self.view, coordinator: navigationHandler)) + + let cell = tableView.cellForRow(at: indexPath) + actions.append(getShareAction(site: site, sourceView: cell ?? self.view, delegate: navigationHandler)) return actions } } From d2dbc46e01258173229d5649115a20b3885055e1 Mon Sep 17 00:00:00 2001 From: cyndichin Date: Thu, 21 Mar 2024 13:13:31 -0400 Subject: [PATCH 4/4] remove whitespace --- .../Client/Frontend/Library/Bookmarks/BookmarksPanel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift index 12b14d89a946..aaadf8999ab9 100644 --- a/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift +++ b/firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksPanel.swift @@ -541,7 +541,7 @@ extension BookmarksPanel: LibraryPanelContextMenu { extras: ["gesture": "long-press"]) }).items actions.append(removeAction) - + let cell = tableView.cellForRow(at: indexPath) actions.append(getShareAction(site: site, sourceView: cell ?? self.view, delegate: bookmarkCoordinatorDelegate))