This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AVFoundation | |
struct SoundUtility { | |
static func play(systemSound: SystemSound) { | |
if let sound = NSSound(contentsOfFile: systemSound.path, byReference: true) { | |
sound.play() | |
} else { | |
print("Failed to play system sound") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let defaults = UserDefaults.standard | |
// MARK: Keys | |
enum Keys: String, CaseIterable { | |
case firstName | |
case websiteUrl | |
case hasLaunchedAppBefore | |
/// The default value for a given UserDefaults key | |
var defaultValue: Any { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# JBush.gitignore v1 (Nov 11, 2021) | |
# | |
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Symbol: String { | |
case add = "plus" | |
case trash = "trash" | |
case todo = "square" | |
case done = "checkmark.square" | |
} | |
/// Returns an image from the SF Symbols library | |
/// # Usage: Image(.trash) for Image(systemName: "trash") | |
extension Image { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import UIKit | |
// import SwiftUI | |
struct Device { | |
static let phone = UIDevice.current.userInterfaceIdiom == .phone | |
static let pad = UIDevice.current.userInterfaceIdiom == .pad | |
static let mac = UIDevice.current.userInterfaceIdiom == .mac | |
static let tv = UIDevice.current.userInterfaceIdiom == .tv | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* MacEditorTextView | |
* Copyright (c) Thiago Holanda 2020 | |
* https://twitter.com/tholanda | |
* | |
* MIT license | |
*/ | |
import Combine | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct JS { | |
static let index = "index" // index.js (default) | |
static let path = "dist/" // path/to/file.js | |
/// Returns the generated JavaScript code for `index.js` as a String. | |
static func get() -> String { | |
return get(file: index, path: path) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSView { | |
var hasDarkAppearance: Bool { | |
if #available(OSX 10.14, *) { | |
switch effectiveAppearance.name { | |
case .darkAqua, .vibrantDark, .accessibilityHighContrastDarkAqua, .accessibilityHighContrastVibrantDark: | |
return true | |
default: | |
return false | |
} | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NSView { | |
var backgroundColor: NSColor? { | |
get { | |
if let colorRef = self.layer?.backgroundColor { | |
return NSColor(cgColor: colorRef) | |
} else { | |
return nil | |
} | |
} | |
set { |
NewerOlder