This file contains hidden or 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 AppKit | |
| /// Custom drawing of a Table's Header Row by darkening the background to a light gray rather than just being white. | |
| class GradientTableHeaderCell: NSTableHeaderCell { | |
| /// Light Mode Gradient | |
| var backgroundFillGradient: NSGradient! { | |
| NSGradient(colorsAndLocations: | |
| (NSColor.secondarySystemFill.withAlphaComponent(0.55), 0.0), // Bottom | |
| (NSColor.secondarySystemFill.withAlphaComponent(0.075), 1.0) // Top |
This file contains hidden or 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 SwiftUI | |
| @main | |
| struct TravelPhotographyApp: App { | |
| var body: some Scene { | |
| WindowGroup { | |
| RootView() | |
| } | |
| .commands { | |
| TextEditingCommands() |
This file contains hidden or 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 Foundation | |
| import SwiftUI | |
| import UIKit | |
| extension UIBlurEffect { | |
| public static func variableBlurEffect(radius: Double, imageMask: UIImage) -> UIBlurEffect? { | |
| let methodType = (@convention(c) (AnyClass, Selector, Double, UIImage) -> UIBlurEffect).self | |
| let selectorName = ["imageMask:", "effectWithVariableBlurRadius:"].reversed().joined() | |
| let selector = NSSelectorFromString(selectorName) |
This file contains hidden or 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 SwiftUI | |
| /// Describe a potentially destructive action to the user. | |
| /// | |
| /// A confirmation describes the action to the user and provides a mechanism for confirming the action in the | |
| /// form of a `Button`. You present a confirmation by calling the environment's confirm action: | |
| /// | |
| /// ```swift | |
| /// @Environment(\.confirm) private var confirm | |
| /// |
This file contains hidden or 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
| // | |
| // MIT License | |
| // | |
| // Copyright (c) 2023 Sophiestication Software | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or 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 SwiftUI | |
| extension View { | |
| @MainActor | |
| func pdf(size: ProposedViewSize) -> Data { | |
| let renderer = ImageRenderer(content: self) | |
| renderer.proposedSize = size | |
| var pdfData = NSMutableData() | |
| renderer.render { size, render in | |
| var mediaBox = CGRect(origin: .zero, size: size) |
This file contains hidden or 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 Foundation | |
| import UIKit | |
| @propertyWrapper | |
| class Tappable<T: UIView>: NSObject, UIGestureRecognizerDelegate { | |
| // MARK: - Public Properties | |
| public var wrappedValue: T? { | |
| willSet { | |
| removeGesture() |
This file contains hidden or 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
| /// MIT License | |
| /// | |
| /// Copyright (c) 2021 Lukas Kubanek, Structured Path GmbH | |
| /// | |
| /// Permission is hereby granted, free of charge, to any person obtaining a copy | |
| /// of this software and associated documentation files (the "Software"), to deal | |
| /// in the Software without restriction, including without limitation the rights | |
| /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| /// copies of the Software, and to permit persons to whom the Software is | |
| /// furnished to do so, subject to the following conditions: |
This file contains hidden or 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
| // In my core data stack | |
| let container = NSPersistentCloudKitContainer(name: "DataModel") | |
| let storeUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupIdentifier)!.appendingPathComponent("DataModel.sqlite") | |
| // Enable history tracking and remote notifications | |
| guard let description = container.persistentStoreDescriptions.first else { | |
| fatalError("###\(#function): Failed to retrieve a persistent store description.") | |
| } | |
| description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) | |
| description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) |
This file contains hidden or 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
| // View-based toolbar items do not auto-validate by default, since the toolbar item view may | |
| // be of any type. This subclass validates a toolbar item NSControl view against its action target. | |
| class ToolbarItemWithControlValidating: NSToolbarItem { | |
| override func validate() { | |
| // validate with views view | |
| if let action = self.action { | |
| let validator = NSApp.target(forAction: action, to: self.target, from: self) as AnyObject? | |
| switch validator { | |
| case let validator as NSToolbarItemValidation: | |
| isEnabled = validator.validateToolbarItem(self) |
NewerOlder