From e644c0735fe062dae1035c48939398224eedc7bd Mon Sep 17 00:00:00 2001 From: "roux g. buciu" Date: Thu, 17 Oct 2024 15:58:02 -0400 Subject: [PATCH] changes for alex --- .../MainMenu/MainMenuCoordinator.swift | 7 ++- .../MainMenu/Redux/MainMenuState.swift | 40 +++++++++++++ .../Redux/MenuNavigationDestination.swift | 5 +- .../Views/MainMenuViewController.swift | 56 +------------------ 4 files changed, 48 insertions(+), 60 deletions(-) diff --git a/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuCoordinator.swift b/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuCoordinator.swift index 1c1bd13364b4..81508b243ef0 100644 --- a/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuCoordinator.swift +++ b/firefox-ios/Client/Frontend/Browser/MainMenu/MainMenuCoordinator.swift @@ -81,7 +81,12 @@ class MainMenuCoordinator: BaseCoordinator, FeatureFlaggable { case .settings: self.navigationHandler?.showSettings(at: .general) case .syncSignIn: - self.navigationHandler?.showSignInView(fxaParameters: destination.fxaSignInViewParameters) + let fxaParameters = FxASignInViewParameters( + launchParameters: FxALaunchParams(entrypoint: .browserMenu, query: [:]), + flowType: .emailLoginFlow, + referringPage: .appMenu + ) + self.navigationHandler?.showSignInView(fxaParameters: fxaParameters) } self.parentCoordinator?.didFinish(from: self) diff --git a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift index f7e647813eeb..8f179ec831bb 100644 --- a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift +++ b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MainMenuState.swift @@ -134,4 +134,44 @@ struct MainMenuState: ScreenState, Equatable { ) } } + + // Farcaseanu + // we should probably add this somewhere in either the screen showing actionType + // from the VC, or the updateCurrentTabInfo action. + // private func syncMenuButton() -> PhotonRowActions? { + // + // let rustAccount = RustFirefoxAccounts.shared + // let needsReAuth = rustAccount.accountNeedsReauth() + // + // guard let userProfile = rustAccount.userProfile else { + // return SingleActionViewModel(title: .LegacyAppMenu.SyncAndSaveData, + // iconString: StandardImageIdentifiers.Large.sync, + // tapHandler: action).items + // } + // + // let title: String = { + // if rustAccount.accountNeedsReauth() { + // return .FxAAccountVerifyPassword + // } + // return userProfile.displayName ?? userProfile.email + // }() + // + // let warningImage = StandardImageIdentifiers.Large.warningFill + // let avatarImage = StandardImageIdentifiers.Large.avatarCircle + // let iconString = needsReAuth ? warningImage : avatarImage + // + // var iconURL: URL? + // if let str = rustAccount.userProfile?.avatarUrl, + // let url = URL(string: str, invalidCharacters: false) { + // iconURL = url + // } + // let iconType: PhotonActionSheetIconType = needsReAuth ? .Image : .URL + // let syncOption = SingleActionViewModel(title: title, + // iconString: iconString, + // iconURL: iconURL, + // iconType: iconType, + // needsIconActionableTint: needsReAuth, + // tapHandler: action).items + // return syncOption + // } } diff --git a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MenuNavigationDestination.swift b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MenuNavigationDestination.swift index 8037722e8eed..d0aede69ffbd 100644 --- a/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MenuNavigationDestination.swift +++ b/firefox-ios/Client/Frontend/Browser/MainMenu/Redux/MenuNavigationDestination.swift @@ -27,15 +27,12 @@ enum MainMenuDetailsViewType { struct MenuNavigationDestination: Equatable { let destination: MainMenuNavigationDestination let urlToVisit: URL? - let fxaSignInViewParameters: FxASignInViewParameters? init( _ destination: MainMenuNavigationDestination, - urlToVisit: URL? = nil, - fxaSingInViewParameters: FxASignInViewParameters? = nil + urlToVisit: URL? = nil ) { self.destination = destination self.urlToVisit = urlToVisit - self.fxaSignInViewParameters = fxaSingInViewParameters } } diff --git a/firefox-ios/Client/Frontend/Browser/MainMenu/Views/MainMenuViewController.swift b/firefox-ios/Client/Frontend/Browser/MainMenu/Views/MainMenuViewController.swift index 0eee0eaa307e..7460a664fe2f 100644 --- a/firefox-ios/Client/Frontend/Browser/MainMenu/Views/MainMenuViewController.swift +++ b/firefox-ios/Client/Frontend/Browser/MainMenu/Views/MainMenuViewController.swift @@ -98,67 +98,13 @@ class MainMenuViewController: UIViewController, ) } - // private func syncMenuButton() -> PhotonRowActions? { - // let action: (SingleActionViewModel) -> Void = { [weak self] action in - // let fxaParams = FxALaunchParams(entrypoint: .browserMenu, query: [:]) - // let parameters = FxASignInViewParameters(launchParameters: fxaParams, - // flowType: .emailLoginFlow, - // referringPage: .appMenu) - // self?.delegate?.showSignInView(fxaParameters: parameters) - // TelemetryWrapper.recordEvent(category: .action, method: .tap, object: .signIntoSync) - // } - // - // let rustAccount = RustFirefoxAccounts.shared - // let needsReAuth = rustAccount.accountNeedsReauth() - // - // guard let userProfile = rustAccount.userProfile else { - // return SingleActionViewModel(title: .LegacyAppMenu.SyncAndSaveData, - // iconString: StandardImageIdentifiers.Large.sync, - // tapHandler: action).items - // } - // - // let title: String = { - // if rustAccount.accountNeedsReauth() { - // return .FxAAccountVerifyPassword - // } - // return userProfile.displayName ?? userProfile.email - // }() - // - // let warningImage = StandardImageIdentifiers.Large.warningFill - // let avatarImage = StandardImageIdentifiers.Large.avatarCircle - // let iconString = needsReAuth ? warningImage : avatarImage - // - // var iconURL: URL? - // if let str = rustAccount.userProfile?.avatarUrl, - // let url = URL(string: str, invalidCharacters: false) { - // iconURL = url - // } - // let iconType: PhotonActionSheetIconType = needsReAuth ? .Image : .URL - // let syncOption = SingleActionViewModel(title: title, - // iconString: iconString, - // iconURL: iconURL, - // iconType: iconType, - // needsIconActionableTint: needsReAuth, - // tapHandler: action).items - // return syncOption - // } menuContent.accountHeaderView.mainButtonCallback = { [weak self] in guard let self else { return } store.dispatch( MainMenuAction( windowUUID: self.windowUUID, actionType: MainMenuActionType.closeMenuAndNavigateToDestination, - navigationDestination: MenuNavigationDestination( - .syncSignIn, - fxaSingInViewParameters: FxASignInViewParameters( - launchParameters: FxALaunchParams( - entrypoint: .browserMenu, - query: [:] - ), - flowType: .emailLoginFlow, - referringPage: .appMenu - ) - ) + navigationDestination: MenuNavigationDestination(.syncSignIn) ) ) }