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
protocol HungryState {}
// 幽霊型はインスタンス化する必要が無いのでenum
enum Hungry: HungryState {}
enum NotHungry: HungryState {}
struct Cat<State: HungryState> {}
extension Cat where State == Hungry {
@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(
@ryu1sazae
ryu1sazae / Plugin.swift
Created May 18, 2024 04:10
SPM Plugin for Sourcery
import Foundation
import PackagePlugin
@main
struct SourceryPlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments _: [String]) async throws {
for target in context.package.targets {
guard target.name == "IntededTargetName" else { // Should be customized
continue
}