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 CATransaction { | |
/// Executes the provided `actions` closure wrapped in `CATransaction`. | |
/// Optionally adds all the specific properties to commit the transaction with | |
/// - Parameters: | |
/// - duration: Duration of transaction | |
/// - timingFunction: Specific timing function to use with transaction | |
/// - disableActions: Wether actual animation should happen during transaction | |
/// - actions: What to do while transaction is commited | |
/// - completion: Closure to be executed when transaction is completes | |
/// |
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
/// Executes a closure and returns resulting generic value | |
/// Idea to replace 'executing closure pattern' used to assign values with some logic. | |
/// Example: | |
/// ``` | |
/// let image: UIImage? = make { | |
/// if #available(iOS 13.0, *) { | |
/// return UIImage(systemName: "plus.square.fill.on.square.fill") | |
/// } | |
/// return UIImage(named: "fallbackImage") | |
/// } |
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 | |
protocol StepAnimatable { | |
/// Start a sequence where you add each step in the `addSteps` closure. Use the provided `AnimationSequence` object | |
/// to add each step which should either be an actual animation or a delay. | |
/// The `completion` closure is executed when the last animation has finished. | |
/// - Parameters: | |
/// - addSteps: Closure used to add steps to the provided `AnimationSequence` object | |
/// - completion: Executed when the last animation has finished. |
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 Foundation | |
public extension String { | |
private static let skinToneModifiers = ["🏻", "🏼", "🏽", "🏾", "🏿"] | |
private static var lastUsedModifier: String? | |
static var randomSkinToneModifier: String { | |
var randomModifier: String | |
repeat { | |
randomModifier = skinToneModifiers.randomElement()! |
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 | |
/// Any model struct used as a ViewModel. Must at least conform to `Equatable` to do some diffing | |
public protocol ViewModellable: Equatable { } | |
/// Protocol declaring `ModelView` behavior | |
public protocol ModelViewable<Model>: UIView { | |
associatedtype Model: ViewModellable | |
var model: Model { get } |
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 QuartzCore | |
struct TimingFunction { | |
private let function: (Double) -> Double | |
init(_ function: @escaping (Double) -> Double) { | |
self.function = function | |
} | |
} |
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 | |
/// Custom scrollView that can forces touch cancellation, even in `UIControl`s | |
/// - Note: Make sure to set `canCancelContentTouches` to `true` | |
class TouchCancellingScrollView: UIScrollView { | |
/// Set to `false` to allow drags in`UIControls` | |
var canCancelControlContentTouches: Bool = true | |
/// Cancels all touches, even when touch is in a `UIControl`. |
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 | |
/// Handles taps on tappable parts in the attributed string marked with the `.tappable` attributed string key | |
extension NSAttributedString.Key { | |
public static let tappable = NSAttributedString.Key("TappableContent") | |
} | |
/// UILabel that allows tapping on parts of its contents marked with the `.tappable` key, with touch highlighting | |
/// while the touch is on the tappable range. | |
/// The ``tapHandler`` closure is called when the text is successfully tapped. The value set on the attributed |
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 Foundation | |
protocol ClosureConfigurable { } | |
extension ClosureConfigurable { | |
typealias Configurator = (Self) throws -> Void | |
/// Configures the receiver with a closure that is executed with `Self` as a parameter | |
/// - Parameter configurator: Closure executed immediately with `Self` as a parameter | |
/// - Returns: Instance after closure is applied | |
@discardableResult public func setup(with configurator: Configurator) rethrows -> Self { |