diff --git a/Loop/App/LoopApp.swift b/Loop/App/LoopApp.swift index 0b552614..e9d36ed9 100644 --- a/Loop/App/LoopApp.swift +++ b/Loop/App/LoopApp.swift @@ -11,25 +11,46 @@ import SwiftUI @main struct LoopApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate - @State var isMenubarItemPresented: Bool = false + @ObservedObject private var updater = Updater.shared @Default(.hideMenuBarIcon) var hideMenuBarIcon var body: some Scene { MenuBarExtra(Bundle.main.appName, image: "menubarIcon", isInserted: Binding.constant(!hideMenuBarIcon)) { - #if DEBUG - let text = "DEV BUILD: \(Bundle.main.appVersion ?? "Unknown") (\(Bundle.main.appBuild ?? 0))" - Text(text) - .font(.system(size: 11, weight: .semibold)) - #endif - Button { if let url = URL(string: "https://github.com/sponsors/MrKai77") { NSWorkspace.shared.open(url) } } label: { - HStack { - Image(systemName: "heart") - Text("Donate") + Label("Donate", systemImage: "heart") + } + + Divider() + + Text( + "Version \(Bundle.main.appVersion ?? "Unknown") (\(Bundle.main.appBuild ?? 0))", + comment: "Format: Version [version, e.g. 1.3.0] ([build number, e.g. 1500])" + ) + .font(.system(size: 11, weight: .semibold)) + + Button { + Task { + await updater.fetchLatestInfo() + + if updater.updateState == .available { + await updater.showUpdateWindow() + } + } + } label: { + if updater.updateState == .available { + Text( + "Update…", + comment: "Button to update app in menubar dropdown menu" + ) + } else { + Text( + "Check for Updates…", + comment: "Button to check for updates in menubar dropdown menu" + ) } } @@ -38,7 +59,9 @@ struct LoopApp: App { } .keyboardShortcut(",", modifiers: .command) - Button("Quit") { + Divider() + + Button("Quit \(Bundle.main.appName)") { NSApp.terminate(nil) } .keyboardShortcut("q", modifiers: .command) diff --git a/Loop/Localizable.xcstrings b/Loop/Localizable.xcstrings index d7a7632e..80a4cf4e 100644 --- a/Loop/Localizable.xcstrings +++ b/Loop/Localizable.xcstrings @@ -2557,6 +2557,9 @@ } } }, + "Check for Updates…" : { + "comment" : "Button to check for updates in menubar dropdown menu" + }, "Close" : { "comment" : "Label for a button that closes a modal window", "localizations" : { @@ -20675,6 +20678,7 @@ } }, "Quit" : { + "extractionState" : "stale", "localizations" : { "ar" : { "stringUnit" : { @@ -20756,6 +20760,10 @@ } } }, + "Quit %@" : { + "comment" : "A button that quits the app.", + "isCommentAutoGenerated" : true + }, "Radial menu" : { "localizations" : { "ar" : { @@ -27605,6 +27613,7 @@ } }, "Update…" : { + "comment" : "Button to update app in menubar dropdown menu", "localizations" : { "ar" : { "stringUnit" : { @@ -28180,6 +28189,7 @@ } }, "Version %@ (%lld)" : { + "comment" : "Format: Version [version, e.g. 1.3.0] ([build number, e.g. 1500])", "localizations" : { "ar" : { "stringUnit" : { @@ -29667,5 +29677,5 @@ } } }, - "version" : "1.0" + "version" : "1.1" } \ No newline at end of file