Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit a23f1e4

Browse files
committed
Fixed hiding statusbar on scroll
1 parent 76810cd commit a23f1e4

8 files changed

Lines changed: 73 additions & 17 deletions

Slide for Reddit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
BE8592C21E0EE72800836C1D /* reddift_config.json in Resources */ = {isa = PBXBuildFile; fileRef = BE8592C11E0EE72800836C1D /* reddift_config.json */; };
304304
BE86300F1E2E6A54004F0E1F /* PostFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE86300E1E2E6A54004F0E1F /* PostFilter.swift */; };
305305
BE8630111E2EDFB2004F0E1F /* SettingsContentFilters.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8630101E2EDFB2004F0E1F /* SettingsContentFilters.swift */; };
306+
BE8643FD25D8AF9F0089E5EB /* UISplitViewController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8643FC25D8AF9F0089E5EB /* UISplitViewController+Extensions.swift */; };
306307
BE8833F1251FB66900131DEB /* ic_space@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BE8833EE251FB66800131DEB /* ic_space@2x.png */; };
307308
BE8833F2251FB66900131DEB /* ic_space@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = BE8833EF251FB66900131DEB /* ic_space@2x~ipad.png */; };
308309
BE8833F3251FB66900131DEB /* ic_space@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = BE8833F0251FB66900131DEB /* ic_space@3x.png */; };
@@ -816,6 +817,7 @@
816817
BE8592C11E0EE72800836C1D /* reddift_config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reddift_config.json; sourceTree = "<group>"; };
817818
BE86300E1E2E6A54004F0E1F /* PostFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostFilter.swift; sourceTree = "<group>"; };
818819
BE8630101E2EDFB2004F0E1F /* SettingsContentFilters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsContentFilters.swift; sourceTree = "<group>"; };
820+
BE8643FC25D8AF9F0089E5EB /* UISplitViewController+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISplitViewController+Extensions.swift"; sourceTree = "<group>"; };
819821
BE8833EE251FB66800131DEB /* ic_space@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ic_space@2x.png"; sourceTree = "<group>"; };
820822
BE8833EF251FB66900131DEB /* ic_space@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ic_space@2x~ipad.png"; sourceTree = "<group>"; };
821823
BE8833F0251FB66900131DEB /* ic_space@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ic_space@3x.png"; sourceTree = "<group>"; };
@@ -1057,6 +1059,7 @@
10571059
BEC4A1A12322F74D00EE5114 /* SFSymbolsEnum.swift */,
10581060
BE2F3BE9253D37EF00FB21EC /* UIResponder+Extensions.swift */,
10591061
BEC9129F258B19AA00E65F34 /* UIBezierPath+Helpers.swift */,
1062+
BE8643FC25D8AF9F0089E5EB /* UISplitViewController+Extensions.swift */,
10601063
);
10611064
name = Extensions;
10621065
sourceTree = "<group>";
@@ -2513,6 +2516,7 @@
25132516
BE2B8A0B1E2602CD0053D493 /* SubredditReorderViewController.swift in Sources */,
25142517
098B5A4320EFC5B600FE201B /* UIButton+Extensions.swift in Sources */,
25152518
BEE206F61F1CF7D3008BB5F1 /* SettingsLinkHandling.swift in Sources */,
2519+
BE8643FD25D8AF9F0089E5EB /* UISplitViewController+Extensions.swift in Sources */,
25162520
323EFB2821434781005157FA /* ProgressBarView.swift in Sources */,
25172521
BEC494281E307D57006618F3 /* GalleryTableViewController.swift in Sources */,
25182522
BE8264E721934221002A540E /* VideoMediaDownloader.swift in Sources */,

Slide for Reddit/AppDelegate.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,4 @@ class NoHomebarSplitViewController: UISplitViewController {
12891289
return .lightContent
12901290
}
12911291
}
1292-
1293-
override var prefersStatusBarHidden: Bool {
1294-
return SettingValues.hideStatusBar
1295-
}
12961292
}

Slide for Reddit/CommentViewController.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi
5858
}
5959

6060
override var prefersStatusBarHidden: Bool {
61-
return SettingValues.hideStatusBar
61+
return SettingValues.hideStatusBar && isToolbarHidden
6262
}
6363

6464
func textChanged(_ string: String) {
@@ -108,7 +108,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi
108108
}
109109

110110
func createJumpButton(_ forced: Bool = false) {
111-
if SettingValues.commentJumpButton == .DISABLED {
111+
if SettingValues.commentJumpButton == .DISABLED || !SettingValues.hideBottomBar {
112112
return
113113
}
114114
if self.navigationController?.view != nil {
@@ -2684,6 +2684,10 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi
26842684
strongSelf.createJumpButton()
26852685
strongSelf.isHiding = false
26862686
}
2687+
2688+
if SettingValues.hideStatusBar {
2689+
self.setNeedsStatusBarAppearanceUpdate()
2690+
}
26872691
}
26882692

26892693
func showUI() {
@@ -2712,6 +2716,10 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi
27122716
}
27132717
self.isToolbarHidden = false
27142718
self.removeJumpButton()
2719+
2720+
if SettingValues.hideStatusBar {
2721+
setNeedsStatusBarAppearanceUpdate()
2722+
}
27152723
}
27162724

27172725
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

Slide for Reddit/MainViewController.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,19 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe
5757
}
5858
var accountB = UIBarButtonItem()
5959
public static var first = true
60+
public var hasAppeared = false
6061

61-
override var prefersStatusBarHidden: Bool {
62-
return SettingValues.hideStatusBar
62+
override var childForStatusBarHidden: UIViewController? {
63+
if hasAppeared && finalSubs.count > currentIndex {
64+
if navigationController?.topViewController != self {
65+
return navigationController?.topViewController
66+
} else {
67+
return viewControllers?.first(where: {
68+
($0 as? SingleSubredditViewController)?.sub == finalSubs[currentIndex]
69+
})
70+
}
71+
}
72+
return nil
6373
}
6474

6575
var statusbarHeight: CGFloat {
@@ -761,6 +771,12 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe
761771
func doRetheme() {
762772
}
763773

774+
override func viewDidAppear(_ animated: Bool) {
775+
super.viewDidAppear(animated)
776+
777+
hasAppeared = true
778+
}
779+
764780
public func viewWillAppearActions(override: Bool = false) {
765781
}
766782

Slide for Reddit/PagingCommentViewController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ class PagingCommentViewController: ColorMuxPagingViewController, UIPageViewContr
1414
var submissionDataSource: SubmissionsDataSource
1515
var startIndex: Int
1616

17-
override var prefersStatusBarHidden: Bool {
18-
return SettingValues.hideStatusBar
17+
override var childForStatusBarHidden: UIViewController? {
18+
if self.submissionDataSource.content.count > currentIndex + startIndex {
19+
return viewControllers?.first(where: {
20+
($0 as? CommentViewController)?.submission?.getId() == self.submissionDataSource.content[currentIndex + startIndex].getId()
21+
})
22+
}
23+
return nil
1924
}
2025

2126
var offline = false

Slide for Reddit/SingleSubredditViewController.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele
4040
return true
4141
}
4242

43-
override var childForHomeIndicatorAutoHidden: UIViewController? {
44-
return nil
45-
}
46-
4743
override var prefersStatusBarHidden: Bool {
48-
return SettingValues.hideStatusBar
44+
return SettingValues.hideStatusBar && isToolbarHidden
4945
}
5046

5147
var autoplayHandler: AutoplayScrollViewHandler!
@@ -604,7 +600,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele
604600
} else {
605601
self.isHiding = false
606602
}
607-
603+
608604
if single || parent is SplitMainViewController {
609605
if SettingValues.hideBottomBar {
610606
self.navigationController?.setToolbarHidden(true, animated: true)
@@ -635,6 +631,10 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele
635631
// }
636632
}
637633
self.isToolbarHidden = true
634+
635+
if SettingValues.hideStatusBar {
636+
setNeedsStatusBarAppearanceUpdate()
637+
}
638638
}
639639

640640
func showUI(_ disableBottom: Bool = false) {
@@ -657,7 +657,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele
657657
self.fab?.transform = CGAffineTransform.identity
658658
})
659659
}
660-
660+
661661
if (single || parent is SplitMainViewController) && !MainViewController.isOffline {
662662
self.navigationController?.setToolbarHidden(false, animated: true)
663663
} else if !disableBottom {
@@ -682,6 +682,10 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele
682682
}*/
683683
}
684684
self.isToolbarHidden = false
685+
686+
if SettingValues.hideStatusBar {
687+
setNeedsStatusBarAppearanceUpdate()
688+
}
685689
}
686690

687691
func show(_ animated: Bool = true) {

Slide for Reddit/SwipeForwardNavigationController.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class SwipeForwardNavigationController: UINavigationController {
3535

3636
setup()
3737
}
38+
39+
override var childForStatusBarHidden: UIViewController? {
40+
return topViewController
41+
}
42+
43+
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
44+
return .slide
45+
}
3846

3947
required init?(coder aDecoder: NSCoder) {
4048
super.init(coder: aDecoder)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// UISplitViewController+Extensions.swift
3+
// Slide for Reddit
4+
//
5+
// Created by Carlos Crane on 2/13/21.
6+
// Copyright © 2021 Haptic Apps. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
extension UISplitViewController {
12+
open override var childForStatusBarHidden: UIViewController? {
13+
return viewControllers.last
14+
}
15+
}

0 commit comments

Comments
 (0)