-
Notifications
You must be signed in to change notification settings - Fork 415
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 favorites section #3083
Conversation
c7dd9e4
to
713471c
Compare
var menuTitle: String { | ||
[title, truncatedUrlString].compactMap { $0 }.joined(separator: "\n") | ||
} | ||
|
||
private var truncatedUrlString: String? { | ||
guard let url = urlObject?.absoluteString else { return nil } | ||
let urlString = url.prefix(100).description | ||
let ellipsis = url.count != urlString.count ? "…" : "" | ||
return urlString + ellipsis | ||
} |
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 FavoritesHomeViewSectionRenderer
.
onFaviconMissing: onFaviconMissing | ||
) | ||
) | ||
.contextMenu { |
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 defined here just because there's no way to provide previews for context menu for iOS 15. This way only icon view is lifted. Downside is that only pressing on icon area allows to enter a context menu.
var displayTitle: String { | ||
if let title = title?.trimmingWhitespace(), !title.isEmpty { | ||
return title | ||
} | ||
|
||
if let host = urlObject?.host?.droppingWwwPrefix() { | ||
return host | ||
} | ||
|
||
assertionFailure("Unable to create display title") | ||
return "" | ||
} | ||
|
||
var host: String { | ||
return urlObject?.host ?? "" | ||
} |
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 FavoriteHomeCell
.
import SwiftUI | ||
|
||
struct FavoritesView: View { | ||
struct FavoritesView<Model: FavoritesModel>: 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.
Making the view generic is the only way I can have a model that is behind an abstraction and use ObservedObject
wrapper.
// MARK: Favorites | ||
if favoritesModel.isEmpty { | ||
FavoritesEmptyStateView() | ||
GeometryReader { proxy 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.
I need that to expand scroll content height to at least the height of the scroll view.
.daxCaption() | ||
.font(Font.system(size: 12)) |
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.
Font used for caption is more compressed and wasn't looking good.
extension EnvironmentValues { | ||
var isLandscapeOrientation: Bool { | ||
self[DeviceOrientationHolderKey.self].deviceOrientation.isLandscape | ||
} | ||
|
||
var deviceOrientation: UIDeviceOrientation { | ||
self[DeviceOrientationHolderKey.self].deviceOrientation | ||
} | ||
} |
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 assume this can be beneficial for everyone working with SwiftUI, so I defined it system-wide.
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.
LGTM:
1/ Button animation when expanding collapsing might need to be looked at
2/ Tab details are missing and keyboard setting not respected but will get those in follows, they still work when the feature is off
Thanks! For reference I created follow-up tasks here. |
# By Mariusz Śpiewak (2) and others # Via GitHub * main: Remove print (#3101) Update Package.resolved file (#3102) New Tab Page favorites section (#3083) Properly compare actual value of the entitlement check (#3100) fix ui tests broken by new onboarding and use shared setup flow (#3081) # Conflicts: # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
* main: Bump submodules/privacy-reference-tests from `a242bf0` to `afb4f61` (#3096) Updates BSK to 171.2.3 Remove print (#3101) Update Package.resolved file (#3102) New Tab Page favorites section (#3083) Properly compare actual value of the entitlement check (#3100) fix ui tests broken by new onboarding and use shared setup flow (#3081)
# By Christopher Brind (9) and others # Via Chris Brind (1) and GitHub (1) * main: (48 commits) Reduce VPN manager instances (#3097) Update BSK for Mac RMF changes (#3107) [DuckPlayer] 7- Open Settings (#3110) [DuckPlayer] 6 - Init updates and Watch on YouTube (#3066) New Tab Page Shortcuts section (#3104) Fix VPN configuration removal to stop the tunnel (#3099) avoid resizing webview when keyboard shows/hides (#3094) Add support for skipping sending usage pixels for remote messages (#3106) Bump submodules/privacy-reference-tests from `a242bf0` to `afb4f61` (#3096) Updates BSK to 171.2.3 Remove print (#3101) Update Package.resolved file (#3102) New Tab Page favorites section (#3083) Properly compare actual value of the entitlement check (#3100) fix ui tests broken by new onboarding and use shared setup flow (#3081) AdHoc lane: Make proper assignment to variable (#3095) Expand AdHoc build workflow, add debug bookmarks screen (#3086) Update BSK to latest - for macOS fix to AdAttribution (#3084) Revert "Fix tests" Fix tests ... # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved # DuckDuckGo/NetworkProtectionStatusViewModel.swift
Task/Issue URL: https://app.asana.com/0/72649045549333/1207806244251268/f
Tech Design URL:
CC:
Description:
Favorites section ported to SwiftUI, integrated with New Tab Page. See figma for design details.
Steps to test this PR:
-- Enable NTP Sections in debug menu --
Add a few favorites and verify the following:
Definition of Done (Internal Only):
Copy Testing:
’
rather than'
Orientation Testing:
Device Testing:
OS Testing:
Theme Testing:
Internal references:
Software Engineering Expectations
Technical Design Template