Skip to content

Instantly share code, notes, and snippets.

View Codelaby's full-sized avatar

Codelaby Codelaby

View GitHub Profile
@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 / 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 / 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 / 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 / NavigationUICustom.swift
Last active February 27, 2025 09:46
Navigation UI custom
//
// TranslucentDemo.swift
// FestivES
//
// Created by Codelaby on 27/2/25.
//
import SwiftUI
import SwiftUI
struct DotPosition: Equatable, Hashable {
let row: Int
let column: Int
}
struct DotGridView: View {
@Codelaby
Codelaby / SlimeProgressDotPageIndicator.swift
Created February 24, 2025 10:46
Slime Progress Dot Indicator
// MARK: Slime Progress Dot Indicator
struct SlimeProgressDotPageIndicator: View {
private let currentPage: Int
private let numberOfPages: Int
private let hidesForSinglePage: Bool
private let config: Config
private let progress: CGFloat
private var adjustedIndex: Int {
return currentPage < 0 ? numberOfPages : (currentPage > numberOfPages ? 0 : currentPage)
@Codelaby
Codelaby / NumerciHPicker.swift
Created February 26, 2025 11:14
NumerciHPicker
//
// NumerciHPicker.swift
// FieldsPlayground
//
// Created by Codelaby on 25/2/25.
//
import SwiftUI
struct NumerciHPicker<SelectionValue, Content>: View where SelectionValue: Hashable & Sendable, Content: View {
@Codelaby
Codelaby / AppleBookScrollDemo.swift
Last active February 26, 2025 15:58
AppleBookScrollDemo
//
// AppleBookScrollDemo.swift
// IOS18Playground
//
// Created by Codelaby on 26/2/25.
//
import SwiftUI
struct Book: Identifiable, Hashable, Sendable {
@Codelaby
Codelaby / AppearancePicker.swift
Created March 5, 2025 10:13
Apperance Picker, Theme switch for swiftUI
struct AppearancePicker<SelectionValue, Content>: View where SelectionValue: Hashable & Sendable, Content: View {
private var items: [SelectionValue]
@Binding var selection: SelectionValue
let content: (SelectionValue) -> Content
// Public initializer
init(items: [SelectionValue], selection: Binding<SelectionValue>, @ViewBuilder content: @escaping (SelectionValue) -> Content) {
self.items = items
self._selection = selection
self.content = content