Skip to content

Instantly share code, notes, and snippets.

View yosshi4486's full-sized avatar

yosshi4486 yosshi4486

View GitHub Profile
@yosshi4486
yosshi4486 / .clinerules
Last active April 5, 2025 07:29
UIKit+VIPERアーキテクチャでiOSアプリを作るClineへの指示(いいかげん)
// 引用・参考リスト
// @hicka04 [VIPERアーキテクチャ まとめ](https://qiita.com/hicka04/items/09534b5daffec33b2bec#router)
// @mizchi [CLINEに全部賭けろ](https://zenn.dev/mizchi/articles/all-in-on-cline)
## 重要
ユーザーはあなたよりプログラミングが得意ですが、時短のためにあなたにコーディングを依頼しています。
2回以上連続でテストを失敗した時は、現在の状況を整理して、一緒に解決方法を考えます。
struct ContentView: View {
var body: some View {
FloatingCard {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
@yosshi4486
yosshi4486 / PageView.swift
Created February 16, 2025 07:24
Simple UIPageViewController Bridge
import SwiftUI
import UIKit
// Add refinements to this official practice:
// https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit
struct PageView<Page : View> : View {
var pages: () -> [Page]
@State private var currentIndex: Int = 0
@yosshi4486
yosshi4486 / DynamicLabeledContentStyle.swift
Created October 20, 2024 03:29
DynamicLabeledContentStyle
import SwiftUI
/// Use `VStack` when the Dynamic Type size is bigger than `.accessibility1`, otherwise; `HStack`.
struct DynamicLabeledContentStyle: LabeledContentStyle {
@Environment(\.dynamicTypeSize) var dynamicTypeSize
func makeBody(configuration: Configuration) -> some View {
if dynamicTypeSize.isAccessibilitySize {
@yosshi4486
yosshi4486 / EdgeLines.swift
Created May 3, 2024 11:52
SwiftUI: Partial Border of View
import SwiftUI
struct EdgeLines: Shape {
struct Edge: OptionSet {
static let top = Edge(rawValue: 1 << 0)
static let bottom = Edge(rawValue: 1 << 1)
static let left = Edge(rawValue: 1 << 2)
static let right = Edge(rawValue: 1 << 3)
static let all = Edge([.top, .bottom, .left, .right])
@yosshi4486
yosshi4486 / Polygon.swift
Created February 17, 2024 08:45
Polygon shape considered a corner radius.
/// 多角形のシェープ.
struct Polygon : Shape {
/// 多角形の頂点の数. デフォルト値は`3`
var numberOfVertex: Int
/// 角の半径. デフォルト値は`3`.
var cornerRadius: CGFloat
/// 直線をトップに配置するかどうかのBool値. デフォルト値は`false`.
@yosshi4486
yosshi4486 / ConvertToExtendedSRGB.swift
Last active November 26, 2023 09:35
Swift Extended sRGB Convert methods.
/// Extended Range sRGB, 拡張範囲sRGBの構造体.
///
/// ユーザーがカラーピッカーで選択した色を保存する際、
/// 拡張sRGBに変換して取り回せばDisplay P3やAdobe RGBなどRGB系の別カラースペースの場合でも気にせず取り扱え便利なため中心的に利用する.
struct ExtendedSRGB: Hashable, Codable {
/// 負数と1以上の値も扱える赤の値. 0.0~1.0はsRGBと互換性がある。
var red: CGFloat
/// 負数と1以上の値も扱える緑の値. 0.0~1.0はsRGBと互換性がある。
@yosshi4486
yosshi4486 / OnCommitModifier.swift
Created August 16, 2023 01:45
OnCommitModifier
/// データをコミットすべきタイミングで実行されるModifier
///
/// コミットされるタイミングは下記の3つ:
/// 1. `UIApplication.willTerminateNotification`通知を受け取ったとき
/// 2. `onDissapear`が呼び出されたとき
/// 3. `scenePhase`が`.background`に切り替わったとき
///
/// このModifierは上記の3つをまとめて汎用的に取り扱えるシンタックスシュガーとなっている.
struct OnCommitModifier: ViewModifier {
@yosshi4486
yosshi4486 / UIKitSplitView.swift
Last active July 22, 2023 08:34
An UIViewControllerRepresentable wrapper of UISplitViewController
/// UIKit製のUISplitViewController.
struct UIKitSplitView<Primary, Secondary>: UIViewControllerRepresentable where Primary : View, Secondary : View {
typealias UIViewControllerType = UISplitViewController
/// プライマリPaneのビューを生成するクロージャ
var primary: () -> Primary
/// セカンダリPaneのビューを生成するクロージャ
var secondary: () -> Secondary
@yosshi4486
yosshi4486 / UIKitTableView.swift
Last active July 18, 2023 13:55
UIKitTableView for some cases SwiftUI.List couldn't be applied.
//
// UIKitTableView.swift
//
// Created by yosshi4486 on 2023/07/18.
//
import SwiftUI
private struct MoveActionEnvironmentKey: EnvironmentKey {