Skip to content

Commit 161bad3

Browse files
authored
Fix status bar color on regular width size class (duckduckgo#2705)
1 parent 463f8fc commit 161bad3

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

DuckDuckGo/BlankSnapshotViewController.swift

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,30 @@ extension BlankSnapshotViewController: TabSwitcherButtonDelegate {
202202

203203
extension BlankSnapshotViewController {
204204

205-
private func decorate() {
205+
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
206+
super.traitCollectionDidChange(previousTraitCollection)
207+
208+
updateStatusBarBackgroundColor()
209+
}
210+
211+
private func updateStatusBarBackgroundColor() {
206212
let theme = ThemeManager.shared.currentTheme
207-
setNeedsStatusBarAppearanceUpdate()
208213

209-
if AppWidthObserver.shared.isLargeWidth {
210-
viewCoordinator.statusBackground.backgroundColor = theme.tabsBarBackgroundColor
214+
if appSettings.currentAddressBarPosition == .bottom {
215+
viewCoordinator.statusBackground.backgroundColor = theme.backgroundColor
211216
} else {
212-
viewCoordinator.statusBackground.backgroundColor = theme.omniBarBackgroundColor
217+
if AppWidthObserver.shared.isPad && traitCollection.horizontalSizeClass == .regular {
218+
viewCoordinator.statusBackground.backgroundColor = theme.tabsBarBackgroundColor
219+
} else {
220+
viewCoordinator.statusBackground.backgroundColor = theme.omniBarBackgroundColor
221+
}
213222
}
223+
}
224+
225+
private func decorate() {
226+
let theme = ThemeManager.shared.currentTheme
227+
228+
setNeedsStatusBarAppearanceUpdate()
214229

215230
view.backgroundColor = theme.mainViewBackgroundColor
216231

@@ -223,11 +238,6 @@ extension BlankSnapshotViewController {
223238
viewCoordinator.toolbarTabSwitcherButton.tintColor = theme.barTintColor
224239

225240
viewCoordinator.logoText.tintColor = theme.ddgTextTintColor
226-
227-
if appSettings.currentAddressBarPosition == .bottom {
228-
viewCoordinator.statusBackground.backgroundColor = theme.backgroundColor
229-
}
230-
231241
}
232242

233243
}

DuckDuckGo/MainViewController.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class MainViewController: UIViewController {
548548
@objc func onAddressBarPositionChanged() {
549549
viewCoordinator.moveAddressBarToPosition(appSettings.currentAddressBarPosition)
550550
refreshViewsBasedOnAddressBarPosition(appSettings.currentAddressBarPosition)
551-
updateAddressBarPositionRelatedColors()
551+
updateStatusBarBackgroundColor()
552552
}
553553

554554
@objc private func onShowFullURLAddressChanged() {
@@ -2411,13 +2411,19 @@ extension MainViewController: AutoClearWorker {
24112411

24122412
extension MainViewController {
24132413

2414-
private func updateAddressBarPositionRelatedColors() {
2414+
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
2415+
super.traitCollectionDidChange(previousTraitCollection)
2416+
2417+
updateStatusBarBackgroundColor()
2418+
}
2419+
2420+
private func updateStatusBarBackgroundColor() {
24152421
let theme = ThemeManager.shared.currentTheme
24162422

24172423
if appSettings.currentAddressBarPosition == .bottom {
24182424
viewCoordinator.statusBackground.backgroundColor = theme.backgroundColor
24192425
} else {
2420-
if AppWidthObserver.shared.isLargeWidth {
2426+
if AppWidthObserver.shared.isPad && traitCollection.horizontalSizeClass == .regular {
24212427
viewCoordinator.statusBackground.backgroundColor = theme.tabsBarBackgroundColor
24222428
} else {
24232429
viewCoordinator.statusBackground.backgroundColor = theme.omniBarBackgroundColor
@@ -2428,22 +2434,20 @@ extension MainViewController {
24282434
private func decorate() {
24292435
let theme = ThemeManager.shared.currentTheme
24302436

2431-
setNeedsStatusBarAppearanceUpdate()
2437+
updateStatusBarBackgroundColor()
24322438

2433-
updateAddressBarPositionRelatedColors()
2439+
setNeedsStatusBarAppearanceUpdate()
24342440

24352441
view.backgroundColor = theme.mainViewBackgroundColor
24362442

24372443
viewCoordinator.navigationBarContainer.backgroundColor = theme.barBackgroundColor
24382444
viewCoordinator.navigationBarContainer.tintColor = theme.barTintColor
2439-
2440-
2445+
24412446
viewCoordinator.toolbar.barTintColor = theme.barBackgroundColor
24422447
viewCoordinator.toolbar.tintColor = theme.barTintColor
24432448

24442449
viewCoordinator.toolbarTabSwitcherButton.tintColor = theme.barTintColor
24452450

2446-
24472451
viewCoordinator.logoText.tintColor = theme.ddgTextTintColor
24482452
}
24492453

0 commit comments

Comments
 (0)