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
extension UIColor { | |
// default implementaion of hex parsing | |
public convenience init?(hex: String) { | |
let r, g, b, a: CGFloat | |
if hex.hasPrefix("#") { | |
let start = hex.index(hex.startIndex, offsetBy: 1) | |
let hexColor = String(hex[start...]) | |
if hexColor.count == 8 { |
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
// | |
// iOSToggleStyle.swift | |
// | |
// Created by Vladislav Prusakov on 03.02.2020. | |
// Copyright © 2020 Vladislav Prusakov. All rights reserved. | |
// | |
import SwiftUI | |
struct iOSToggleStyle: ToggleStyle { |
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
public extension UIImage { | |
/// Creates a dynamic image that supports displaying a different image asset when dark mode is active. | |
static func dynamic( | |
light makeLight: @autoclosure () -> UIImage, | |
dark makeDark: @autoclosure () -> UIImage | |
) -> UIImage { | |
if #available(iOS 13, *) { | |
return UIDynamicProviderImage(light: makeLight(), dark: makeDark()) | |
} else { |
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
class RangeTree<T> { | |
private var value: [T] | |
private(set) var range: Range<Int> | |
private var leftLeaf: RangeTree<T>? | |
private var rightLeaf: RangeTree<T>? | |
convenience init(array: [T]) { | |
self.init(array: array, range: 0 ..< array.count) | |
} |
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
final class CompoundProgress: Progress { | |
private struct Child { | |
let progress: Progress | |
let cancellationObservation: NSKeyValueObservation | |
let completedUnitObservation: NSKeyValueObservation | |
func invalidate() { | |
self.cancellationObservation.invalidate() | |
self.completedUnitObservation.invalidate() |