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-10138 [Menu]⁃ Investigate Print option for Save Sub Menu #24149

Merged
merged 1 commit into from
Jan 23, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct AccessibilityIdentifiers {
static let saveToReadingList = "MainMenu.SaveToReadingList"
static let addToShortcuts = "MainMenu.AddToShortcuts"
static let bookmarkThisPage = "MainMenu.BookmarkThisPage"
static let print = "MainMenu.Print"
static let share = "MainMenu.Share"
static let reportBrokenSite = "MainMenu.ReportBrokenSite"
static let readerView = "MainMenu.ReaderViewOn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,14 @@ class BrowserCoordinator: BaseCoordinator,
)
}

func showPrintSheet() {
if let webView = browserViewController.tabManager.selectedTab?.webView {
let printController = UIPrintInteractionController.shared
printController.printFormatter = webView.viewPrintFormatter()
printController.present(animated: true, completionHandler: nil)
}
}

private func makeMenuNavViewController() -> DismissableNavigationViewController? {
if let mainMenuCoordinator = childCoordinators.first(where: { $0 is MainMenuCoordinator }) as? MainMenuCoordinator {
mainMenuCoordinator.dismissMenuModal(animated: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ struct MainMenuConfigurationUtility: Equatable, FeatureFlaggable {
if shouldShowReportSiteIssue {
description += ", \(Preview.ReportBrokenSiteSubtitle)"
}

description += ", \(Preview.PrintSubtitle)"
description += ", \(Preview.ShareSubtitle)"

return description
Expand Down Expand Up @@ -309,7 +311,10 @@ struct MainMenuConfigurationUtility: Equatable, FeatureFlaggable {

return [
firstSection,
MenuSection(options: [configureShareItem(with: uuid, tabInfo: tabInfo)]),
MenuSection(options: [
configurePrintItem(with: uuid, tabInfo: tabInfo),
configureShareItem(with: uuid, tabInfo: tabInfo),
])
]
}

Expand Down Expand Up @@ -341,6 +346,34 @@ struct MainMenuConfigurationUtility: Equatable, FeatureFlaggable {
)
}

private func configurePrintItem(
with uuid: WindowUUID,
tabInfo: MainMenuTabInfo
) -> MenuElement {
return MenuElement(
title: .MainMenu.Submenus.Tools.Print,
iconName: Icons.print,
isEnabled: true,
isActive: false,
a11yLabel: .MainMenu.Submenus.Tools.AccessibilityLabels.Print,
a11yHint: "",
a11yId: AccessibilityIdentifiers.MainMenu.print,
action: {
store.dispatch(
MainMenuAction(
windowUUID: uuid,
actionType: MainMenuActionType.tapNavigateToDestination,
navigationDestination: MenuNavigationDestination(
.printSheet,
url: tabInfo.canonicalURL
),
telemetryInfo: TelemetryInfo(isHomepage: tabInfo.isHomepage)
)
)
}
)
}

private func configureShareItem(
with uuid: WindowUUID,
tabInfo: MainMenuTabInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protocol MainMenuCoordinatorDelegate: AnyObject {
func showFindInPage()
func showSignInView(fxaParameters: FxASignInViewParameters?)
func updateZoomPageBarVisibility()
func showPrintSheet()

/// Open the share sheet to share the currently selected `Tab`.
func showShareSheetForCurrentlySelectedTab()
Expand Down Expand Up @@ -111,6 +112,9 @@ class MainMenuCoordinator: BaseCoordinator, FeatureFlaggable {
)
self.navigationHandler?.showSignInView(fxaParameters: fxaParameters)

case .printSheet:
self.navigationHandler?.showPrintSheet()

case .shareSheet:
self.navigationHandler?.showShareSheetForCurrentlySelectedTab()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ final class MainMenuMiddleware {
static let newInFirefox = "new_in_firefox"
static let tools = "tools"
static let save = "save"
static let print = "print"
static let share = "share"
static let switchToDesktopSite = "switch_to_desktop_site"
static let switchToMobileSite = "switch_to_mobile_site"
Expand Down Expand Up @@ -270,6 +271,9 @@ final class MainMenuMiddleware {
telemetry.mainMenuOptionTapped(with: isHomepage, and: TelemetryAction.newInFirefox)
}

case .printSheet:
telemetry.toolsSubmenuOptionTapped(with: isHomepage, and: TelemetryAction.print)

case .shareSheet:
telemetry.toolsSubmenuOptionTapped(with: isHomepage, and: TelemetryAction.share)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum MainMenuNavigationDestination: Equatable, CaseIterable {
case passwords
case settings
case syncSignIn
case printSheet
case shareSheet
case zoom
}
Expand Down