Skip to content

Instantly share code, notes, and snippets.

View couchdeveloper's full-sized avatar

Andreas Grosam couchdeveloper

View GitHub Profile
@couchdeveloper
couchdeveloper / PageView.swift
Created January 6, 2023 13:37
SwiftUI PageView - a UIPageViewController with dynamic content
import SwiftUI
import Foundation
struct PageView<Page, PageContent: View>: View where
Page: Identifiable,
PageContent: Identifiable,
PageContent.ID == Page.ID
{
let uiViewControllerRepresentable: PageViewController<Page, PageContent>
@Binding var currentPage: Page
@couchdeveloper
couchdeveloper / Example.swift
Last active November 12, 2024 13:17
Observable Transducer
import Foundation
enum Mocks {}
extension Mocks { enum Counter {} }
extension Mocks.Counter {
enum State: Sendable {
case start
import Oak
import Observation
import SwiftUI
enum Counters: Transducer {
enum State: Terminable {
case idle(value: Int)
case finished(value: Int)
var isTerminal: Bool {
@couchdeveloper
couchdeveloper / NavigationSplitView.swift
Last active November 14, 2025 09:31
Demonstrates how to use a NavigationSplitView with a detail view with a NavigationStack, where the navigation path is retained when changing to different details.
import SwiftUI
enum Main {
enum Views {}
enum Models {}
}
extension Main.Models {
// The data value rendered in the Sidebar view
@couchdeveloper
couchdeveloper / EncodingStrategies.swift
Last active January 17, 2026 21:39
Static JSON Encoder
import struct Foundation.Date
import class Foundation.DateFormatter
import class Foundation.ISO8601DateFormatter
// MARK: - Root Tag Protocol
/// Root protocol for all encoding strategies.
///
/// This is a tag protocol that enables generic constraints and extensions.
public protocol EncodingStrategies: Sendable {}