Skip to content

Instantly share code, notes, and snippets.

View ryu1sazae's full-sized avatar
Living in the world

Ryuichi/Rick ryu1sazae

Living in the world
View GitHub Profile
@ryu1sazae
ryu1sazae / HorizontalPagingViewRepresentable.swift
Last active April 15, 2024 13:56
PagingView which can be scrolled horizontally. Confirmed on Xcode15.2, iOS16.0+
import SwiftUI
import UIKit
/// - Note: The height must be specified explicitly.
public struct HorizontalPagingViewRepresentable<Content: View>: UIViewRepresentable {
private let currentIndex: Int
private let pageIndexChanged: (Int) -> Void
private let content: () -> Content
public init(
protocol HungryState {}
// 幽霊型はインスタンス化する必要が無いのでenum
enum Hungry: HungryState {}
enum NotHungry: HungryState {}
struct Cat<State: HungryState> {}
extension Cat where State == Hungry {