From 5b1bc176faf2a91953c7bbab6b3565a3abef2a06 Mon Sep 17 00:00:00 2001 From: Haris Zaman Date: Wed, 24 Jun 2020 20:05:20 +0300 Subject: [PATCH] Fixed #6730: open apps preview should hide all screens in private browsing (#6757) * Fixed #6730: open apps preview should hide all screens in private browsing * #6730 changed color of backdropContainer and changed it edges to fill whole screen, added it TrayView as well * Added new color #1D1133 for Ink90 --- .../Browser/BrowserViewController.swift | 9 +++++--- .../Browser/TabTrayControllerV1.swift | 23 ++++++++++++++++--- Client/Frontend/photon-colors.swift | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Client/Frontend/Browser/BrowserViewController.swift b/Client/Frontend/Browser/BrowserViewController.swift index 35cef7f6e3b7..3c677646894f 100644 --- a/Client/Frontend/Browser/BrowserViewController.swift +++ b/Client/Frontend/Browser/BrowserViewController.swift @@ -342,9 +342,11 @@ class BrowserViewController: UIViewController { return } + view.bringSubviewToFront(webViewContainerBackdrop) webViewContainerBackdrop.alpha = 1 webViewContainer.alpha = 0 urlBar.locationContainer.alpha = 0 + firefoxHomeViewController?.view.alpha = 0 topTabsViewController?.switchForegroundStatus(isInForeground: false) presentedViewController?.popoverPresentationController?.containerView?.alpha = 0 presentedViewController?.view.alpha = 0 @@ -356,12 +358,14 @@ class BrowserViewController: UIViewController { UIView.animate(withDuration: 0.2, delay: 0, options: UIView.AnimationOptions(), animations: { self.webViewContainer.alpha = 1 self.urlBar.locationContainer.alpha = 1 + self.firefoxHomeViewController?.view.alpha = 1 self.topTabsViewController?.switchForegroundStatus(isInForeground: true) self.presentedViewController?.popoverPresentationController?.containerView?.alpha = 1 self.presentedViewController?.view.alpha = 1 self.view.backgroundColor = UIColor.clear }, completion: { _ in self.webViewContainerBackdrop.alpha = 0 + self.view.sendSubviewToBack(self.webViewContainerBackdrop) }) // Re-show toolbar which might have been hidden during scrolling (prior to app moving into the background) @@ -376,7 +380,7 @@ class BrowserViewController: UIViewController { KeyboardHelper.defaultHelper.addDelegate(self) webViewContainerBackdrop = UIView() - webViewContainerBackdrop.backgroundColor = UIColor.Photon.Grey50 + webViewContainerBackdrop.backgroundColor = UIColor.Photon.Ink90 webViewContainerBackdrop.alpha = 0 view.addSubview(webViewContainerBackdrop) @@ -483,7 +487,7 @@ class BrowserViewController: UIViewController { } webViewContainerBackdrop.snp.makeConstraints { make in - make.edges.equalTo(webViewContainer) + make.edges.equalTo(self.view) } } @@ -539,7 +543,6 @@ class BrowserViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - // On iPhone, if we are about to show the On-Boarding, blank out the tab so that it does // not flash before we present. This change of alpha also participates in the animation when // the intro view is dismissed. diff --git a/Client/Frontend/Browser/TabTrayControllerV1.swift b/Client/Frontend/Browser/TabTrayControllerV1.swift index 784cfaa0f1d3..1d4cf3162deb 100644 --- a/Client/Frontend/Browser/TabTrayControllerV1.swift +++ b/Client/Frontend/Browser/TabTrayControllerV1.swift @@ -45,6 +45,8 @@ class TabTrayControllerV1: UIViewController { var tabDisplayManager: TabDisplayManager! var tabCellIdentifer: TabDisplayer.TabCellIdentifer = TabCell.Identifier var otherBrowsingModeOffset = CGPoint.zero + // Backdrop used for displaying greyed background for private tabs + var webViewContainerBackdrop: UIView! var collectionView: UICollectionView! let statusBarBG = UIView() @@ -161,6 +163,10 @@ class TabTrayControllerV1: UIViewController { super.viewDidLoad() tabManager.addDelegate(self) view.accessibilityLabel = NSLocalizedString("Tabs Tray", comment: "Accessibility label for the Tabs Tray view.") + + webViewContainerBackdrop = UIView() + webViewContainerBackdrop.backgroundColor = UIColor.Photon.Ink90 + webViewContainerBackdrop.alpha = 0 collectionView.alwaysBounceVertical = true collectionView.backgroundColor = UIColor.theme.tabTray.background @@ -173,7 +179,7 @@ class TabTrayControllerV1: UIViewController { searchBarHolder.addSubview(roundedSearchBarHolder) searchBarHolder.addSubview(searchBar) searchBarHolder.backgroundColor = UIColor.theme.tabTray.toolbar - [collectionView, toolbar, searchBarHolder, cancelButton].forEach { view.addSubview($0) } + [webViewContainerBackdrop, collectionView, toolbar, searchBarHolder, cancelButton].forEach { view.addSubview($0) } makeConstraints() // The statusBar needs a background color @@ -222,6 +228,11 @@ class TabTrayControllerV1: UIViewController { } fileprivate func makeConstraints() { + + webViewContainerBackdrop.snp.makeConstraints { make in + make.edges.equalTo(self.view) + } + collectionView.snp.makeConstraints { make in make.left.equalTo(view.safeArea.left) make.right.equalTo(view.safeArea.right) @@ -518,20 +529,26 @@ extension TabTrayControllerV1 { extension TabTrayControllerV1 { @objc func appWillResignActiveNotification() { if tabDisplayManager.isPrivate { + webViewContainerBackdrop.alpha = 1 + view.bringSubviewToFront(webViewContainerBackdrop) collectionView.alpha = 0 searchBarHolder.alpha = 0 + emptyPrivateTabsView.alpha = 0 } } @objc func appDidBecomeActiveNotification() { // Re-show any components that might have been hidden because they were being displayed // as part of a private mode tab - UIView.animate(withDuration: 0.2) { + UIView.animate(withDuration: 0.2, animations: { self.collectionView.alpha = 1 - + self.emptyPrivateTabsView.alpha = 1 if self.tabDisplayManager.isPrivate, !self.privateTabsAreEmpty() { self.searchBarHolder.alpha = 1 } + }) { _ in + self.webViewContainerBackdrop.alpha = 0 + self.view.sendSubviewToBack(self.webViewContainerBackdrop) } } } diff --git a/Client/Frontend/photon-colors.swift b/Client/Frontend/photon-colors.swift index 6e53cc1dedc7..bdf8f41bf121 100644 --- a/Client/Frontend/photon-colors.swift +++ b/Client/Frontend/photon-colors.swift @@ -92,7 +92,7 @@ extension UIColor { static let Ink60 = UIColor(rgb: 0x464B76) static let Ink70 = UIColor(rgb: 0x363959) static let Ink80 = UIColor(rgb: 0x202340) - static let Ink90 = UIColor(rgb: 0x0f1126) + static let Ink90 = UIColor(rgb: 0x1D1133) static let White100 = UIColor(rgb: 0xffffff)