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
@propertyWrapper | |
struct Storage<T: AppStorageConvertible>: RawRepresentable { | |
var rawValue: String { wrappedValue.storedValue } | |
var wrappedValue: T | |
init?(rawValue: String) { | |
guard let value = T.init(rawValue) else { return nil } | |
self.wrappedValue = value | |
} | |
init(wrappedValue: T) { |
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
// MARK: - TCAView | |
public protocol TCAView: View where Body == WithViewStore<ScopedState, ScopedAction, Content> { | |
associatedtype ViewState | |
associatedtype ViewAction | |
associatedtype ScopedState | |
associatedtype ScopedAction | |
associatedtype Content |
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
struct AnyCodingKey: CodingKey { | |
var stringValue: String | |
var intValue: Int? | |
init?(intValue: Int) { | |
self.intValue = intValue | |
self.stringValue = "\(intValue)" | |
} | |
init?(stringValue: String) { | |
self.intValue = nil |
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 | |
class DictionaryDecoder { | |
init() { } | |
func decode<T: Decodable>(_ type: T.Type, from data: [String: Any]) throws -> T { | |
let decoder = _Decoder(codingPath: [], source: data) | |
return try T(from: decoder) | |
} | |
} |
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
struct ReadSpacing<Content: View>: View { | |
@State private var spacing: CGFloat = 0 | |
@Binding private var outsideSpacing: CGFloat? | |
private let content: (CGFloat) -> Content | |
init(@ViewBuilder content: @escaping (CGFloat) -> Content) { | |
self._outsideSpacing = .constant(nil) | |
self.content = content | |
} | |
init(into spacing: Binding<CGFloat>, @ViewBuilder content: @escaping () -> Content) { |
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 | |
extension View { | |
public func discover<T: UIView>( | |
tag: Int = .random(in: (.min)...(.max)), | |
where predicate: @escaping (T) -> Bool = { _ in true }, | |
_ closure: @escaping (T) -> Void | |
) -> some View { | |
self.overlay( | |
DiscoveryView(tag: tag) |
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
struct User: Equatable { | |
var firstName: String | |
var lastName: String | |
} | |
@main | |
struct MyApp: App { | |
@State var value = User(firstName: "", lastName: "") | |
@State var showEdit = false |
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
public protocol AnalyticsReducer { | |
associatedtype State | |
associatedtype Action | |
func analytics(before: State, after: State, action: Action) -> Effect<Action> | |
} | |
public struct _AnalyticsReducer<Base: Reducer, Analytics: AnalyticsReducer>: Reducer where Analytics.State == Base.State, Analytics.Action == Base.Action { | |
@usableFromInline | |
let base: Base |
NewerOlder