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 Combine | |
@propertyWrapper | |
struct Streamed<Value: Sendable> { | |
var wrappedValue: Value { | |
didSet { | |
onCountUpdate(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 SwiftUI | |
import Combine | |
import ComposableArchitecture | |
// MARK: - MODELS | |
struct Counter: Identifiable, Equatable { | |
let id: UUID | |
let createdAt: Date | |
var count: 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
import SwiftUI | |
import Combine | |
import ComposableArchitecture | |
// MARK: - MODELS | |
struct Counter: Identifiable, Equatable { | |
let id: UUID | |
let createdAt: Date | |
var count: 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
struct SizePreferenceKey: PreferenceKey { | |
static var defaultValue: CGSize = .zero | |
static func reduce(value: inout CGSize, nextValue: () -> CGSize) { | |
value = nextValue() | |
} | |
} | |
struct RelativeSizeModifier: ViewModifier { | |
let percentWidth: CGFloat |
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 | |
import SwiftUI | |
class ScopedGetObservable<T>: ObservableObject { | |
var cancellable: AnyCancellable? | |
let getter: () -> T | |
init<P>(getter: @autoclosure @escaping () -> T, publisher: P) where P: Publisher, P.Output == T, P.Failure == Never { | |
self.getter = getter |
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
@propertyWrapper | |
struct ObservedStorePath<Value: Equatable>: DynamicProperty { | |
@ObservedObject private var observableFilter: ObservableStoreFilter<Value> | |
var wrappedValue: Value { | |
get { | |
observableFilter.value | |
} | |
nonmutating set { | |
observableFilter.value = newValue |
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
struct ContentView: View { | |
@State var showNewCardView = false | |
@State var mirleftCards: [MirleftCard] = [ | |
MirleftCard(image: Image("beach"), title: "The Beach", description: "The amazing view of the Grande Plage."), | |
MirleftCard(image: Image("sunset"), title: "Sunset", description: "The beautiful moroccan sunset."), | |
] | |
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
struct OptionalView<Value, Content>: View where Content: View { | |
var content: (Value) -> Content | |
var value: Value | |
init?(_ value: Value?, @ViewBuilder content: @escaping (Value) -> Content) { | |
guard let value = value else { | |
return nil | |
} | |
self.value = value | |
self.content = content |
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
struct AvatarView: View { | |
var image: UIImage? | |
var initials: String? | |
var body: some View { | |
OptionalView(image) { image in | |
Image(uiImage: image) | |
} | |
.fallbackView(initials) { initials in | |
Text(initials) |
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
enum DeepLink { | |
case post(id: String, commentId: String?) | |
case user(username: String) | |
static func map(url: URL) -> DeepLink? { | |
var deepLink: DeepLink? | |
var componentsIterator = url.pathComponents.makeIterator() | |
_ = componentsIterator.next() //url components usually start with a slash so we just ignore | |
guard let firstComponent = componentsIterator.next() else { return nil } |
NewerOlder