Skip to content

Commit

Permalink
defer loading the tab switcher button until view did load (#3326)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/414709148257752/1208092544762425/f
Tech Design URL: 
CC: @bwaresiak 

**Description**:
Defer loading the tab switcher button until view did load to avoid
Lottie trying to do something with the view hierarchy when not
available.

**Steps to test this PR**:
1. On the phone, open, close and re-order tabs. Make sure tab switcher
button reflects correct state.
3. On the iPad, open, close and re-order tabs. Make sure tab switcher
button reflects correct state.
4. Enable "app lock" from settings. Background app. Ensure blank
snapshot view is correct. Foreground app and open / close tabs.
5. Launch the app using a link from cold and while in the background.
  • Loading branch information
brindy authored Sep 5, 2024
1 parent 582f000 commit 3812b58
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion DuckDuckGo/BlankSnapshotViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BlankSnapshotViewController: UIViewController {

let menuButton = MenuButton()

let tabSwitcherButton = TabSwitcherButton()
var tabSwitcherButton: TabSwitcherButton!
let appSettings: AppSettings

var viewCoordinator: MainViewCoordinator!
Expand All @@ -54,6 +54,8 @@ class BlankSnapshotViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

tabSwitcherButton = TabSwitcherButton()

viewCoordinator = MainViewFactory.createViewHierarchy(view)
if appSettings.currentAddressBarPosition.isBottom {
viewCoordinator.moveAddressBarToPosition(.bottom)
Expand Down
5 changes: 3 additions & 2 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class MainViewController: UIViewController {
}()

weak var tabSwitcherController: TabSwitcherViewController?
let tabSwitcherButton = TabSwitcherButton()
var tabSwitcherButton: TabSwitcherButton!

/// Do not reference directly, use `presentedMenuButton`
let menuButton = MenuButton()
var presentedMenuButton: MenuButton {
Expand Down Expand Up @@ -639,6 +639,7 @@ class MainViewController: UIViewController {
}

private func initTabButton() {
tabSwitcherButton = TabSwitcherButton()
tabSwitcherButton.delegate = self
viewCoordinator.toolbarTabSwitcherButton.customView = tabSwitcherButton
viewCoordinator.toolbarTabSwitcherButton.isAccessibilityElement = true
Expand Down
4 changes: 3 additions & 1 deletion DuckDuckGo/TabsBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TabsBarViewController: UIViewController {
weak var delegate: TabsBarDelegate?
private weak var tabsModel: TabsModel?

let tabSwitcherButton = TabSwitcherButton()
var tabSwitcherButton: TabSwitcherButton!
private let longPressTabGesture = UILongPressGestureRecognizer()

private weak var pressedCell: TabsBarCell?
Expand All @@ -72,6 +72,8 @@ class TabsBarViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

tabSwitcherButton = TabSwitcherButton()

decorate()

tabSwitcherButton.delegate = self
Expand Down

0 comments on commit 3812b58

Please sign in to comment.