diff --git a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Actions/GeneralBrowserAction.swift b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Actions/GeneralBrowserAction.swift index 37d42f2690a2..7dfcd5c96fd0 100644 --- a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Actions/GeneralBrowserAction.swift +++ b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Actions/GeneralBrowserAction.swift @@ -37,6 +37,7 @@ enum GeneralBrowserActionType: ActionType { case showTabTray case showQRcodeReader case showBackForwardList + case showTabsLongPressActions } class GeneralBrowserMiddlewareAction: Action { diff --git a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+TabToolbarDelegate.swift b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+TabToolbarDelegate.swift index aadede2ce4a2..f81124edfdc7 100644 --- a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+TabToolbarDelegate.swift +++ b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+TabToolbarDelegate.swift @@ -271,20 +271,10 @@ extension BrowserViewController: TabToolbarDelegate, PhotonActionSheetProtocol { } func tabToolbarDidLongPressTabs(_ tabToolbar: TabToolbarProtocol, button: UIButton) { - guard self.presentedViewController == nil else { return } - var actions: [[PhotonRowActions]] = [] - actions.append(getTabToolbarLongPressActionsForModeSwitching()) - actions.append(getMoreTabToolbarLongPressActions()) - let generator = UIImpactFeedbackGenerator(style: .heavy) generator.impactOccurred() - let viewModel = PhotonActionSheetViewModel( - actions: actions, - closeButtonTitle: .CloseButtonTitle, - modalStyle: .overCurrentContext - ) - presentSheetWith(viewModel: viewModel, on: self, from: button) + presentActionSheet(from: button) } func tabToolbarDidPressSearch(_ tabToolbar: TabToolbarProtocol, button: UIButton) { diff --git a/firefox-ios/Client/Frontend/Browser/BrowserViewController/State/BrowserViewControllerState.swift b/firefox-ios/Client/Frontend/Browser/BrowserViewController/State/BrowserViewControllerState.swift index b54fdf72556a..2336bffffad5 100644 --- a/firefox-ios/Client/Frontend/Browser/BrowserViewController/State/BrowserViewControllerState.swift +++ b/firefox-ios/Client/Frontend/Browser/BrowserViewController/State/BrowserViewControllerState.swift @@ -27,6 +27,7 @@ struct BrowserViewControllerState: ScreenState, Equatable { var navigateTo: NavigationType? var showQRcodeReader: Bool var showBackForwardList: Bool + var showTabsLongPressActions: Bool var microsurveyState: MicrosurveyPromptState init(appState: AppState, uuid: WindowUUID) { @@ -51,6 +52,7 @@ struct BrowserViewControllerState: ScreenState, Equatable { navigateTo: bvcState.navigateTo, showQRcodeReader: bvcState.showQRcodeReader, showBackForwardList: bvcState.showBackForwardList, + showTabsLongPressActions: bvcState.showTabsLongPressActions, microsurveyState: bvcState.microsurveyState) } @@ -67,6 +69,7 @@ struct BrowserViewControllerState: ScreenState, Equatable { navigateTo: nil, showQRcodeReader: false, showBackForwardList: false, + showTabsLongPressActions: false, microsurveyState: MicrosurveyPromptState(windowUUID: windowUUID)) } @@ -83,6 +86,7 @@ struct BrowserViewControllerState: ScreenState, Equatable { navigateTo: NavigationType? = nil, showQRcodeReader: Bool = false, showBackForwardList: Bool = false, + showTabsLongPressActions: Bool = false, microsurveyState: MicrosurveyPromptState ) { self.searchScreenState = searchScreenState @@ -97,6 +101,7 @@ struct BrowserViewControllerState: ScreenState, Equatable { self.navigateTo = navigateTo self.showQRcodeReader = showQRcodeReader self.showBackForwardList = showBackForwardList + self.showTabsLongPressActions = showTabsLongPressActions self.microsurveyState = microsurveyState } @@ -251,6 +256,20 @@ struct BrowserViewControllerState: ScreenState, Equatable { showQRcodeReader: false, showBackForwardList: true, microsurveyState: MicrosurveyPromptState.reducer(state.microsurveyState, action)) + case GeneralBrowserActionType.showTabsLongPressActions: + return BrowserViewControllerState( + searchScreenState: state.searchScreenState, + showDataClearanceFlow: state.showDataClearanceFlow, + toolbarState: state.toolbarState, + fakespotState: state.fakespotState, + toast: state.toast, + windowUUID: state.windowUUID, + browserViewType: state.browserViewType, + navigateTo: nil, + showQRcodeReader: false, + showBackForwardList: false, + showTabsLongPressActions: true, + microsurveyState: MicrosurveyPromptState.reducer(state.microsurveyState, action)) case GeneralBrowserActionType.navigateBack: return BrowserViewControllerState( searchScreenState: state.searchScreenState, diff --git a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift index 93a07b58660d..6f224c0adea4 100644 --- a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift +++ b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Views/BrowserViewController.swift @@ -1795,6 +1795,8 @@ class BrowserViewController: UIViewController, navigationHandler?.showQRCode(delegate: self) } else if state.showBackForwardList { navigationHandler?.showBackForwardList() + } else if state.showTabsLongPressActions { + presentActionSheet(from: view) } } @@ -1860,6 +1862,22 @@ class BrowserViewController: UIViewController, tabManager.selectedTab?.goForward() } + func presentActionSheet(from view: UIView) { + guard presentedViewController == nil else { return } + + var actions: [[PhotonRowActions]] = [] + actions.append(getTabToolbarLongPressActionsForModeSwitching()) + actions.append(getMoreTabToolbarLongPressActions()) + + let viewModel = PhotonActionSheetViewModel( + actions: actions, + closeButtonTitle: .CloseButtonTitle, + modalStyle: .overCurrentContext + ) + + presentSheetWith(viewModel: viewModel, on: self, from: view) + } + func focusOnTabSegment() { let isPrivateTab = tabManager.selectedTab?.isPrivate ?? false let segmentToFocus = isPrivateTab ? TabTrayPanelType.privateTabs : TabTrayPanelType.tabs diff --git a/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarMiddleware.swift b/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarMiddleware.swift index faa1eceafe9b..118265ef3f43 100644 --- a/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarMiddleware.swift +++ b/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarMiddleware.swift @@ -190,6 +190,10 @@ class ToolbarMiddleware: FeatureFlaggable { let action = GeneralBrowserAction(windowUUID: windowUUID, actionType: GeneralBrowserActionType.showBackForwardList) store.dispatch(action) + case .tabs: + let action = GeneralBrowserAction(windowUUID: windowUUID, + actionType: GeneralBrowserActionType.showTabsLongPressActions) + store.dispatch(action) default: break } diff --git a/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarState.swift b/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarState.swift index 8232c161cef8..aa27ac429e69 100644 --- a/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarState.swift +++ b/firefox-ios/Client/Frontend/Browser/Toolbars/Redux/ToolbarState.swift @@ -45,7 +45,8 @@ struct ToolbarState: ScreenState, Equatable { var canPerformLongPressAction: Bool { return actionType == .back || - actionType == .forward + actionType == .forward || + actionType == .tabs } }