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