-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement static prompts for add to dock #3790
Implement static prompts for add to dock #3790
Conversation
|
830f4fb
to
9ca4c67
Compare
9ca4c67
to
f64d4c1
Compare
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.
Hi @jotaemepereira! The feature works great 👏 I've left some comments in the code as I think it would be great to have it cleaned up a bit. Let me know if you have any concerns about it. Thanks!
@@ -663,6 +663,7 @@ struct UserText { | |||
static let isAddedToDock = NSLocalizedString("preferences.is-added-to-dock", value: "DuckDuckGo is added to the Dock.", comment: "Indicates that the browser is added to the macOS system Dock") | |||
static let isNotAddedToDock = NSLocalizedString("preferences.not-added-to-dock", value: "DuckDuckGo is not added to the Dock.", comment: "Indicate that the browser is not added to macOS system Dock") | |||
static let addToDock = NSLocalizedString("preferences.add-to-dock", value: "Add to Dock…", comment: "Action button to add the app to the Dock") | |||
static let addDuckDuckGoToDock = NSLocalizedString("preferences.add-to-dock", value: "Add DuckDuckGo To Dock…", comment: "Action button to add the app to the Dock") |
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.
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.
Good call, copy was approved, but I can bring this to their attention.
@State private var isHovered: Bool = false | ||
|
||
var body: some View { | ||
ZStack { |
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 body of this body looks misaligned :)
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.
Good eye 😬 . Fixed!
@@ -188,6 +216,16 @@ final class MoreOptionsMenu: NSMenu, NSMenuDelegate { | |||
addItem(preferencesItem) | |||
} | |||
|
|||
private func createMenuItemWithFeatureIndicator(title: String, image: NSImage, onTap: @escaping () -> Void) -> NSView { |
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.
Really great job on it. I probably wouldn't consider going with SwiftUI there :) it looks indistinguishable from a regular menu item though 💪
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.
Thanks! I ran out of ideas of how to add the custom circle to the right, maybe something easier was out there and I missed it 😅 .
var wasFeatureShownPublisher: AnyPublisher<Bool, Never> { | ||
$isFeatureShownFromMoreOptionsMenu.eraseToAnyPublisher() |
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.
Why are we using present and past tense in the same context? Passive voice is a bit strange in API naming, so perhaps we could call everything didShowFeatureFromMoreOptionsMenu
(and didShowPublisher
)?
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.
Why? Because I’m bad at naming 😂 . Let me user your approach.
DuckDuckGo/Menus/MainMenu.swift
Outdated
@@ -438,6 +443,11 @@ final class MainMenu: NSMenu { | |||
override func update() { | |||
super.update() | |||
|
|||
#if !APPSTORE |
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.
Sorry to be a pain, and I recall telling you about NSApp.isSandboxed
earlier just to add to the mix...
I see that we're using #if !APPSTORE
and #if SPARKLE
in parts of the implementation. And then NSApp.isSandboxed
in unit tests. Would it be possible to unify these approaches? Ultimately it's sandboxing that prevents us from adding to Dock so perhaps we could use NSApp.isSandboxed
everywhere? Otherwise just rely on either SPARKLE or !APPSTORE.
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.
You are not a pain at all, and I agree that we should be consistent.
The big difference between the two is that using a compilation flag does not include the code in the binary while using NSApp.isSandboxed
adds it.
The compilation flag seems safer, given that the App Store build would not compile, while the second one is easier to mock, but could lead to a possible issue if something messes up the NSApp.isSandboxed
I’m going to play the safe approach and use the compilation flag, I’m going to use SPARKLE
build because it easier to read that using the negative.
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.
Looks great now, thanks @jotaemepereira!
Task/Issue URL: https://app.asana.com/0/1204006570077678/1209173259474635/f
Tech Design URL:
CC:
Description
This adds new static entry points to add to the dock. Now, the adding to dock setting can be used from the main menu, and more options menu, and also in the Settings -> Default Browser -> Shortcuts section.
In the more options menu, we will show a blue dot (both in the more options button and in the menu item), the notification dot will disappear after the user opens and closes the more options menu. If you want to check the blue dot again, I’ve added a debug menu in the Reset Data -> Reset Add To Dock more options menu notification.
Acceptance criteria
AC1 - AppStore users should not see any Add To Dock prompt
Given an AppStore user, when the user does not have DDG in the dock, then it should never see one of the prompts.
AC2 - If the user is non-AppStore, and DDG is not in the dock.
Given a non-AppStore user, when the user does not have DDG in the dock, then the user should see a 'Add to Dock' prompt on the main menu, more options, and in the Settings → Default Browser preference pane.
AC3 - If the user is non-AppStore, and DDG is in the dock.
Given a non-AppStore user, when the user does have DDG in the dock, then the user should not see the 'Add to Dock' prompt on the main menu and more options, and in Settings → Default Browser, you should see 'DuckDuckGo is in your Dock.
Definition of Done:
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation