Skip to content
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

Merged
merged 28 commits into from
Jul 18, 2024
Merged

New Tab Page favorites section #3083

merged 28 commits into from
Jul 18, 2024

Conversation

dus7
Copy link
Contributor

@dus7 dus7 commented Jul 15, 2024

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 --

  1. Single row of favorites placeholders is visible if there are no favorites.

Add a few favorites and verify the following:

  1. Collapse/expand button is not visible when there is less than 2 rows of favorites.
  2. Tapping a favorite opens it in current tab.
  3. Long-pressing a favorite opens context menu with Edit and Delete - verify both actions work.
  4. On landscape and iPad there are 6 columns of favorites.
  5. Pixels are sent on:
    1. opening favorite (regular and daily)
    2. deleting favorite
    3. editing favorite
    4. opening NTP (regular and daily)

Definition of Done (Internal Only):

Copy Testing:

  • Use of correct apostrophes in new copy, ie rather than '

Orientation Testing:

  • Portrait
  • Landscape

Device Testing:

  • iPhone SE (1st Gen)
  • iPhone 8
  • iPhone X
  • iPhone 14 Pro
  • iPad

OS Testing:

  • iOS 15
  • iOS 16
  • iOS 17

Theme Testing:

  • Light theme
  • Dark theme

Internal references:

Software Engineering Expectations
Technical Design Template

Copy link

github-actions bot commented Jul 15, 2024

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 713471c

@dus7 dus7 requested a review from brindy July 17, 2024 15:13
Comment on lines +39 to +48
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
}
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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.

Comment on lines +124 to +139
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 ?? ""
}
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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
Copy link
Contributor Author

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))
Copy link
Contributor Author

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.

Comment on lines +22 to +30
extension EnvironmentValues {
var isLandscapeOrientation: Bool {
self[DeviceOrientationHolderKey.self].deviceOrientation.isLandscape
}

var deviceOrientation: UIDeviceOrientation {
self[DeviceOrientationHolderKey.self].deviceOrientation
}
}
Copy link
Contributor Author

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.

@dus7 dus7 marked this pull request as ready for review July 17, 2024 15:15
Copy link
Contributor

@brindy brindy left a 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

@dus7
Copy link
Contributor Author

dus7 commented Jul 18, 2024

Thanks! For reference I created follow-up tasks here.

@dus7 dus7 merged commit d9bd26c into main Jul 18, 2024
24 checks passed
@dus7 dus7 deleted the mariusz/ntp-favorites branch July 18, 2024 14:32
samsymons added a commit that referenced this pull request Jul 18, 2024
# 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
samsymons added a commit that referenced this pull request Jul 19, 2024
* 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)
samsymons added a commit that referenced this pull request Jul 19, 2024
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants