Skip to content

Instantly share code, notes, and snippets.

View Codelaby's full-sized avatar

Codelaby Codelaby

View GitHub Profile
@Codelaby
Codelaby / coroutines-recursion.swift
Created March 22, 2025 18:05 — forked from adellibovi/coroutines-recursion.swift
Recursion with Swift Coroutines
import Foundation
class Tree {
let left, right: Tree?
init(left: Tree?, right: Tree?) {
self.left = left
self.right = right
}
}
let tree = (1..<100000000).reduce(Tree(left: nil, right: nil), { prev, result in
//
// ContentView.swift
// AnimationTimingCurve
//
// Created by Chris Eidhof on 25.09.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI
@Codelaby
Codelaby / ReorderableListExample.swift
Created March 17, 2025 09:26 — forked from JEuler/ReorderableListExample.swift
SwiftUI Reorder With Buttons List Example
import SwiftUI
// Simple example of a custom reordering implementation in SwiftUI
struct ReorderableListExample: View {
// Sample data
@State private var items = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5"]
@State private var isEditMode: EditMode = .inactive
var body: some View {
VStack {
@Codelaby
Codelaby / FloatingOverlayApp.swift
Created March 15, 2025 08:38 — forked from JuniperPhoton/FloatingOverlayApp.swift
A simple application to show a black, resizable, title-less, always-on-top NSWindow on Mac.
//
// FloatingOverlayApp.swift
// FloatingOverlay
//
// Created by JuniperPhoton on 2025/3/12.
//
import SwiftUI
// Dependency: https://github.com/sindresorhus/KeyboardShortcuts
@Codelaby
Codelaby / Shimmer.swift
Created March 6, 2025 07:53 — forked from xavierLowmiller/Shimmer.swift
Slide-to-Unlock animation in SwiftUI
import SwiftUI
public struct Shimmer: AnimatableModifier {
private let gradient: Gradient
@State private var position: CGFloat = 0
public var animatableData: CGFloat {
get { position }
import SwiftUI
struct DotPosition: Equatable, Hashable {
let row: Int
let column: Int
}
struct DotGridView: View {
@Codelaby
Codelaby / BezierGridView.swift
Created February 6, 2025 08:37 — forked from rygrob/BezierGridView.swift
Bézier Grid View
import SwiftUI
struct BezierGridView: View {
@State private var vertices: [[BezierVertex]]
let rows: Int
let cols: Int
init(rows: Int, cols: Int) {
self.rows = rows
@Codelaby
Codelaby / ContentView.swift
Created October 22, 2024 21:56 — forked from Lofionic/ContentView.swift
Shader fun
import SwiftUI
struct ContentView: View {
@State private var start = Date.now
var body: some View {
VStack {
TimelineView(.animation) { timeline in
let time = start.distance(to: timeline.date)
Rectangle()
import SwiftUI
import MetalKit
struct Particle {
let color: SIMD4<Float>
let radius: Float
let lifespan: Float
let position: SIMD2<Float>
let velocity: SIMD2<Float>
}