-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Tab Page #433
New Tab Page #433
Conversation
@@ -138,6 +138,10 @@ final class Tab: NSObject { | |||
super.init() | |||
|
|||
setupWebView(shouldLoadInBackground: shouldLoadInBackground) | |||
|
|||
if content == .homepage { |
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.
Ensures the home page enters the history so that it can be navigated back to without causing back/forward list complexity.
|
||
import SwiftUI | ||
|
||
extension Color { |
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.
Copied from iOS to give consistent, but seemingly random, colours for favorites.
let size: CGFloat | ||
|
||
@State var image: NSImage? | ||
@State private var timer = Timer.publish(every: 0.3, tolerance: 0, on: .main, in: .default, options: nil).autoconnect() |
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.
If the SwiftUI view is shown too quickly then the Favicon cache does not appear to load and give the cached image. This refreshes the image after a short time, but only once as the timer is cancelled after being fired.
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.
I think this is probably fine, though ideally the FaviconManager
should publish when the favicon cache loads or changes, after which this view could just subscribe to that (probably debouncing the events within a short period in case of rapid changes). Though if this is just for setting up the view and canceled right after, then I think this is fine.
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.
Agree, but didn't want to change the FaviconManager if I could avoid it. I did look at making a publisher but the areFaviconsLoaded
var is a composite so didn't seem like a quick refactor.
But actually I will make one improvement here and that's to check until the caches are loaded.
|
||
import SwiftUI | ||
|
||
struct MoreOrLess: View { |
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.
A component that shows a "More ^" or "Less v" link that can be used to hide and show other views.
@@ -40,4 +40,17 @@ extension View { | |||
} | |||
} | |||
|
|||
func link(onHoverChanged: ((Bool) -> Void)? = nil, clicked: @escaping () -> Void) -> some View { | |||
self.onHover { over in |
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.
Updates the cursor to show pointy hand. Unfortunately if the containing view also uses this flag to change itself, then Swift UI rebuilds the view resets the point back to the normal arrow.
var historyDictionary = self.historyDictionary ?? [:] | ||
historyDictionary[entry.url] = entry | ||
self.historyDictionary = historyDictionary | ||
self._history = self.makeHistory(from: historyDictionary) | ||
|
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.
I noticed both existing functions called this same code and I was about to add another to do the same just refactored it into here.
|
||
struct FavoriteModel { | ||
|
||
static let addButtonUUID = UUID() |
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.
The add button is a specialised "Favorite" so we need to be able to identify it. This reduces the amount of logic required in the view / model for determining when to show the add button based on how many rows of favorites are already showing.
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.
Only just started working on this, one question and one bug:
- Question: What's the expected order of the tracker feed on the home page? It almost always adds new sites on chronological order, but in some cases I can visit two sites in sequence and they'll be backwards. For instance, if I visit Amazon, and then the NY Times, Amazon appears as the most recent visited website still, with NY Times second.
- Bug: When you have text selected in the new tab's address bar, visiting another tab will have the same number of characters selected in the address bar.
let size: CGFloat | ||
|
||
@State var image: NSImage? | ||
@State private var timer = Timer.publish(every: 0.3, tolerance: 0, on: .main, in: .default, options: nil).autoconnect() |
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.
I think this is probably fine, though ideally the FaviconManager
should publish when the favicon cache loads or changes, after which this view could just subscribe to that (probably debouncing the events within a short period in case of rapid changes). Though if this is just for setting up the view and canceled right after, then I think this is fine.
Thanks @samsymons !
|
Ah 1) is caused because we're truncating the date of the history ... it was being trunacted to the same day, now it's being truncated to the same minute. Actully, I need to run a privacy triage on that. |
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.
🥇
Task/Issue URL: https://app.asana.com/0/392891325557410/1201829216434626
Tech Design URL:
CC:
Description:
All new tab page re-written in Swift UI.
Steps to test this PR:
Internal references:
Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM