Add preference for hiding toolbars
This commit is contained in:
parent
b313f37170
commit
86719b4528
|
@ -111,6 +111,17 @@ class BrowserNavigationController: UIViewController {
|
|||
.store(in: &cancellables)
|
||||
|
||||
view.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(panGestureRecognized)))
|
||||
|
||||
Preferences.shared.$hideToolbarsWhenScrolling
|
||||
.sink { [unowned self] (hideToolbarsWhenScrolling) in
|
||||
if !hideToolbarsWhenScrolling {
|
||||
// animate just in case the preference change came from another window and we're currently visible
|
||||
UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseInOut) {
|
||||
self.toolbarOffset = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
|
@ -341,6 +352,7 @@ extension BrowserNavigationController {
|
|||
|
||||
extension BrowserNavigationController: UIScrollViewDelegate {
|
||||
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
|
||||
guard Preferences.shared.hideToolbarsWhenScrolling else { return }
|
||||
trackingScroll = true
|
||||
prevScrollViewContentOffset = scrollView.contentOffset
|
||||
scrollStartedBelowEnd = scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.bounds.height + scrollView.safeAreaInsets.bottom)
|
||||
|
|
|
@ -45,6 +45,10 @@ class Preferences: Codable, ObservableObject {
|
|||
|
||||
useInAppSafari = try container.decode(Bool.self, forKey: .useInAppSafari)
|
||||
useReaderMode = try container.decode(Bool.self, forKey: .useReaderMode)
|
||||
|
||||
if let stored = try container.decodeIfPresent(Bool.self, forKey: .hideToolbarsWhenScrolling) {
|
||||
hideToolbarsWhenScrolling = stored
|
||||
}
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
|
@ -57,6 +61,8 @@ class Preferences: Codable, ObservableObject {
|
|||
|
||||
try container.encode(useInAppSafari, forKey: .useInAppSafari)
|
||||
try container.encode(useReaderMode, forKey: .useReaderMode)
|
||||
|
||||
try container.encode(hideToolbarsWhenScrolling, forKey: .hideToolbarsWhenScrolling)
|
||||
}
|
||||
|
||||
@Published var homepage = AppDelegate.defaultHomepage
|
||||
|
@ -67,6 +73,8 @@ class Preferences: Codable, ObservableObject {
|
|||
@Published var useInAppSafari = false
|
||||
@Published var useReaderMode = false
|
||||
|
||||
@Published var hideToolbarsWhenScrolling = true
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case homepage
|
||||
|
||||
|
@ -75,6 +83,8 @@ class Preferences: Codable, ObservableObject {
|
|||
|
||||
case useInAppSafari
|
||||
case useReaderMode
|
||||
|
||||
case hideToolbarsWhenScrolling
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ struct PreferencesView: View {
|
|||
appearanceSection
|
||||
|
||||
safariSection
|
||||
|
||||
behaviorSection
|
||||
}
|
||||
.navigationBarTitle("Preferences")
|
||||
.insetOrGroupedListStyle()
|
||||
|
@ -69,6 +71,12 @@ struct PreferencesView: View {
|
|||
.disabled(!preferences.useInAppSafari)
|
||||
}
|
||||
}
|
||||
|
||||
private var behaviorSection: some View {
|
||||
Section(header: Text("Behavior")) {
|
||||
Toggle("Hide Toolbars When Scrolling", isOn: $preferences.hideToolbarsWhenScrolling)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension View {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<key>BrowserCore.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>3</integer>
|
||||
<integer>5</integer>
|
||||
</dict>
|
||||
<key>Gemini-iOS.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
|
@ -27,17 +27,17 @@
|
|||
<key>GeminiIntents.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>6</integer>
|
||||
<integer>3</integer>
|
||||
</dict>
|
||||
<key>GeminiProtocol.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>4</integer>
|
||||
<integer>6</integer>
|
||||
</dict>
|
||||
<key>GeminiRenderer.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>5</integer>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
|
Loading…
Reference in New Issue