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
extension View { | |
// MARK: - Debounce with Binding | |
func debounce<T: Sendable & Equatable>(_ query: Binding<T>, using channel: AsyncChannel<T>, for duration: Duration, action: @Sendable @escaping (T) async -> Void) -> some View { | |
self | |
.task { | |
for await query in channel.debounce(for: duration) { | |
await action(query) | |
} | |
} | |
.task(id: query.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
@available(iOS 15.0, *) | |
public struct RichTextEditor : SwiftUICore.View { | |
public init(text: SwiftUICore.Binding<Foundation.AttributedString>) | |
@_Concurrency.MainActor @preconcurrency public var body: some SwiftUICore.View { | |
get | |
} | |
@available(iOS 15.0, *) | |
public typealias Body = @_opaqueReturnTypeOf("$s7SwiftUI14RichTextEditorV4bodyQrvp", 0) __ | |
} | |
@available(*, unavailable) |
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
// | |
// Copyright © 2024 Lucas Abijmil. All rights reserved. | |
// | |
import Speech | |
protocol TranscriptionService { | |
var delegate: TranscriptionServiceDelegate? { get set } | |
func requestPermission() async -> AuthorizationStatus |
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
protocol CameraService { | |
var delegate: CameraServiceDelegate? { get set } | |
func start() async | |
func capture() | |
} | |
@MainActor | |
protocol CameraServiceDelegate: AnyObject { | |
func didRecord(livePhoto: URL) |
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
/// - If you want to **only** detect faces in a photo you must use the `VNDetectFaceRectanglesRequest` object. | |
/// - The `results` property, of type `[VNFaceObservation]?` contains the number of faces detected. | |
/// - You can also retrieve the confidence for each `VNFaceObservation` by accessing the `confidence` property of type `VNConfidence` which provide a value between 0 and 1. | |
/// - ⚠️ Even if you retrieved a `VNFaceObservation` object, the `landmarks` property (which provides the facial features) **will always return** `nil` as you use a `VNDetectFaceRectanglesRequest` for the request. | |
private func detectFaces(in image: CGImage) throws -> [VNFaceObservation]? { | |
let request = VNDetectFaceRectanglesRequest() | |
request.revision = VNDetectFaceRectanglesRequestRevision3 | |
let handler = VNImageRequestHandler(cgImage: image) | |
try handler.perform([request]) |
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 LazyScrollView<Content: View>: View { | |
@State private var fitsVertically = false | |
@State private var fitsHorizontally = false | |
private let content: Content | |
private let axes: Axis.Set | |
private let showsIndicators: Bool | |
private var activeScrollingDirections: Axis.Set { | |
return axes.intersection((fitsVertically ? [] : Axis.Set.vertical).union(fitsHorizontally ? [] : Axis.Set.horizontal)) | |
} |
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 ScrollViewDelegate<Content: View>: View { | |
@State private var verticalScrollTimer: Timer? | |
@State private var horizontalScrollTimer: Timer? | |
@ViewBuilder private let content: Content | |
private let axes: Axis.Set | |
private let showsIndicators: Bool | |
private let onVerticalScroll: ((_ isScrolling: Bool) -> Void)? | |
private let onHorizontalScroll: ((_ isScrolling: Bool) -> Void)? | |
private let coordinateSpace = "scrollView" |