diff --git a/Passepartout/App/iOS/CHANGELOG.md b/Passepartout/App/iOS/CHANGELOG.md index 948bf6a6..0a0a263f 100644 --- a/Passepartout/App/iOS/CHANGELOG.md +++ b/Passepartout/App/iOS/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 1.17.0 Beta 2831 (2021-10-18) +## Unreleased ### Changed diff --git a/Passepartout/App/macOS/Assets.xcassets/Contents.json b/Passepartout/App/macOS/Assets.xcassets/Contents.json index da4a164c..73c00596 100644 --- a/Passepartout/App/macOS/Assets.xcassets/Contents.json +++ b/Passepartout/App/macOS/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/Contents.json b/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/Contents.json new file mode 100644 index 00000000..f0066357 --- /dev/null +++ b/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "StatusActive@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "StatusActive@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@2x.png b/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@2x.png new file mode 100644 index 00000000..a85f0d47 Binary files /dev/null and b/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@2x.png differ diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@3x.png b/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@3x.png new file mode 100644 index 00000000..18d8e235 Binary files /dev/null and b/Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@3x.png differ diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/Contents.json b/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/Contents.json deleted file mode 100644 index 8b7cab96..00000000 --- a/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/Contents.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "idiom" : "universal", - "scale" : "1x" - }, - { - "filename" : "StatusBarButtonImage@2x.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "StatusBarButtonImage@3x.png", - "idiom" : "universal", - "scale" : "3x" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "template" - } -} diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@2x.png b/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@2x.png deleted file mode 100644 index 2a0337ac..00000000 Binary files a/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@2x.png and /dev/null differ diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@3x.png b/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@3x.png deleted file mode 100644 index bd90cd93..00000000 Binary files a/Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@3x.png and /dev/null differ diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/Contents.json b/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/Contents.json new file mode 100644 index 00000000..756b263d --- /dev/null +++ b/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "StatusPending@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "StatusPending@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@2x.png b/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@2x.png new file mode 100644 index 00000000..f6529f87 Binary files /dev/null and b/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@2x.png differ diff --git a/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@3x.png b/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@3x.png new file mode 100644 index 00000000..8c17d727 Binary files /dev/null and b/Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@3x.png differ diff --git a/Passepartout/App/macOS/CHANGELOG.md b/Passepartout/App/macOS/CHANGELOG.md index 1175a915..a5cc7fd5 100644 --- a/Passepartout/App/macOS/CHANGELOG.md +++ b/Passepartout/App/macOS/CHANGELOG.md @@ -5,12 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 1.17.0 Beta 2831 (2021-10-18) +## Unreleased ### Changed - Allow Oeck provider without any purchase. -- Status bar icon color had to be dropped in order to automatically adjust to desktop background color. +- Drop status bar icon color to automatically adjust to desktop background color. [#199](https://github.com/passepartoutvpn/passepartout-apple/issues/199) - Migrate to SwiftPM. ### Fixed diff --git a/Passepartout/App/macOS/Global/SwiftGen+Assets.swift b/Passepartout/App/macOS/Global/SwiftGen+Assets.swift index 531a074a..de7735ee 100644 --- a/Passepartout/App/macOS/Global/SwiftGen+Assets.swift +++ b/Passepartout/App/macOS/Global/SwiftGen+Assets.swift @@ -20,7 +20,8 @@ internal typealias AssetImageTypeAlias = ImageAsset.Image // swiftlint:disable identifier_name line_length nesting type_body_length type_name internal enum Asset { internal enum Assets { - internal static let statusBarButtonImage = ImageAsset(name: "StatusBarButtonImage") + internal static let statusActive = ImageAsset(name: "StatusActive") + internal static let statusPending = ImageAsset(name: "StatusPending") } internal enum Flags { internal static let ad = ImageAsset(name: "ad") diff --git a/Passepartout/App/macOS/Menu/StatusMenu.swift b/Passepartout/App/macOS/Menu/StatusMenu.swift index cac67900..e27df4bd 100644 --- a/Passepartout/App/macOS/Menu/StatusMenu.swift +++ b/Passepartout/App/macOS/Menu/StatusMenu.swift @@ -57,13 +57,9 @@ class StatusMenu: NSObject { // MARK: Button images - private let imageStatus = Asset.Assets.statusBarButtonImage.image + private let imageStatusActive = Asset.Assets.statusActive.image - private lazy var imageStatusActive: NSImage = imageStatus.tinted(withColor: Theme.current.palette.colorOn) - - private lazy var imageStatusInactive: NSImage = imageStatus.tinted(withColor: Theme.current.palette.colorPrimaryText) - - private lazy var imageStatusInProgress: NSImage = imageStatus.tinted(withColor: Theme.current.palette.colorIndeterminate) + private let imageStatusPending = Asset.Assets.statusPending.image // MARK: Menu references @@ -97,10 +93,10 @@ class StatusMenu: NSObject { } func install() { - guard let button = statusItem.button else { + guard let _ = statusItem.button else { return } - button.image = imageStatus + setStatusImage(for: .inactive) VPN.shared.prepare { self.rebuild() @@ -237,7 +233,7 @@ class StatusMenu: NSObject { guard let profile = profile else { itemProfileName.title = L10n.Menu.ActiveProfile.Title.none // itemProfileName.image = nil - statusItem.button?.image = imageStatusInactive + setStatusImage(for: .inactive) statusItem.button?.toolTip = nil return } @@ -619,22 +615,18 @@ class StatusMenu: NSObject { switch vpn.status ?? .disconnected { case .connected: - statusItem.button?.image = imageStatusActive - statusItem.button?.alphaValue = 1.0 + setStatusImage(for: .active) Reviewer.shared.reportEvent() case .connecting: - statusItem.button?.image = imageStatusInProgress - statusItem.button?.alphaValue = 1.0 + setStatusImage(for: .pending) case .disconnected: - statusItem.button?.image = imageStatusInactive - statusItem.button?.alphaValue = 0.5 + setStatusImage(for: .inactive) case .disconnecting: - statusItem.button?.image = imageStatusInProgress - statusItem.button?.alphaValue = 1.0 + setStatusImage(for: .pending) } } } @@ -686,3 +678,29 @@ extension StatusMenu: ConnectionServiceDelegate { NotificationCenter.default.post(name: StatusMenu.didUpdateProfile, object: profile) } } + +extension StatusMenu { + fileprivate enum ImageStatus { + case active + + case pending + + case inactive + } + + fileprivate func setStatusImage(for imageStatus: ImageStatus) { + switch imageStatus { + case .active: + statusItem.button?.image = imageStatusActive + statusItem.button?.alphaValue = 1.0 + + case .pending: + statusItem.button?.image = imageStatusPending + statusItem.button?.alphaValue = 1.0 + + case .inactive: + statusItem.button?.image = imageStatusActive + statusItem.button?.alphaValue = 0.5 + } + } +}