This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 440
Fix #916: Add pull to refresh #3769
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Client/Assets/Images.xcassets/Settings/settings-pull-to-refresh.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+676 Bytes
...sets/Settings/settings-pull-to-refresh.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+996 Bytes
...sets/Settings/settings-pull-to-refresh.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,10 @@ class Tab: NSObject { | |
|
||
/// A helper property that handles native to Brave Search communication. | ||
var braveSearchManager: BraveSearchManager? | ||
|
||
private lazy var refreshControl = UIRefreshControl().then { | ||
$0.addTarget(self, action: #selector(reload), for: .valueChanged) | ||
} | ||
|
||
func createWebview() { | ||
if webView == nil { | ||
|
@@ -417,13 +421,20 @@ class Tab: NSObject { | |
webView?.stopLoading() | ||
} | ||
|
||
func reload() { | ||
@objc func reload() { | ||
// Clear the user agent before further navigation. | ||
// Proper User Agent setting happens in BVC's WKNavigationDelegate. | ||
// This prevents a bug with back-forward list, going back or forward and reloading the tab | ||
// loaded wrong user agent. | ||
webView?.customUserAgent = nil | ||
|
||
defer { | ||
if let refreshControl = webView?.scrollView.refreshControl, | ||
refreshControl.isRefreshing { | ||
refreshControl.endRefreshing() | ||
} | ||
} | ||
|
||
// Refreshing error, safe browsing warning pages. | ||
if let originalUrlFromErrorUrl = webView?.url?.originalURLFromErrorURL { | ||
webView?.load(URLRequest(url: originalUrlFromErrorUrl)) | ||
|
@@ -548,8 +559,15 @@ class Tab: NSObject { | |
return | ||
} | ||
|
||
updatePullToRefreshVisibility() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't we already covering this case inside BVC There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No this call happens whenever a URL changes in the tab's web view (since we dont want pull to refresh on local pages at all). The BVC pref observation only ensures that it updates any visible tabs refresh control when a user flips that pref on/off |
||
|
||
self.urlDidChangeDelegate?.tab(self, urlDidChangeTo: url) | ||
} | ||
|
||
func updatePullToRefreshVisibility() { | ||
guard let url = webView?.url, let webView = webView else { return } | ||
webView.scrollView.refreshControl = url.isLocalUtility || !Preferences.General.enablePullToRefresh.value ? nil : refreshControl | ||
} | ||
|
||
func isDescendentOf(_ ancestor: Tab) -> Bool { | ||
return sequence(first: parent) { $0?.parent }.contains { $0 == ancestor } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this real text value? Enable
Pull-to-refresh
looks not matching with rest of the options because of dash usage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's real, James proposed it