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

Update XcodesApp.swift #124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update XcodesApp.swift #124

wants to merge 1 commit into from

Conversation

jacobwhite
Copy link

Create MenuBar item. Probably needs additional ui in settings to only show menu bar item, and hide the dock icon and all that. But this seems to work okay. Maybe needs better icon.

Create MenuBar item.
@jacobwhite jacobwhite requested a review from a team as a code owner April 26, 2021 23:58
@jacobwhite
Copy link
Author

This would be way cooler if the menubar icon changed to show when its downloading and installing xcodes.

@unnamedd
Copy link

@jacobwhite may I suggest a small thing? Upload a screenshot of your change. This will make easier for the reviewer to see exactly what should be the result of your pull request.

@jacobwhite
Copy link
Author

@unnamedd Sure.
image

@MattKiazyk
Copy link
Contributor

Hey Jacob!

Thanks for contributing to Xcodes!

I love the idea of a menu icon. I love the idea of the menu icon changing for different statuses (downloading, unxiping, refreshing, etc)

I'm not in love with just showing the main UI, just to have it in the menu. Is there a particular aspect of a menu app that is more enticing for you?

@jacobwhite
Copy link
Author

jacobwhite commented Apr 27, 2021 via email

@aerickson14
Copy link
Contributor

Hi @jacobwhite thank you for your contribution :)

Unfortunately, when referencing Apple's Human Interface Guidelines they recommend not to show a popover from a menu item.

Display a menu—not a popover—when the user clicks your menu bar extra. Unless the app functionality you want to expose is too complex for a menu, you should avoid presenting it in a popover. See Popovers.

That being said, there are apps that break this rule such as Dropbox and 1Password. The difference with these apps though is they present a significantly different UI in the popover from the main UI. It is usually some sort of quick access or simplified view.

I totally agree with you and @MattKiazyk that a menu item that changes status when downloading or installing would be a great addition. Now just to decide if a menu, or some sort of simplified popover makes sense when clicking the menu item 🤔

@jacobwhite
Copy link
Author

jacobwhite commented Apr 27, 2021 via email

@lockieluke
Copy link

lockieluke commented Jan 14, 2023

i love this UI, XcodesApp is a really simple app and it doesn't need its own separate window, given that it can live in the menu bar, automatically updating Xcode should be possible

@jacobwhite
Copy link
Author

Yeah! Especially if you just want to leave it running all the time.

Too bad they don't agree. ¯_(ツ)_/¯

@tinder-cfuller
Copy link

tinder-cfuller commented Jan 26, 2024

I think a menu bar item is an excellent idea! I see there is some debate on the design. I would like to offer an alternative approach with the hope that maybe this could be a nice compromise. I am offering a simpler UI for the drop-down menu, while maintaining the most critical functionality that should be easily accessible.

Xcodes

Description

  • Show the active Xcode version directly in the menu bar (similar to battery percentage).
    • I personally think this is such an awesome feature that I would look at frequently as I need to switch Xcode versions for different projects.
  • In the drop down menu, only show the installed versions.
    • Each version in the list is displayed as text, such as 12.5 Beta 3 (12E5244e), no app icon or other details (simple is elegant)
    • Selecting an installed version from the drop down menu will make it active.
    • The active version will have an icon (likely checkmark or possibly simply a bullet) indicating it is the active one.
  • The drop down menu can also contain menu items for opening the main Xcodes window, opening settings or quitting.
  • Somewhere there should be settings for the menu bar item itself to control whether the Xcode build numbers are shown and whether the active version is shown in the menu bar.

Prototype Sample Code

final class AppDelegate: NSObject, NSApplicationDelegate {

    private var statusBarItem: NSStatusItem!

    private let systemSymbolName: String = "wrench.and.screwdriver"

    private let mockXcodeVersions: [String] = [
        "12.5 Beta 3 (12E5244e)",
        "12.5 Beta 2 (12E5234g)",
        "12.5 Beta (12E52200)",
        "12.4 (12D4e)",
        "12.3 (12C33)",
        "12.3 Beta (12C5020f)",
    ]

    private lazy var mockXcodeVersion: String = "12.4 (12D4e)"

    func applicationDidFinishLaunching(_ notification: Notification) {
        statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
        configureStatusBarItemButton(statusBarItem.button)
        configureStatusBarItemMenu(statusBarItem)
    }

    private func configureStatusBarItemButton(_ button: NSStatusBarButton?) {
        guard let button: NSStatusBarButton
        else { return }
        button.title = mockXcodeVersion
        button.image = NSImage(systemSymbolName: systemSymbolName, accessibilityDescription: "Xcodes")
    }

    private func configureStatusBarItemMenu(_ statusBarItem: NSStatusItem) {
        let menu: NSMenu = .init()
        for xcodeVersion: String in mockXcodeVersions {
            let menuItem: NSMenuItem = .init()
            let image: NSImage?
            if xcodeVersion == mockXcodeVersion {
                image = .init(systemSymbolName: "checkmark.circle.fill", accessibilityDescription: xcodeVersion)
            } else {
                image = NSImage(size: NSSize(width: 1, height: 1))
            }
            menuItem.image = image
            menuItem.title = xcodeVersion
            menuItem.action = #selector(didSelectXcodeVersion)
            menu.addItem(menuItem)
        }
        menu.addItem(.separator())
        menu.addItem(withTitle: "Open Xcodes", action: #selector(openXcodes), keyEquivalent: "")
        menu.addItem(withTitle: "Settings", action: #selector(openSettings), keyEquivalent: "")
        menu.addItem(withTitle: "Quit", action: #selector(openSettings), keyEquivalent: "")
        statusBarItem.menu = menu
    }

    @objc
    private func didSelectXcodeVersion(_ sender: NSMenuItem) {
        print(sender.title)
    }

    @objc
    private func openXcodes(_ sender: NSMenuItem) {}

    @objc
    private func openSettings(_ sender: NSMenuItem) {}
}

@jacobwhite
Copy link
Author

Hell yeah, maybe optional considering it would take a lot of space on a top notch laptop.

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

6 participants