@@ -35,10 +35,6 @@ class StatusBarOverlay: UIView,
3535 var notificationCenter : NotificationProtocol = NotificationCenter . default
3636 var hasTopTabs = false
3737
38- private var isToolbarRefactorEnabled : Bool {
39- toolbarHelper. isToolbarRefactorEnabled
40- }
41-
4238 /// Returns a value between 0 and 1 which indicates how far the user has scrolled.
4339 /// This is used as the alpha of the status bar background.
4440 /// 0 = no status bar background shown
@@ -80,17 +76,9 @@ class StatusBarOverlay: UIView,
8076
8177 func resetState( isHomepage: Bool ) {
8278 savedIsHomepage = isHomepage
83-
84- // We only need no status bar for one edge case
85- var needsNoStatusBar = isHomepage && isBottomSearchBar
86- if !isToolbarRefactorEnabled {
87- needsNoStatusBar = needsNoStatusBar && wallpaperManager. currentWallpaper. hasImage
88- }
79+ let needsNoStatusBar = needsNoStatusBar ( isHomepage: isHomepage)
8980 scrollOffset = needsNoStatusBar ? 0 : 1
90-
91- let translucencyBackgroundAlpha = toolbarHelper. backgroundAlpha ( )
92- let alpha = scrollOffset > translucencyBackgroundAlpha ? translucencyBackgroundAlpha : scrollOffset
93- backgroundColor = savedBackgroundColor? . withAlphaComponent ( alpha)
81+ updateStatusBarAlpha ( isHomepage: isHomepage, needsNoStatusBar: needsNoStatusBar)
9482 }
9583
9684 func showOverlay( animated: Bool ) {
@@ -125,22 +113,20 @@ class StatusBarOverlay: UIView,
125113 }
126114 }
127115
128- // MARK: - ThemeApplicable
129-
130- func applyTheme( theme: Theme ) {
131- savedBackgroundColor = ( hasTopTabs || isToolbarRefactorEnabled) ? theme. colors. layer3 : theme. colors. layer1
132- let translucencyBackgroundAlpha = toolbarHelper. backgroundAlpha ( )
116+ // MARK: - Helper
133117
134- // We only need no status bar for one edge case
135- let isHomepage = savedIsHomepage ?? false
118+ private func needsNoStatusBar( isHomepage: Bool ) -> Bool {
136119 let isWallpaperedHomepage = isHomepage && wallpaperManager. currentWallpaper. hasImage
137- var needsNoStatusBar : Bool
138120
139- if isToolbarRefactorEnabled {
140- needsNoStatusBar = isHomepage && isBottomSearchBar
121+ if toolbarHelper . shouldBlur ( ) {
122+ return isHomepage && isBottomSearchBar
141123 } else {
142- needsNoStatusBar = isWallpaperedHomepage && isBottomSearchBar
124+ return isWallpaperedHomepage && isBottomSearchBar
143125 }
126+ }
127+
128+ private func updateStatusBarAlpha( isHomepage: Bool , needsNoStatusBar: Bool ) {
129+ let translucencyBackgroundAlpha = toolbarHelper. backgroundAlpha ( )
144130
145131 if needsNoStatusBar {
146132 let alpha = scrollOffset > translucencyBackgroundAlpha ? translucencyBackgroundAlpha : scrollOffset
@@ -150,6 +136,16 @@ class StatusBarOverlay: UIView,
150136 }
151137 }
152138
139+ // MARK: - ThemeApplicable
140+
141+ func applyTheme( theme: Theme ) {
142+ savedBackgroundColor = ( hasTopTabs || toolbarHelper. isToolbarRefactorEnabled) ?
143+ theme. colors. layer3 : theme. colors. layer1
144+ let isHomepage : Bool = savedIsHomepage ?? false
145+ let needsNoStatusBar = needsNoStatusBar ( isHomepage: isHomepage)
146+ updateStatusBarAlpha ( isHomepage: isHomepage, needsNoStatusBar: needsNoStatusBar)
147+ }
148+
153149 // MARK: - StatusBarScrollDelegate
154150
155151 func scrollViewDidScroll( _ scrollView: UIScrollView , statusBarFrame: CGRect ? , theme: Theme ) {
0 commit comments