Skip to content

Commit

Permalink
10.15 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
superhighfives committed Jan 20, 2021
1 parent 4034b78 commit e9e6fe7
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Pika.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
221600F925A62E5B00B8B7D9 /* IconImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 221600F825A62E5B00B8B7D9 /* IconImage.swift */; };
221600FD25A636D600B8B7D9 /* ConditionalModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 221600FC25A636D600B8B7D9 /* ConditionalModifier.swift */; };
226FD61025A940F90021A67F /* VisualEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226FD60F25A940F90021A67F /* VisualEffect.swift */; };
22EF1D9B25B7AA18001102FA /* Sequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22EF1D9A25B7AA18001102FA /* Sequence.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 */; };
Expand Down Expand Up @@ -51,6 +52,7 @@
221600F825A62E5B00B8B7D9 /* IconImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconImage.swift; sourceTree = "<group>"; };
221600FC25A636D600B8B7D9 /* ConditionalModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConditionalModifier.swift; sourceTree = "<group>"; };
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>"; };
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>"; };
Expand Down Expand Up @@ -183,6 +185,7 @@
221600FC25A636D600B8B7D9 /* ConditionalModifier.swift */,
EA72BBA825A7CE9C008205E7 /* NSWindowFade.swift */,
EA635DCB25B3B42B0014D91A /* WCAGCompliance.swift */,
22EF1D9A25B7AA18001102FA /* Sequence.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -353,6 +356,7 @@
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 */,
EA057887259F54B500ACCD89 /* ColorMenuItems.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Pika/Assets/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@
</menuItem>
<menuItem title="Background" keyEquivalent="D" allowsKeyEquivalentWhenHidden="YES" id="YF5-6a-ACB">
<connections>
<action selector="triggerPickForeground:" target="Ady-hI-5gd" id="ybq-mi-p2z"/>
<action selector="triggerPickBackground:" target="Ady-hI-5gd" id="gqy-M9-vRu"/>
</connections>
</menuItem>
</items>
Expand Down
8 changes: 8 additions & 0 deletions Pika/Extensions/Sequence.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Cocoa

extension Sequence where Iterator.Element: Hashable {
func unique() -> [Iterator.Element] {
var seen: Set<Iterator.Element> = []
return filter { seen.insert($0).inserted }
}
}
12 changes: 6 additions & 6 deletions Pika/Views/ColorMenuItems.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ struct ColorMenuItems: View {
let pasteboard = NSPasteboard.general

var body: some View {
VStack(alignment: .leading, spacing: 0.0) {
Button(action: {
pasteboard.clearContents()
pasteboard.setString(eyedropper.color.toFormat(format: colorFormat), forType: .string)
}, label: { Text("Copy current format") })
Button(action: {
pasteboard.clearContents()
pasteboard.setString(eyedropper.color.toFormat(format: colorFormat), forType: .string)
}, label: { Text("Copy current format") })
VStack {
Divider()
}
Button(action: {
pasteboard.clearContents()
pasteboard.setString(eyedropper.color.toHexString(), forType: .string)
}, label: { Text("Copy color hex") })
}, label: { Text("Copy HEX values") })
Button(action: {
pasteboard.clearContents()
pasteboard.setString(eyedropper.color.toRGB8BitString(), forType: .string)
Expand Down
12 changes: 9 additions & 3 deletions Pika/Views/NavigationMenuItems.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ struct NavigationMenuItems: View {
}
}

Divider()
VStack {
Divider()
}

Group {
Button("Copy foreground", action: {
Expand All @@ -53,7 +55,9 @@ struct NavigationMenuItems: View {
}
}

Divider()
VStack {
Divider()
}

Group {
Button("About", action: {
Expand All @@ -75,7 +79,9 @@ struct NavigationMenuItems: View {
}
}

Divider()
VStack {
Divider()
}

Button("Quit", action: {
NSApplication.shared.terminate(self)
Expand Down
24 changes: 23 additions & 1 deletion Pika/Views/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@ struct PreferencesView: View {
@Default(.betaUpdates) var betaUpdates
@State var colorSpace: NSColorSpace = Defaults[.colorSpace]

func getColorSpaces() -> ([NSColorSpace], [NSColorSpace]) {
var availableSpaces = NSColorSpace.availableColorSpaces(with: .rgb).unique()
var primarySpaces: [NSColorSpace] = []

for space in availableSpaces {
if space == NSColorSpace.sRGB || space == NSColorSpace.adobeRGB1998 || space == NSColorSpace.displayP3 {
guard let index = availableSpaces.firstIndex(of: space) else { continue }
primarySpaces.append(space)
availableSpaces.remove(at: index)
}
}

return (primarySpaces, availableSpaces)
}

var body: some View {
let (primarySpaces, availableSpaces) = self.getColorSpaces()

HStack(spacing: 0) {
Group {
AppVersion()
Expand Down Expand Up @@ -44,7 +61,12 @@ struct PreferencesView: View {
Text("Set your RGB color space")
Picker("Color Space", selection:
$colorSpace.onChange(perform: { Defaults[.colorSpace] = $0 })) {
ForEach(NSColorSpace.availableColorSpaces(with: .rgb), id: \.self) { value in
ForEach(primarySpaces, id: \.self) { value in
Text(value.localizedName!)
.tag(value)
}
Divider()
ForEach(availableSpaces, id: \.self) { value in
Text(value.localizedName!)
.tag(value)
}
Expand Down
5 changes: 1 addition & 4 deletions Pika/Views/Toast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ extension View {

struct Toast<Presenting>: View where Presenting: View {
@Environment(\.colorScheme) var colorScheme: ColorScheme
/// The binding that decides the appropriate drawing in the body.
@Binding var isShowing: Bool
/// The view that will be "presenting" this toast
let presenting: () -> Presenting
/// The text to show
let text: Text

var body: some View {
Expand All @@ -39,7 +36,7 @@ struct Toast<Presenting>: View where Presenting: View {
.font(.system(size: 10.0))
.background(Color.black.opacity(0.6))
.foregroundColor(Color.white.opacity(0.8))
.cornerRadius(100)
.cornerRadius(12)
.transition(.slide)
.opacity(self.isShowing ? 1 : 0)
.offset(x: 4.0, y: 4.0)
Expand Down

0 comments on commit e9e6fe7

Please sign in to comment.