From 0c448e7f91b44662789593601634420664e62759 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Nov 2021 20:42:58 +0100 Subject: [PATCH] Replace status icon with color-agnostic shapes Fixes #199 --- Passepartout/App/iOS/CHANGELOG.md | 2 +- .../App/macOS/Assets.xcassets/Contents.json | 6 +- .../StatusActive.imageset/Contents.json | 25 ++++++++ .../StatusActive.imageset/StatusActive@2x.png | Bin 0 -> 798 bytes .../StatusActive.imageset/StatusActive@3x.png | Bin 0 -> 1038 bytes .../Contents.json | 55 ------------------ .../StatusBarButtonImage@2x.png | Bin 434 -> 0 bytes .../StatusBarButtonImage@3x.png | Bin 493 -> 0 bytes .../StatusPending.imageset/Contents.json | 25 ++++++++ .../StatusPending@2x.png | Bin 0 -> 1230 bytes .../StatusPending@3x.png | Bin 0 -> 1658 bytes Passepartout/App/macOS/CHANGELOG.md | 4 +- .../App/macOS/Global/SwiftGen+Assets.swift | 3 +- Passepartout/App/macOS/Menu/StatusMenu.swift | 52 +++++++++++------ 14 files changed, 93 insertions(+), 79 deletions(-) create mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/Contents.json create mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@2x.png create mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusActive.imageset/StatusActive@3x.png delete mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/Contents.json delete mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@2x.png delete mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusBarButtonImage.imageset/StatusBarButtonImage@3x.png create mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/Contents.json create mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@2x.png create mode 100644 Passepartout/App/macOS/Assets.xcassets/StatusPending.imageset/StatusPending@3x.png 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 0000000000000000000000000000000000000000..a85f0d47c52d96e84b0766f2a132249df65d1687 GIT binary patch literal 798 zcmeAS@N?(olHy`uVBq!ia0vp^B0#Lf!3-obN;vz06id3JuOkD)#(wTUiL5}rLb6AY zF9SoB8UsT^3j@P1pisjL28L1t28LG&3=CE?7#PG0=Ijcz0ZJST@Ck8!{qB>MHHep( zoC0JIMfCsw|MziE_XTjhZ--*bub+SBEcbMGUAAq;YwyOH z=AUMne*9}@ytKaI(Agi;udlmpVz|EJegB6Qa>un5X1~+gtEhDlXar-Dx4VmD=e-<1 zAcwQSBeIx*K~EWk87r3BmjMOYOFVsD*`IQ=3d@`N-!cORIfFoQq8~`g0gAVR6MdGM{3)HrfdJ}r}D}uF#YQKzSQsj z^p`6yJLtu0EYp~}zAo%_0GRJx{v+1^Q97#5JNMC9x#cD!C{XNHG{0 z7#Zps8tNLDh8S8}83B=rwt<0_fx+#EcA!v3Xvob^$xN%ntzp%kwpySD22WQ%mvv4F FO#s0vjxhiL literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..18d8e235d1cbc25bcee11db9c6a6f8743ee5e5a2 GIT binary patch literal 1038 zcmeAS@N?(olHy`uVBq!ia0vp^vOsLa!3-p)Z&$bnq*&4&eH|GXHuiJ>Nn{1`6_P!I zd>I(3)EF2VS{N990fib~Fff!FFfhDIU|_JC!N4G1FlSew4FdzCMSxF;>+5%)fNFr` zC?Y-t{{R2~{f6U2V8Er71o;IsFfiHAxpe>9a$h!%s+S)p2r^dwnQHgqYs~C>yLRmS zu;<_Yi?@x~IoF;NQ9Slw!|D^f{l6csWA5!+b)2i`u$!~%!RtNz$3Dlfk96h zgc&QA+Lr+Z*-JcqUD=;wuSk+s1PTcxC;EY;Vu3ggh!ucXY?5e!5YRjWPZ!4! zi_>qXMEW-e2(+?qNm_X|>u&DG(1oSW-H-N#3VGfhrS*?^5eqi zf*+HL)$h!n$-~f*`*vgBh9&2A@T_nNztkI4?$5PgyZ+mvEAtx~9phf`@gC-=bw6&j zLPs{_7^iU%pC!NWi^;*8R;}6;=Ah?iJa6XG$p-Cq`j@^sT$v~?Ch5$1vqAMssxXTq z!)I&NwyE-$uZI0Po_R1^YK`Lh{E9swF`IQ(mj$`!%`vh&?Y7^8d;g32vV~LG%n$E8IV+8AJJ;1^j!yltEM@0ZAB&X! z=UR8M*xdJa;hQvO%gXK-H_A;WyY2|zk^J=ohrepxD*MOsadC^aznbrA_!bw|v%&7w z{D_~dQU_e>Elsx+0mD$W#5JNMC9x#cD!C{XNHG{07#Zps8tNLDh8S8}83B=rwt<0_ kfx+#Eb_Y>3l4r>mdKI;Vst0CL7U?EnA( literal 0 HcmV?d00001 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 2a0337ac272394e7d167435bdcbee3610015a89b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 434 zcmeAS@N?(olHy`uVBq!ia0vp^B0#Lj!2%?U&7EfeDVB6cUq=Rpjs4tz5?O(Kg=CK) zUj~LMH3o);76yi2K%s^g3=E|P3=FRl7#OU8dc+In>CCsby~u0&mcLGtrz`5thtG=_ z8=YH{x^3l^f9c;=Cp=lxy7O=B-@y41SAW>D3o`$dev{!C8<`)MX5lF!N|bSQrFN(*U&J;$iT|L*viOU+rZGuz~E*^G$@b} n8glbfGSe!NH5gi2nOa&I7(q0suDsC$)WG2B>gTe~DWM4fsS1yY 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 bd90cd93a057f32a786bfec60dcf14ac201333ad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 493 zcmeAS@N?(olHy`uVBq!ia0vp^vOsLe!2%?EzGR&QQY`6?zK#qG8~eHcB(ehe3dtTp zz6=aiY77hwEes65fI@Udzy|3P)Hy-(XR|h`#`Y-kmmc{&$k*#-}H2G4DmSrcG^a+Lk0qE z`)@SqEn4)5+kzv=rG|678QS)C+W=?m-SU=?yO0Xy;&iPPbp65S`xl<_rG&$_7i75eIdY~`h9)Iy11R` zmsYr~?wi#jcrSfwm6A9A!$lv$Cwsh+vUc4cEm08qqVfQPM3GKwYfeUE$1VSj86rl% zjyz=fz$mM-ZfBNrNEOhNswJ)wB`Jv|saDBFsX&Us$iUE2*U(7U&@jZvz{N`ao`6!h%w3A-KDMPo^>pc!&%@FSZHu#d}(H+EX+3Pn~uWlGmJ%_Th6#MM!wKs>I!X~bjhgoX+cn#*gkAnG4U|z0f0es!G>n`=k$-t}knSEA;n8 zfK|QI@=LAn=H0W?eIx%u^2q({3=0Dx3D#px2OWji9DXc(P~puXvHvOtu72keuBodi z?sIiLAYl2OceC@tfC{+?11WLeh)o=k-}+zvI{8%T?Q`##mD&+g-}33kyq-|Ik#}NU zwEDE3uf1n=b?@A}$#Epk{mjv~@7~I<`1|nD#f@D4e&5d>`SRK9tI@nY0q0G3c^ zi@jfS^x3y}_x$w_9ootMH~hev{<=g(qxp*hYs4J8-9D-^>FllA&9X=7K1>B9w^9HA literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..8c17d727e0f258558227823703ebb6d5867a7808 GIT binary patch literal 1658 zcmeAS@N?(olHy`uVBq!ia0vp^vOsLa!3-p)Z&$bnq*&4&eH|GXHuiJ>Nn{1`6_P!I zd>I(3)EF2VS{N990fib~Fff!FFfhDIU|_JC!N4G1FlSew4Fdy{aDY#U>+5%)fNFr` zC>jj`UAY6KTZ4f(m^V>NGuZn(} z()4dO$KFdb+~)1RAk^|LZpp13xn~7pwqL$^O^1bT+i8A6v!;#6}!A6NH;v!1to=k6i_-aydLx>;`FW1GcD~rp{?EJhwDsve#(j+2Jk`KS(+sV^2>@yN8zs!Zj0D(WG=UKMsiKA2g4;usbMJ1OyT_0{ zt6<&T#PG$>Zgj?k_b=IIU9R|^jqSOu-X@zHw;T4XpJ?>Pz3gzKTL1OyJX%w^-mveT z=iJUas|uE|xe3TgYs?xg&4VIqR4u z%jcwQn%@23#cO6=UJ2hd5A_c1{e9BMOUO3ea${TFq>Yv9zVd&6pMKZCz{72Uu<7rB z1OtOL&Q$^nULEGKj`As*)AZrR#wKeejzhu{XS97 z5w4jtFZ+-`$9(lkzBfLza(Pc$xmZ{0+|~@edl~u;=( z{_pwAa^j7SAKcdO%yoarq*xi1_5#zQYKdz^NlIc#s#S7PDv)9@GB7gKH8j*UFby%Z uv@)`^GB(sUFt9Q(a4i=6fubQdKP5A*61N5uy_GIN4Gf;HelF{r5}E+OB*NhU literal 0 HcmV?d00001 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 + } + } +}