From 3861c6d1a98d900c754e2088692e42fc292a3248 Mon Sep 17 00:00:00 2001 From: Nuo Xu Date: Tue, 24 Dec 2024 11:48:43 -0500 Subject: [PATCH 1/2] remove tab tray content when in private mode when user moves to home switch --- .../Tabs/TabTray/TabTrayController.swift | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift index fe560bb61650..723de20aa0a6 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift @@ -366,6 +366,21 @@ class TabTrayController: AuthenticationController { shredButton.addTarget(self, action: #selector(shredButtonPressed), for: .touchUpInside) becomeFirstResponder() + + NotificationCenter.default.do { + $0.addObserver( + self, + selector: #selector(sceneWillResignActiveNotification(_:)), + name: UIScene.willDeactivateNotification, + object: nil + ) + $0.addObserver( + self, + selector: #selector(sceneDidBecomeActiveNotification(_:)), + name: UIScene.didActivateNotification, + object: nil + ) + } } override func viewDidAppear(_ animated: Bool) { @@ -770,6 +785,27 @@ class TabTrayController: AuthenticationController { } } + @objc func sceneWillResignActiveNotification(_ notification: NSNotification) { + guard let scene = notification.object as? UIScene, scene == currentScene else { + return + } + + // If we are in the private mode info showing, hide any elements in the tab that we wouldn't want shown + // when the app is in the home switcher + if privateMode { + tabContentView.alpha = 0 + } + } + + @objc func sceneDidBecomeActiveNotification(_ notification: NSNotification) { + guard let scene = notification.object as? UIScene, scene == currentScene else { + return + } + + // Re-show any components that might have been hidden + tabContentView.alpha = 1 + } + func toggleModeChanger() { tabTraySearchController.isActive = false From 393ba6b759b2b59d56a9127c4a07d0decd1109ea Mon Sep 17 00:00:00 2001 From: Nuo Xu Date: Fri, 3 Jan 2025 11:17:28 -0500 Subject: [PATCH 2/2] fix format --- .../Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift b/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift index 723de20aa0a6..460f215a8529 100644 --- a/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift +++ b/ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/TabTrayController.swift @@ -366,7 +366,7 @@ class TabTrayController: AuthenticationController { shredButton.addTarget(self, action: #selector(shredButtonPressed), for: .touchUpInside) becomeFirstResponder() - + NotificationCenter.default.do { $0.addObserver( self,