Skip to content

Instantly share code, notes, and snippets.

View byaruhaf's full-sized avatar
🏄
Surfing Xcode

Franklin Byaruhanga byaruhaf

🏄
Surfing Xcode
View GitHub Profile
@stevdza-san
stevdza-san / RequestState.kt
Last active July 21, 2024 14:14
Useful wrapper class for handling the data in Jetpack Compose
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.runtime.Composable
sealed class RequestState<out T> {
data object Idle : RequestState<Nothing>()
data object Loading : RequestState<Nothing>()
@marcoarment
marcoarment / Searchable_iOS16.swift
Created July 11, 2023 19:23
Backporting iOS 17's SwiftUI .searchable($isPresented) binding for iOS 16
import SwiftUI
extension View {
public func searchable_iOS16(text: Binding<String>, isPresented: Binding<Bool>, placement: SearchFieldPlacement) -> some View {
modifier(Searchable_iOS16(text: text, isPresented: isPresented, placement: placement))
}
}
public struct Searchable_iOS16: ViewModifier {
@Binding var text: String
@BobbyESP
BobbyESP / libs.versions.toml
Created April 29, 2023 10:05
A very complete TOML file for Android Development mainly thought for the new Jetpack Compose framework
[versions]
accompanist = "0.29.2-rc"
androidGradlePlugin = "7.4.2"
androidxComposeBom = "2023.01.00"
androidxComposeCompiler = "1.4.6"
androidxCore = "1.10.0-rc01"
androidMaterial = "1.9.0-alpha02"
androidxAppCompat = "1.7.0-alpha02"
androidxActivity = "1.7.1"
markdownDependency = "0.3.2"
@yimajo
yimajo / Query+AsyncTrowingStream.swift
Created March 17, 2023 15:22
Wrap Firestore's addSnapshotListner method for use with AsyncThrowingStream.
import FirebaseFirestore
// MARK: - async
extension Query {
func addSnapshotListener<T>(
includeMetadataChanges: Bool = false
) -> AsyncThrowingStream<[T], Error> where T: Decodable{
.init { continuation in
let listener = addSnapshotListener(includeMetadataChanges: includeMetadataChanges) { result in
//
// CacheAsyncImage.swift
//
// Created by Costantino Pistagna on 08/02/23.
//
import SwiftUI
struct CacheAsyncImage<Content, Content2>: View where Content: View, Content2: View {
private let url: URL?
@yimajo
yimajo / Query+Result.swift
Created January 23, 2023 06:59
FirebaseFirestore Query Snapshot listener to Result conversion wrapper.
import FirebaseFirestore
@available(swift 5.0)
public extension Query {
func addSnapshotListener(
includeMetadataChanges: Bool = false,
listener: @escaping (Result<QuerySnapshot, Error>) -> ()
) -> some ListenerRegistration {
addSnapshotListener(includeMetadataChanges: includeMetadataChanges) { snapshot, error in
if let error {
@carlynorama
carlynorama / debouncingTextField.swift
Last active September 17, 2022 16:54
Debouncing Text Field
//
// DebouncingTextField.swift
// LocationSearchResults
//
// Created by Labtanza on 8/13/22.
// https://stackoverflow.com/questions/66164898/swiftui-combine-debounce-textfield
// https://stackoverflow.com/questions/62635914/initialize-stateobject-with-a-parameter-in-swiftui
import SwiftUI
@TheNightmanCodeth
TheNightmanCodeth / XcodeCloudModel.ts
Created September 7, 2022 17:04
Xcode Cloud Webhook Request TypeScript Model
/*
* This file containes interfaces that represent the content of the
* webhook request's body. I won't be using all of these but figured
* someone might find this useful one day <3
*
* Copyright (C) 2022 Joseph Diragi
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@chriseidhof
chriseidhof / ContentView.swift
Last active March 27, 2024 19:14
Variadic Views
import SwiftUI
struct MyValue: _ViewTraitKey {
static var defaultValue: Int = 0
}
extension View {
func myValue(_ value: Int) -> some View {
_trait(MyValue.self, value)
}
@samwize
samwize / pre-commit
Last active May 9, 2022 07:25 — forked from candostdagdeviren/pre-commit
Git Pre-Commit hook with SwiftLInt
#!/bin/bash
SWIFT_LINT=./Pods/SwiftLint/swiftlint
if [[ -e "${SWIFT_LINT}" ]]; then
# Export files in SCRIPT_INPUT_FILE_$count to lint against later
count=0
while IFS= read -r file_path; do
export SCRIPT_INPUT_FILE_$count="$file_path"
count=$((count + 1))