Skip to content

Commit

Permalink
Refactor FXIOS-10657 connectETPSettingsNavigationWithBrowserVC (#23885)
Browse files Browse the repository at this point in the history
Refactor FXIOS-10657 connectETPNavigationWithBrowserVC (#23317)
  • Loading branch information
petruSt24 authored Dec 20, 2024
1 parent 38570bc commit efb6ff7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ enum NavigationBrowserActionType: ActionType {
case tapOnCustomizeHomepage
case tapOnCell
case tapOnLink
case tapOnTrackingProtection
case longPressOnCell
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Foundation
enum BrowserNavigationDestination: Equatable {
// Native views
case customizeHomepage
case trackingProtectionSettings

// Webpage views
case link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ struct BrowserViewControllerState: ScreenState, Equatable {
navigationDestination: NavigationDestination(.customizeHomepage)
)

case NavigationBrowserActionType.tapOnTrackingProtection:
return BrowserViewControllerState(
searchScreenState: state.searchScreenState,
showDataClearanceFlow: state.showDataClearanceFlow,
fakespotState: FakespotState.reducer(state.fakespotState, action),
windowUUID: state.windowUUID,
browserViewType: state.browserViewType,
microsurveyState: MicrosurveyPromptState.reducer(state.microsurveyState, action),
navigationDestination: NavigationDestination(.trackingProtectionSettings)
)

case NavigationBrowserActionType.tapOnCell,
NavigationBrowserActionType.tapOnLink:
return BrowserViewControllerState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,8 @@ class BrowserViewController: UIViewController,
switch type.destination {
case .contextMenu:
navigationHandler?.showContextMenu()
case .trackingProtectionSettings:
navigationHandler?.show(settings: .contentBlocker)
case .customizeHomepage:
navigationHandler?.show(settings: .homePage)
case .link:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,18 @@ class TrackingProtectionViewController: UIViewController,
// MARK: Redux
func newState(state: TrackingProtectionState) {
trackingProtectionState = state
// TODO: FXIOS-10657 connect the ETP navigation with the BVC general navigation
if let navDestination = state.navigateTo {
switch navDestination {
case .home:
navigationController?.popToRootViewController(animated: true)
case .back:
navigationController?.popViewController(animated: true)
case .close:
enhancedTrackingProtectionMenuDelegate?.didFinish()
case .settings:
showSettings()
}
}
if let displayView = state.displayView {
switch displayView {
case .blockedTrackersDetails:
Expand Down Expand Up @@ -558,6 +569,15 @@ class TrackingProtectionViewController: UIViewController,
self.navigationController?.pushViewController(detailsVC, animated: true)
}

private func showSettings() {
store.dispatch(
NavigationBrowserAction(
windowUUID: self.windowUUID,
actionType: NavigationBrowserActionType.tapOnTrackingProtection
)
)
}

// MARK: Clear Cookies Alert
func onTapClearCookiesAndSiteData() {
model.onTapClearCookiesAndSiteData(controller: self)
Expand Down

0 comments on commit efb6ff7

Please sign in to comment.