From 8631b3d8f0c134e4bd794dc78340b8dc7efc053e Mon Sep 17 00:00:00 2001 From: Charlie Gleason Date: Thu, 19 Dec 2024 21:41:42 -0800 Subject: [PATCH] fix: simplified some code, better handle light v dark --- Pika.xcodeproj/project.pbxproj | 18 ++++++------- Pika/Views/AppVersion.swift | 11 +++++--- Pika/Views/NavigationMenu.swift | 44 ++++++++------------------------ Pika/Views/PreferencesView.swift | 2 +- 4 files changed, 26 insertions(+), 49 deletions(-) diff --git a/Pika.xcodeproj/project.pbxproj b/Pika.xcodeproj/project.pbxproj index f203220..3d23325 100644 --- a/Pika.xcodeproj/project.pbxproj +++ b/Pika.xcodeproj/project.pbxproj @@ -115,7 +115,6 @@ EAE23DE02D032A38005BB270 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAD0B6D2259CED1D00FA2F67 /* Preview Assets.xcassets */; }; EAE23DE12D032A38005BB270 /* ColorNames.json in Resources */ = {isa = PBXBuildFile; fileRef = EA7B199825FBA09300E06D9D /* ColorNames.json */; }; EAE23DE22D032A38005BB270 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EAD0B6CF259CED1D00FA2F67 /* Assets.xcassets */; }; - EAE2EB9C2D03697600FA9BC9 /* Info (Mac App Store).plist in Resources */ = {isa = PBXBuildFile; fileRef = EAE2EB9B2D03697600FA9BC9 /* Info (Mac App Store).plist */; }; EAE2EB9D2D03753A00FA9BC9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EAD0B6D4259CED1D00FA2F67 /* Main.storyboard */; }; EAE2EB9F2D03C3DE00FA9BC9 /* LookUpAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAE2EB9E2D03C3DA00FA9BC9 /* LookUpAPI.swift */; }; EAE2EBA32D03C40000FA9BC9 /* LatestAppStoreVersion+ShouldUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAE2EBA12D03C3FE00FA9BC9 /* LatestAppStoreVersion+ShouldUpdate.swift */; }; @@ -498,7 +497,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - EAE2EB9C2D03697600FA9BC9 /* Info (Mac App Store).plist in Resources */, EAE23DDF2D032A38005BB270 /* Localizable.strings in Resources */, EAE23DE02D032A38005BB270 /* Preview Assets.xcassets in Resources */, EAE2EB9D2D03753A00FA9BC9 /* Main.storyboard in Resources */, @@ -860,7 +858,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 48; + CURRENT_PROJECT_VERSION = 50; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\""; DEVELOPMENT_TEAM = TGHU37N6EX; @@ -874,7 +872,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika; PRODUCT_NAME = Pika; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG TARGET_SPARKLE"; @@ -891,7 +889,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 48; + CURRENT_PROJECT_VERSION = 50; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\""; DEVELOPMENT_TEAM = TGHU37N6EX; @@ -905,7 +903,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika; PRODUCT_NAME = Pika; SWIFT_ACTIVE_COMPILATION_CONDITIONS = TARGET_SPARKLE; @@ -923,7 +921,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\""; DEVELOPMENT_TEAM = TGHU37N6EX; @@ -937,7 +935,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika; PRODUCT_NAME = Pika; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG TARGET_MAS"; @@ -955,7 +953,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 47; + CURRENT_PROJECT_VERSION = 49; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\""; DEVELOPMENT_TEAM = TGHU37N6EX; @@ -969,7 +967,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 11.0; - MARKETING_VERSION = 1.0.0; + MARKETING_VERSION = 1.0.1; PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika; PRODUCT_NAME = Pika; SWIFT_ACTIVE_COMPILATION_CONDITIONS = TARGET_MAS; diff --git a/Pika/Views/AppVersion.swift b/Pika/Views/AppVersion.swift index 5c53658..16ee099 100644 --- a/Pika/Views/AppVersion.swift +++ b/Pika/Views/AppVersion.swift @@ -4,14 +4,16 @@ struct AppVersion: View { @Environment(\.colorScheme) var colorScheme: ColorScheme let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String let buildNumber = Bundle.main.infoDictionary?["CFBundleVersion"] as? String + var displayOnTransparent = false var body: some View { VStack(spacing: 10.0) { VStack(spacing: 5.0) { Image("AboutIcon") Text(PikaText.textAppName) .font(.title) + .foregroundColor(colorScheme == .light && !displayOnTransparent ? .black : .white) .modify { - if colorScheme == .dark { + if colorScheme == .dark || displayOnTransparent { $0.shadow(color: Color.black.opacity(0.3), radius: 0, x: 0, @@ -27,8 +29,9 @@ struct AppVersion: View { let textUnknown = PikaText.textAboutUnknown Text("\(textVersion) \(appVersion ?? textUnknown)") .fontWeight(.semibold) + .foregroundColor(colorScheme == .light && !displayOnTransparent ? .black : .white) .modify { - if colorScheme == .dark { + if colorScheme == .dark || displayOnTransparent { $0.shadow(color: Color.black.opacity(0.3), radius: 0, x: 0, @@ -39,9 +42,9 @@ struct AppVersion: View { } Text("(\(textBuild) \(buildNumber ?? textUnknown))") - .foregroundColor(colorScheme == .light ? .black : .white).opacity(0.5) + .foregroundColor(colorScheme == .light && !displayOnTransparent ? .black : .white).opacity(0.5) .modify { - if colorScheme == .dark { + if colorScheme == .dark || displayOnTransparent { $0.shadow(color: Color.black.opacity(0.3), radius: 0, x: 0, diff --git a/Pika/Views/NavigationMenu.swift b/Pika/Views/NavigationMenu.swift index d4ee790..8e1bbad 100644 --- a/Pika/Views/NavigationMenu.swift +++ b/Pika/Views/NavigationMenu.swift @@ -4,35 +4,6 @@ import SwiftUI struct NavigationMenu: View { @Default(.colorFormat) var colorFormat - // These are a hack to trigger a redraw on OSX 11.0 - otherwise the - // button displays wtih 50% opacity until you interact with it. If - // anyone knows of a better way to do this, let me know. - @State var once: Bool = false - @State var showMenu: Bool = true - - @ViewBuilder - func getMenu() -> some View { - let icon = "gearshape" - - if showMenu { - Menu { - NavigationMenuItems() - } label: { - IconImage(name: icon) - } - .menuStyle(BorderlessButtonMenuStyle(showsMenuIndicator: true)) - .onAppear { - if !once { - showMenu.toggle() - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { - showMenu.toggle() - } - } - once = true - } - } - } - var body: some View { HStack(spacing: 0) { Picker(PikaText.textFormatTitle, selection: $colorFormat) { @@ -44,11 +15,16 @@ struct NavigationMenu: View { .pickerStyle(SegmentedPickerStyle()) .labelsHidden() - getMenu() - .frame(alignment: .leading) - .padding(.trailing, 10.0) - .padding(.leading, 5.0) - .fixedSize() + Menu { + NavigationMenuItems() + } label: { + IconImage(name: "gearshape") + } + .menuStyle(BorderlessButtonMenuStyle(showsMenuIndicator: true)) + .frame(alignment: .leading) + .padding(.trailing, 10.0) + .padding(.leading, 5.0) + .fixedSize() let values = ColorFormat.allCases.map { $0 } HStack { diff --git a/Pika/Views/PreferencesView.swift b/Pika/Views/PreferencesView.swift index 51fb705..d759661 100644 --- a/Pika/Views/PreferencesView.swift +++ b/Pika/Views/PreferencesView.swift @@ -58,7 +58,7 @@ struct PreferencesView: View { HStack(alignment: .top, spacing: 0) { ZStack { Visualisation() - AppVersion() + AppVersion(displayOnTransparent: true) } .frame(maxWidth: 240.0, maxHeight: .infinity) .background(VisualEffect(