Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.0.10 #48

Merged
merged 23 commits into from
Mar 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions Pika.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
226FD61025A940F90021A67F /* VisualEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226FD60F25A940F90021A67F /* VisualEffect.swift */; };
22EF1D9B25B7AA18001102FA /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22EF1D9A25B7AA18001102FA /* Sequence.swift */; };
22FE80B325BA0F820063759E /* KeyboardShortcutItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22FE80B225BA0F820063759E /* KeyboardShortcutItem.swift */; };
EA057887259F54B500ACCD89 /* ColorMenuItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA057886259F54B500ACCD89 /* ColorMenuItems.swift */; };
EA0C525025AA729300AFF716 /* Visualisation.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0C524F25AA729300AFF716 /* Visualisation.swift */; };
EA0C526025AB5A2B00AFF716 /* NavigationMenuItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0C525F25AB5A2B00AFF716 /* NavigationMenuItems.swift */; };
EA0C526425AB5D1700AFF716 /* PikaWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0C526325AB5D1700AFF716 /* PikaWindow.swift */; };
EA0C526F25AB683400AFF716 /* EyedropperButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0C526E25AB683400AFF716 /* EyedropperButton.swift */; };
EA0C527325AB6C6000AFF716 /* ColorMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA0C527225AB6C6000AFF716 /* ColorMenu.swift */; };
EA257BD125D8629300C3FC54 /* SwapButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA257BD025D8629300C3FC54 /* SwapButtonStyle.swift */; };
EA424C7D25CDEF98009056A9 /* ComplianceToggleGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA424C7C25CDEF98009056A9 /* ComplianceToggleGroup.swift */; };
EA424CDE25CF0328009056A9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = EA424CE025CF0328009056A9 /* Localizable.strings */; };
Expand Down Expand Up @@ -52,6 +50,7 @@
EAD0B713259CFD2000FA2F67 /* Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD0B712259CFD2000FA2F67 /* Defaults.swift */; };
EAD0B718259D146200FA2F67 /* EyedropperButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD0B717259D146200FA2F67 /* EyedropperButtonStyle.swift */; };
EAD0B71C259D151400FA2F67 /* NavigationMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD0B71B259D151400FA2F67 /* NavigationMenu.swift */; };
EAEBF64725E878A5002999D1 /* CircleButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAEBF64625E878A5002999D1 /* CircleButtonStyle.swift */; };
EAF100C725C731AD006E1EC3 /* SplashTouchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF100C625C731AD006E1EC3 /* SplashTouchBar.swift */; };
EAF100CA25C75218006E1EC3 /* PikaTouchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF100C325C59EB3006E1EC3 /* PikaTouchBar.swift */; };
EAF100CD25C785C4006E1EC3 /* TouchBarVisual.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF100CC25C785C4006E1EC3 /* TouchBarVisual.swift */; };
Expand All @@ -63,12 +62,10 @@
226FD60F25A940F90021A67F /* VisualEffect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisualEffect.swift; sourceTree = "<group>"; };
22EF1D9A25B7AA18001102FA /* Sequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sequence.swift; sourceTree = "<group>"; };
22FE80B225BA0F820063759E /* KeyboardShortcutItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardShortcutItem.swift; sourceTree = "<group>"; };
EA057886259F54B500ACCD89 /* ColorMenuItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorMenuItems.swift; sourceTree = "<group>"; };
EA0C524F25AA729300AFF716 /* Visualisation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Visualisation.swift; sourceTree = "<group>"; };
EA0C525F25AB5A2B00AFF716 /* NavigationMenuItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationMenuItems.swift; sourceTree = "<group>"; };
EA0C526325AB5D1700AFF716 /* PikaWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PikaWindow.swift; sourceTree = "<group>"; };
EA0C526E25AB683400AFF716 /* EyedropperButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyedropperButton.swift; sourceTree = "<group>"; };
EA0C527225AB6C6000AFF716 /* ColorMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorMenu.swift; sourceTree = "<group>"; };
EA257BD025D8629300C3FC54 /* SwapButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwapButtonStyle.swift; sourceTree = "<group>"; };
EA424C7C25CDEF98009056A9 /* ComplianceToggleGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComplianceToggleGroup.swift; sourceTree = "<group>"; };
EA424CDF25CF0328009056A9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -104,6 +101,7 @@
EAD0B712259CFD2000FA2F67 /* Defaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Defaults.swift; sourceTree = "<group>"; };
EAD0B717259D146200FA2F67 /* EyedropperButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyedropperButtonStyle.swift; sourceTree = "<group>"; };
EAD0B71B259D151400FA2F67 /* NavigationMenu.swift */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.swift; path = NavigationMenu.swift; sourceTree = "<group>"; tabWidth = 4; };
EAEBF64625E878A5002999D1 /* CircleButtonStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircleButtonStyle.swift; sourceTree = "<group>"; };
EAF100C325C59EB3006E1EC3 /* PikaTouchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PikaTouchBar.swift; sourceTree = "<group>"; };
EAF100C625C731AD006E1EC3 /* SplashTouchBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashTouchBar.swift; sourceTree = "<group>"; };
EAF100CC25C785C4006E1EC3 /* TouchBarVisual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarVisual.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -233,8 +231,6 @@
children = (
EAD0B6F3259CF29300FA2F67 /* AboutView.swift */,
EAD0B6F5259CF29300FA2F67 /* AppVersion.swift */,
EA0C527225AB6C6000AFF716 /* ColorMenu.swift */,
EA057886259F54B500ACCD89 /* ColorMenuItems.swift */,
EA635DE025B4FC580014D91A /* ColorPickers.swift */,
EA801284259F8F480026D5D9 /* ComplianceToggle.swift */,
EA424C7C25CDEF98009056A9 /* ComplianceToggleGroup.swift */,
Expand Down Expand Up @@ -263,6 +259,7 @@
children = (
EAD0B717259D146200FA2F67 /* EyedropperButtonStyle.swift */,
EA257BD025D8629300C3FC54 /* SwapButtonStyle.swift */,
EAEBF64625E878A5002999D1 /* CircleButtonStyle.swift */,
);
path = Styles;
sourceTree = "<group>";
Expand Down Expand Up @@ -390,13 +387,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EA0C527325AB6C6000AFF716 /* ColorMenu.swift in Sources */,
EA72BB8B25A537C3008205E7 /* MetalShader.swift in Sources */,
22EF1D9B25B7AA18001102FA /* Sequence.swift in Sources */,
EAD0B6F9259CF29300FA2F67 /* PreferencesView.swift in Sources */,
EA72BB8825A53750008205E7 /* SplashView.swift in Sources */,
EAF100CA25C75218006E1EC3 /* PikaTouchBar.swift in Sources */,
EA057887259F54B500ACCD89 /* ColorMenuItems.swift in Sources */,
EAF100C725C731AD006E1EC3 /* SplashTouchBar.swift in Sources */,
EAA8AE1C25B8F03B0049299B /* KeyboardShortcutGrid.swift in Sources */,
EA0C525025AA729300AFF716 /* Visualisation.swift in Sources */,
Expand All @@ -422,6 +417,7 @@
EA72BBA925A7CE9C008205E7 /* NSWindowFade.swift in Sources */,
EAD0B718259D146200FA2F67 /* EyedropperButtonStyle.swift in Sources */,
EA635DC925B3B2650014D91A /* Cula.swift in Sources */,
EAEBF64725E878A5002999D1 /* CircleButtonStyle.swift in Sources */,
EA635DE125B4FC580014D91A /* ColorPickers.swift in Sources */,
221600F925A62E5B00B8B7D9 /* IconImage.swift in Sources */,
EAD0B6FA259CF29300FA2F67 /* AppVersion.swift in Sources */,
Expand Down Expand Up @@ -579,7 +575,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 14;
CURRENT_PROJECT_VERSION = 17;
DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\"";
DEVELOPMENT_TEAM = TGHU37N6EX;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -590,7 +586,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.0.9;
MARKETING_VERSION = "0.0.10-beta3";
PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -606,7 +602,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 14;
CURRENT_PROJECT_VERSION = 17;
DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\"";
DEVELOPMENT_TEAM = TGHU37N6EX;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -617,7 +613,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.0.9;
MARKETING_VERSION = "0.0.10-beta3";
PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
42 changes: 28 additions & 14 deletions Pika/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
// Define content view
let contentView = ContentView()
.environmentObject(eyedroppers)
.frame(minWidth: 400,
idealWidth: 400,
maxWidth: 500,
minHeight: 180,
idealHeight: 200,
maxHeight: 350,
.frame(minWidth: 450,
idealWidth: 450,
maxWidth: 550,
minHeight: 200,
idealHeight: 220,
maxHeight: 360,
alignment: .center)

pikaWindow = PikaWindow.createPrimaryWindow()
pikaWindow.contentView = NSHostingView(rootView: contentView)
pikaTouchBarController = PikaTouchBarController(window: pikaWindow)

// Define global keyboard shortcuts
KeyboardShortcuts.onKeyUp(for: .togglePika) { [self] in
KeyboardShortcuts.onKeyUp(for: .togglePika) { [] in
if Defaults[.viewedSplash] {
togglePopover(nil)
NSApp.sendAction(#selector(AppDelegate.triggerPickForeground), to: nil, from: nil)
}
}

Expand Down Expand Up @@ -114,11 +114,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
action: #selector(checkForUpdates(_:)),
keyEquivalent: ""
)
statusBarMenu.addItem(
withTitle: NSLocalizedString("menu.preferences", comment: "Preferences"),

let preferences = NSMenuItem(
title: NSLocalizedString("menu.preferences", comment: "Preferences"),
action: #selector(openPreferencesWindow(_:)),
keyEquivalent: ""
keyEquivalent: ","
)
preferences.keyEquivalentModifierMask = NSEvent.ModifierFlags.command
statusBarMenu.addItem(preferences)

statusBarMenu.addItem(NSMenuItem.separator())
statusBarMenu.addItem(
withTitle: NSLocalizedString("menu.quit", comment: "Quit Pika"),
Expand Down Expand Up @@ -156,7 +160,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
if aboutWindow == nil {
aboutWindow = PikaWindow.createSecondaryWindow(
title: "About",
size: NSRect(x: 0, y: 0, width: 300, height: 540),
size: NSRect(x: 0, y: 0, width: 300, height: 610),
styleMask: [.titled, .closable, .miniaturizable, .fullSizeContentView]
)
aboutTouchBarController = SplashTouchBarController(window: aboutWindow)
Expand All @@ -169,12 +173,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
if preferencesWindow == nil {
preferencesWindow = PikaWindow.createSecondaryWindow(
title: "Preferences",
size: NSRect(x: 0, y: 0, width: 550, height: 480),
size: NSRect(x: 0, y: 0, width: 550, height: 420),
styleMask: [.titled, .closable, .miniaturizable, .fullSizeContentView]
)
preferencesWindow.contentView = NSHostingView(rootView: PreferencesView())
}
preferencesWindow.makeKeyAndOrderFront(nil)
notificationCenter.post(name: Notification.Name(PikaConstants.ncTriggerPreferences), object: self)
}

@IBAction func openSplashWindow(_: Any?) {
Expand Down Expand Up @@ -210,12 +215,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
notificationCenter.post(name: Notification.Name(PikaConstants.ncTriggerCopyBackground), object: self)
}

@IBAction func triggerSwap(_: Any) {
notificationCenter.post(name: Notification.Name(PikaConstants.ncTriggerSwap), object: self)
}

@IBAction func hidePika(_: Any) {
hideMainWindow()
}

@IBAction func showPika(_: Any) {
pikaWindow.fadeIn(sender: nil, duration: 0.2)
if pikaWindow.isVisible {
pikaWindow.makeKeyAndOrderFront(self)
} else {
pikaWindow.fadeIn(sender: nil, duration: 0.2)
}
NSApp.activate(ignoringOtherApps: true)
}

@IBAction func checkForUpdates(_: Any) {
Expand Down
6 changes: 6 additions & 0 deletions Pika/Assets/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,12 @@
<action selector="triggerPickBackground:" target="Ady-hI-5gd" id="gqy-M9-vRu"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="DMb-e0-vJg"/>
<menuItem title="Swap Colors" keyEquivalent="X" allowsKeyEquivalentWhenHidden="YES" id="6j0-AT-P3M">
<connections>
<action selector="triggerSwap:" target="Ady-hI-5gd" id="Gu5-Cw-s7r"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
Expand Down
Binary file modified Pika/Assets/en.lproj/Localizable.strings
Binary file not shown.
2 changes: 2 additions & 0 deletions Pika/Constants/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ enum PikaConstants {
static let ncTriggerCopyBackground = "triggerCopyBackground"
static let ncTriggerPickForeground = "triggerPickForeground"
static let ncTriggerPickBackground = "triggerPickBackground"
static let ncTriggerSwap = "triggerSwap"
static let ncTriggerPreferences = "triggerPreferences"
}
57 changes: 57 additions & 0 deletions Pika/Styles/CircleButtonStyle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import Combine
import SwiftUI

struct CircleButtonStyle: ButtonStyle {
@State private var isHovered: Bool = false
let isVisible: Bool

private struct CircleButtonStyleView: View {
@Environment(\.colorScheme) var colorScheme: ColorScheme

let configuration: Configuration
let isVisible: Bool

func getBackgroundColor(colorScheme: ColorScheme) -> Color {
if #available(OSX 11.0, *) {
return colorScheme == .dark
? Color(red: 27 / 255, green: 27 / 255, blue: 27 / 255)
: Color(red: 233 / 255, green: 233 / 255, blue: 233 / 255)
} else {
return colorScheme == .dark
? Color(red: 50 / 255, green: 52 / 255, blue: 59 / 255)
: Color(red: 236 / 255, green: 236 / 255, blue: 236 / 255)
}
}

var body: some View {
let fgColor = colorScheme == .dark ? Color.white : .black
let bgColor: Color = getBackgroundColor(colorScheme: colorScheme)

configuration.label
.padding(.all, 8)
.background(
ZStack {
Circle()
.fill(bgColor)
.shadow(
color: Color.black.opacity(0.2),
radius: configuration.isPressed ? 1 : 2,
x: 0,
y: configuration.isPressed ? 1 : 2
)
.overlay(
Circle()
.stroke(fgColor.opacity(0.1))
)
}
)
.opacity(isVisible ? (configuration.isPressed ? 0.8 : 1.0) : 0.0)
.foregroundColor(fgColor.opacity(0.8))
.animation(.easeInOut)
}
}

func makeBody(configuration: Self.Configuration) -> some View {
CircleButtonStyleView(configuration: configuration, isVisible: isVisible)
}
}
25 changes: 22 additions & 3 deletions Pika/Styles/SwapButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import SwiftUI
struct SwapButtonStyle: ButtonStyle {
@State private var isHovered: Bool = false
let isVisible: Bool
let alt: String

private struct SwapButtonStyleView: View {
@Environment(\.colorScheme) var colorScheme: ColorScheme

@State private var isHovered: Bool = false
@State private var timerSubscription: Cancellable?
@State private var timer = Timer.publish(every: 0.25, on: .main, in: .common)

let configuration: Configuration
let isVisible: Bool
let alt: String

func getBackgroundColor(colorScheme: ColorScheme) -> Color {
if #available(OSX 11.0, *) {
Expand All @@ -31,7 +36,7 @@ struct SwapButtonStyle: ButtonStyle {
HStack {
configuration.label
if isHovered {
Text(NSLocalizedString("color.pick.swap", comment: "Swap"))
Text(alt)
.font(.system(size: 12.0))
}
}
Expand All @@ -55,7 +60,21 @@ struct SwapButtonStyle: ButtonStyle {
}
)
.onHover { hover in
self.isHovered = hover
if hover {
if self.timerSubscription == nil {
self.timer = Timer.publish(every: 1, on: .main, in: .common)
self.timerSubscription = self.timer.connect()
}
} else {
timerSubscription?.cancel()
timerSubscription = nil
self.isHovered = false
}
}
.onReceive(timer) { _ in
self.isHovered = true
timerSubscription?.cancel()
timerSubscription = nil
}
.opacity(isVisible ? (configuration.isPressed ? 0.8 : 1.0) : 0.0)
.foregroundColor(fgColor.opacity(0.8))
Expand All @@ -64,6 +83,6 @@ struct SwapButtonStyle: ButtonStyle {
}

func makeBody(configuration: Self.Configuration) -> some View {
SwapButtonStyleView(configuration: configuration, isVisible: isVisible)
SwapButtonStyleView(configuration: configuration, isVisible: isVisible, alt: alt)
}
}
Loading