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
private struct ConditionalEnvironmentOverlay<Value: Equatable, OverlayContent: View>: ViewModifier { | |
@Environment(\.self) private var environmentValues | |
private let keyPath: KeyPath<EnvironmentValues, Value> | |
private let value: Value | |
private let overlayContent: OverlayContent | |
init( | |
condition: KeyPath<EnvironmentValues, Value>, | |
equals value: Value, |
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 SwiftUI | |
import Charts | |
import PlaygroundSupport | |
let spiData: [(package: String, fileCount: Int, mbSize: Int)] = [ | |
(package: "swift-markdown-ui", fileCount: 3796, mbSize: 44), | |
(package: "Microya", fileCount: 414, mbSize: 4), | |
(package: "swift-url-routing", fileCount: 9430, mbSize: 101), |
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 SwiftUI | |
public struct Platform: OptionSet { | |
public var rawValue: UInt8 | |
public static let iOS = Platform(rawValue: 1 << 0) | |
public static let macOS = Platform(rawValue: 1 << 1) | |
public static let tvOS = Platform(rawValue: 1 << 2) | |
public static let watchOS = Platform(rawValue: 1 << 3) | |
public static let all: Platform = [.iOS, .macOS, .tvOS, .watchOS] |
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 | |
#if canImport(SwiftUI) && DEBUG | |
import SwiftUI | |
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable { | |
let viewController: ViewController | |
init(_ builder: @escaping () -> ViewController) { | |
viewController = builder() | |
} |
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
@discardableResult | |
public func with<T>(_ value: T, _ builder: (T) -> Void) -> T { | |
builder(value) | |
return value | |
} | |
@discardableResult | |
public func with<T>(_ value: T, _ builder: (T) throws -> Void ) rethrows -> T { | |
try builder(value) | |
return value |
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
// | |
// ViewController.swift | |
// AttributedString | |
// | |
// Created by Peter Goldsmith on 27/02/2017. | |
// | |
import UIKit | |
class ViewController: UIViewController { |
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
/** | |
* Perform a throwing expression, and throw a custom error in case the expression threw | |
* | |
* - parameter expression: The expression to execute | |
* - parameter error: The custom error to throw instead of the expression's error | |
* - throws: The given error | |
* - returns: The return value of the given expression | |
*/ | |
func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T { | |
do { |
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
// | |
// debounce-throttle.swift | |
// | |
// Created by Simon Ljungberg on 19/12/16. | |
// License: MIT | |
// | |
import Foundation | |
extension TimeInterval { |
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
// | |
// ViewController.swift | |
// UIViewCapture | |
// | |
// Created by Yusuke on 11/7/16. | |
// Copyright © 2016 Yusuke. All rights reserved. | |
// | |
import UIKit |
NewerOlder