Skip to content

Instantly share code, notes, and snippets.

View LucasAbijmil's full-sized avatar
🚀

Lucas Abijmil LucasAbijmil

🚀
View GitHub Profile
@LucasAbijmil
LucasAbijmil / View+Debounce.swift
Last active September 2, 2025 08:27
Debounce in SwiftUI using async/await, AsyncChannel & Observable macro
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) {
@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)
@LucasAbijmil
LucasAbijmil / TranscriptionService.swift
Last active May 14, 2024 10:09
Audio Transcription
//
// Copyright © 2024 Lucas Abijmil. All rights reserved.
//
import Speech
protocol TranscriptionService {
var delegate: TranscriptionServiceDelegate? { get set }
func requestPermission() async -> AuthorizationStatus
@LucasAbijmil
LucasAbijmil / CameraService.swift
Created May 11, 2024 13:19
Capture Live Photo
protocol CameraService {
var delegate: CameraServiceDelegate? { get set }
func start() async
func capture()
}
@MainActor
protocol CameraServiceDelegate: AnyObject {
func didRecord(livePhoto: URL)
@LucasAbijmil
LucasAbijmil / FaceDetection.swift
Last active May 11, 2024 12:58
Face detection & face landmarks with Vision framework
/// - 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])
import Foundation
enum Share {
enum Social {
case instagram(String) // DM only, if you need to share your content into a story please see this (https://gist.github.com/kunofellasleep/e160c64ecea64441ffee0a6a3e18f685)
case whatsapp(String) // Accept WhatsApp text formatting
case telegram(String) // Accept Telegram text formatting
case twitter(String) // Tweet only
case messenger(URL) // URL only
@LucasAbijmil
LucasAbijmil / LazyScrollView.swift
Created March 4, 2023 12:17
LazyScrollView – Before iOS 16.4 otherwise use the `scrollBounceBehavior` modifier
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))
}
@LucasAbijmil
LucasAbijmil / ScrollViewDelegate.swift
Created February 5, 2023 20:31
Detect if the user scrolls in SwiftUI
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"