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 | |
import Combine | |
@propertyWrapper | |
final class UserDefault<Wrapped>: NSObject, ObservableObject { | |
typealias Validator = (Wrapped) -> (Wrapped) | |
private let suite: UserDefaults | |
private let key: String |
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 | |
struct LabeledViewAlignment: AlignmentID { | |
static func defaultValue(in context: ViewDimensions) -> CGFloat { | |
context[.leading] | |
} | |
} | |
extension HorizontalAlignment { | |
static let labeledViewAlignment = HorizontalAlignment(LabeledViewAlignment.self) |
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 Photos | |
final class FetchResult<Object: AnyObject> { | |
let phFetchResult: PHFetchResult<Object> | |
init(_ phFetchResult: PHFetchResult<Object>) { | |
self.phFetchResult = phFetchResult | |
} | |
} |
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 Combine | |
import Foundation | |
final class Property<Value> { | |
// MARK: Public properties | |
var value: Value { subject.value } | |
// MARK: Private properties |
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 ContentView: View { | |
@State private var text = "" | |
var body: some View { | |
ScrollView { | |
LazyVStack(alignment: .leading) { | |
ForEach(1 ..< 20) { number in | |
Text("Row number \(number)") | |
.padding() | |
} |
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
extension Effect { | |
static func resultTask( | |
priority: TaskPriority? = nil, | |
operation: @escaping @Sendable () async -> Result<Output, Failure> | |
) -> Self { | |
Effect<Result<Output, Failure>, Never> | |
.task(priority: priority, operation: operation) | |
.flatMap { result -> Self in | |
switch result { | |
case .success(let value): return Effect(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 | |
struct SymmetricHStack<Content: View, Leading: View, Trailing: View>: View { | |
@ViewBuilder var content: () -> Content | |
@ViewBuilder var leading: () -> Leading | |
@ViewBuilder var trailing: () -> Trailing | |
var body: some View { | |
HStack { | |
ZStack(alignment: .leading) { |
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 ScalingFrameModifier: ViewModifier { | |
@ScaledMetric var width: CGFloat | |
@ScaledMetric var height: CGFloat | |
var hasWidthSpecified: Bool | |
var hasHeightSpecified: Bool | |
var alignment: Alignment = .center | |
init( | |
width: CGFloat? = nil, | |
height: CGFloat? = 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 SwiftUI | |
protocol TitleProvider { | |
var title: String { get } | |
} | |
extension ColorScheme { | |
var dual: ColorScheme { | |
switch self { | |
case .light: return .dark |