Skip to content

Commit

Permalink
fix: simplified some code, better handle light v dark
Browse files Browse the repository at this point in the history
  • Loading branch information
superhighfives committed Dec 20, 2024
1 parent 27c9d8c commit 8631b3d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 49 deletions.
18 changes: 8 additions & 10 deletions Pika.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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";
Expand All @@ -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;
Expand All @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions Pika/Views/AppVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
44 changes: 10 additions & 34 deletions Pika/Views/NavigationMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Pika/Views/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8631b3d

Please sign in to comment.