Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FXIOS-8703 Share action to library items context menu #19333

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,8 @@
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 */; };
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 */; };
Expand Down Expand Up @@ -922,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 */; };
Expand Down Expand Up @@ -5844,6 +5845,8 @@
8A7A26E629D4C0D800EA76F1 /* IntroScreenManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntroScreenManagerTests.swift; sourceTree = "<group>"; };
8A7A26E929D4C3C800EA76F1 /* LaunchType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LaunchType.swift; sourceTree = "<group>"; };
8A7A93ED2810ADF2005E7E1B /* ContileProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContileProviderTests.swift; sourceTree = "<group>"; };
8A7AE4432BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryPanelCoordinatorDelegate.swift; sourceTree = "<group>"; };
8A7AE4452BAC76B00072DAEC /* MockLibraryNavigationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockLibraryNavigationHandler.swift; sourceTree = "<group>"; };
8A7D1AC42BA3542600162F4B /* splashScreen.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = splashScreen.json; sourceTree = "<group>"; };
8A832A8F29DC96C50025D5DD /* LaunchScreenView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenView.swift; sourceTree = "<group>"; };
8A832A9129DC99790025D5DD /* LaunchScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchScreenViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6164,7 +6167,6 @@
96D95015270238500079D39D /* Throttler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Throttler.swift; sourceTree = "<group>"; };
96EA9453293655BF00123345 /* AppSession+Enums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppSession+Enums.swift"; sourceTree = "<group>"; };
96EB6C3727D821B800A9D159 /* HistoryPanelViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryPanelViewModel.swift; sourceTree = "<group>"; };
96EB6C3B27D82AEA00A9D159 /* HistoryPanel+ContextMenuExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HistoryPanel+ContextMenuExtensions.swift"; sourceTree = "<group>"; };
96EB6C3D27D9266500A9D159 /* HistoryActionables.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryActionables.swift; sourceTree = "<group>"; };
96EB6C3F27DBEE9800A9D159 /* SearchGroupedItemsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchGroupedItemsViewController.swift; sourceTree = "<group>"; };
96EB6C4227DC205D00A9D159 /* SearchGroupedItemsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchGroupedItemsViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -9076,6 +9078,7 @@
5AE371832A4DD6F50092A760 /* PasswordManagerListViewControllerSpy.swift */,
C23889E42A50329200429673 /* MockParentCoordinatorDelegate.swift */,
C2446B302A856D13000C527D /* MockLibraryCoordinatorDelegate.swift */,
8A7AE4452BAC76B00072DAEC /* MockLibraryNavigationHandler.swift */,
C2D80BEC2AAF3C6B00CDF7A9 /* MockBrowserCoordinator.swift */,
C29B64822AD69C3E00F3244B /* MockQRCodeParentCoordinator.swift */,
21FA8FB12AE856EB0013B815 /* MockTabTrayCoordinatorDelegate.swift */,
Expand Down Expand Up @@ -10005,7 +10008,6 @@
59A6825233896FC846499289 /* HistoryPanel.swift */,
211F00AB27F4D918001D9189 /* HistoryPanel+Search.swift */,
96EB6C3727D821B800A9D159 /* HistoryPanelViewModel.swift */,
96EB6C3B27D82AEA00A9D159 /* HistoryPanel+ContextMenuExtensions.swift */,
96EB6C3D27D9266500A9D159 /* HistoryActionables.swift */,
);
path = HistoryPanel;
Expand Down Expand Up @@ -10104,6 +10106,7 @@
children = (
8A83B7472A264FB7002FF9AC /* LibraryCoordinator.swift */,
C2D1A10C2A66C70000205DCC /* BookmarksCoordinator.swift */,
8A7AE4432BAB510B0072DAEC /* LibraryPanelCoordinatorDelegate.swift */,
C2506C922A6A863600F2B76E /* HistoryCoordinator.swift */,
C2A72A662A76938C002ACCE2 /* DownloadsCoordinator.swift */,
C2A72A682A769460002ACCE2 /* ReadingListCoordinator.swift */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -14309,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 */,
Expand Down Expand Up @@ -14367,6 +14370,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 */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -38,6 +38,7 @@ class BookmarksCoordinator: BaseCoordinator, BookmarksCoordinatorDelegate {

private let profile: Profile
private weak var parentCoordinator: LibraryCoordinatorDelegate?
private weak var navigationHandler: LibraryNavigationHandler?
private let windowUUID: WindowUUID

// MARK: - Initializers
Expand All @@ -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)
}

Expand Down Expand Up @@ -88,4 +91,8 @@ class BookmarksCoordinator: BaseCoordinator, BookmarksCoordinatorDelegate {
}
router.push(detailController)
}

func shareLibraryItem(url: URL, sourceView: UIView) {
navigationHandler?.shareLibraryItem(url: url, sourceView: sourceView)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand All @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -75,14 +76,21 @@ 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)
let bookmarksCoordinator = BookmarksCoordinator(
router: router,
profile: profile,
windowUUID: windowUUID,
parentCoordinator: parentCoordinator
parentCoordinator: parentCoordinator,
navigationHandler: self
)
add(child: bookmarksCoordinator)
(navigationController.topViewController as? BookmarksPanel)?.bookmarkCoordinatorDelegate = bookmarksCoordinator
Expand All @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
protocol LibraryPanelCoordinatorDelegate: AnyObject {
func shareLibraryItem(url: URL, sourceView: UIView)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@
import Foundation
import Storage

protocol ReadingListNavigationHandler: AnyObject {
protocol ReadingListNavigationHandler: AnyObject, LibraryPanelCoordinatorDelegate {
func openUrl(_ url: URL, visitType: VisitType)
}

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)
}

Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,9 @@ extension BookmarksPanel: LibraryPanelContextMenu {
}).items
actions.append(removeAction)

let cell = tableView.cellForRow(at: indexPath)
actions.append(getShareAction(site: site, sourceView: cell ?? self.view, delegate: bookmarkCoordinatorDelegate))

return actions
}
}
Expand Down

This file was deleted.

Loading