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 Swift | |
extension CaseIterable where Self: Equatable { | |
var index: Self.AllCases.Index { | |
return Self.allCases.firstIndex(of: self)! | |
} | |
} |
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 URL { | |
init?(string: String?) { | |
guard let string = string else { | |
return nil | |
} | |
self.init(string: string) | |
} |
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 | |
@propertyWrapper | |
public struct PercentEncodedURL: Codable { | |
public let wrappedValue: URL | |
public init(wrappedValue: URL) { | |
self.wrappedValue = wrappedValue | |
} |
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 | |
@propertyWrapper | |
public struct NullableURL: Codable { | |
public let wrappedValue: URL? | |
public init(wrappedValue: URL?) { | |
self.wrappedValue = wrappedValue | |
} |
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 Kingfisher | |
import FavIcon | |
struct KFFaviconProvider: ImageDataProvider { | |
let url: URL | |
let cacheKey: String | |
init(url: URL, cacheKey: String? = nil) { |
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 KeychainAccess | |
@propertyWrapper | |
struct KeychainStorage<Value: Codable> { | |
let key: String | |
let service: String | |
let initialValue: Value | |
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 Disk | |
@propertyWrapper | |
struct File<Value: Codable> { | |
let path: String | |
let directory: Disk.Directory | |
let defaultValue: Value | |
init(_ path: String, directory: Disk.Directory, defaultValue: Value) { | |
self.path = path |
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 KingFisher | |
struct KFLinkPresentationIconProvider: ImageDataProvider { | |
let url: URL | |
let cacheKey: String | |
init(url: URL, cacheKey: String? = nil) { | |
self.url = url | |
self.cacheKey = cacheKey ?? url.absoluteString |
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 Combine | |
extension Publisher { | |
func printError() -> Publishers.HandleEvents<Self> { | |
return self.handleEvents(receiveCompletion: { completion in | |
if case .failure(let error) = completion { | |
Swift.print("receive error: \(error)") | |
} | |
}) | |
} |
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 KeyedDecodingContainer { | |
func decode(_ type: URL.Type, forKey key: Key) throws -> URL { | |
do { | |
return try URL(from: superDecoder()) | |
} catch (let error) { | |
guard | |
let urlString = try? decode(String.self, forKey: key), |