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 | |
| import PanModal | |
| struct ExampleView: View { | |
| @State var detail: AnyView? = nil | |
| @State var items: [String] = ["Detail 1", "Detail 2", "Detail 3"] | |
| var body: some View { | |
| NavigationView { |
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 | |
| extension Data { | |
| var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription | |
| guard let object = try? JSONSerialization.jsonObject(with: self, options: []), | |
| let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]), | |
| let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil } | |
| return prettyPrintedString | |
| } |
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 | |
| import UIKit | |
| // from https://github.com/cashapp/AccessibilitySnapshot | |
| import AccessibilitySnapshotCore | |
| struct AccessibilityPreview<Content: View>: View { | |
| let content: Content | |
| var body: some View { |
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 RxSwift | |
| import RxCocoa | |
| @dynamicMemberLookup | |
| protocol DynamicMemberLookupableObservableType: AssociateObservable { | |
| subscript<T>(dynamicMember keyPath: KeyPath<Value, T>) -> Observable<T> { get } | |
| } | |
| extension DynamicMemberLookupableObservableType { | |
| subscript<T>(dynamicMember keyPath: KeyPath<Value, T>) -> Observable<T> { |
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 DictionaryCoding | |
| /// Note: This relies on the DictionaryCoding package https://github.com/elegantchaos/DictionaryCoding | |
| struct QueryParamEncoder { | |
| func encode<T: Encodable>(_ item: T) throws -> String { | |
| let encoder = DictionaryEncoder() | |
| let encoded: [String: Any] = try encoder.encode(item) | |
| let queryParams = encodeDictionary(encoded) | |
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 | |
| struct HalfShape: Shape { | |
| let left: Bool | |
| func path(in rect: CGRect) -> Path { | |
| return Path { path in | |
| let width = rect.width | |
| let height = rect.height |
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
| // | |
| // ContinuousStarRating.swift | |
| // | |
| // 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
| // | |
| // RotatorView.swift | |
| // | |
| // Created by Pavel Zak on 16/11/2020. | |
| // original idea by: https://twitter.com/beesandbombs/status/1326312738033983489?s=20 | |
| // | |
| import SwiftUI | |
| func pow(_ x: Int, _ y: Int) -> Int { |
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
| // | |
| // Lightnings fun | |
| // | |
| // BEWARE highly unoptimized! | |
| // | |
| // Created by Pavel Zak on 30/11/2020. | |
| // | |
| import SwiftUI |
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 | |
| @dynamicMemberLookup | |
| final class DynamicUserDefaults { | |
| static var standard: DynamicUserDefaults { | |
| return DynamicUserDefaults(.standard) | |
| } | |
| private let keys = Keys() |