Skip to content

Instantly share code, notes, and snippets.

View Codelaby's full-sized avatar

Codelaby Codelaby

View GitHub Profile
import SwiftUI
struct DotPosition: Equatable, Hashable {
let row: Int
let column: Int
}
struct DotGridView: View {
@Codelaby
Codelaby / NavigationUICustom.swift
Last active February 27, 2025 09:46
Navigation UI custom
//
// TranslucentDemo.swift
// FestivES
//
// Created by Codelaby on 27/2/25.
//
import SwiftUI
@Codelaby
Codelaby / WavingText.swift
Created February 15, 2025 16:45
WavingText animation swiftui
import SwiftUI
// https://x.com/_take_hito_/status/1890677320895066252
struct ContentView: View {
var body: some View {
WavingText()
.foregroundStyle(.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(hue: 220/360, saturation: 0.3, brightness: 0.9))
}
@Codelaby
Codelaby / InfiniteScrollView.swift
Created February 13, 2025 15:50
InfiniteScrollView hack offset
import SwiftUI
// MARK: InfiniteScrollView
struct InfiniteScrollView<Content: View>: View {
@State private var scrollPosition: ScrollPosition = ScrollPosition(idType: Int.self)
@Binding var currentIndex: Int
var spacing: CGFloat = 10
var itemSize: CGSize
var count: Int = 0
@Codelaby
Codelaby / InfiniteScrollHelper.swift
Created February 12, 2025 16:08
InfiniteScrollHelper
fileprivate struct InfiniteScrollHelper: UIViewRepresentable {
@Binding var contentSize: CGSize
@Binding var declarationRate: UIScrollView.DecelerationRate
func makeCoordinator() -> Coordinator {
Coordinator(declarationRate: declarationRate, contentSize: contentSize)
}
func makeUIView(context: Context) -> some UIView {
let view = UIView(frame: .zero)
view.backgroundColor = .clear
@Codelaby
Codelaby / InfiniteCarousel.swift
Last active February 6, 2025 09:00
InfiniteCarousel IOS18
//
// CarouselInfinite.swift
// IOS18Playground
//
// Created by Codelaby on 28/9/24.
//
// based: https://www.youtube.com/watch?v=p1nN9eFOPNQ
import SwiftUI
@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 / CustomTextField.swift
Last active January 24, 2025 12:01
Floating Label input field by SwiftUI
import SwiftUI
fileprivate extension View {
@ViewBuilder func reverseMask<Mask: View>(
alignment: Alignment = .center,
@ViewBuilder _ mask: () -> Mask
) -> some View {
self.mask {
Rectangle()
@Codelaby
Codelaby / StreakActor.swift
Last active January 9, 2025 09:42
Streak Manager Swift
/*
Third Library based -> https://github.com/lukerobertsapps/LRStreakKit
*/
import Foundation
/// Data for a streak, codable so it can be persisted
struct Streak: Codable {
/// The length of the streak in days
var length: Int = 0
@Codelaby
Codelaby / TwoListPlayground.swift
Created December 28, 2024 11:03
Drag drop two list swift
struct TwoListPlayground: View {
@State private var users1 = ["Paul", "Taylor", "Adele"]
@State private var users2 = ["Pauline", "Tom", "Adam"]
var body: some View {
VStack {
HStack {
Spacer()