Skip to content

Instantly share code, notes, and snippets.

View Koshimizu-Takehito's full-sized avatar
🏝️

takehito Koshimizu-Takehito

🏝️
View GitHub Profile
@Koshimizu-Takehito
Koshimizu-Takehito / ColorSegmentedControl.swift
Last active May 5, 2025 14:12
A demo screen showcasing a custom color-based segmented control component.
import SwiftUI
// MARK: - Demo Screen
/// A demo screen showcasing a custom color-based segmented control component.
/// Displays a list of segments and shows the selected segment's value in a large, bold title.
struct ColorSegmentedControlDemoScreen: View {
/// The static list of selectable segments.
private static let demoItems: [ColorItem] = [
ColorItem(value: "Apple", color: .red),
@Koshimizu-Takehito
Koshimizu-Takehito / BadgeModel.swift
Created May 3, 2025 09:19
Displays the provided value inside a capsule‑shaped badge.
import Observation
/// An observable view‑model that drives a numeric badge.
///
/// `BadgeModel` keeps track of the current count (`number`) and the
/// badge’s visual appearance (`style`). It also exposes two derived
/// properties that make it easy to bind the model to SwiftUI controls:
///
/// * `slider` – Bridges the `Int`‐based `number` to floating‑point
/// controls such as `Slider`.
@Koshimizu-Takehito
Koshimizu-Takehito / StrokeModifier.swift
Last active April 27, 2025 02:34
ビューに枠線を引く
import SwiftUI
// MARK: - Demo Screen
/// A sample screen demonstrating three stacked stroke effects produced by
/// `StrokeModifier`.
/// Each call to `.stroke(_:width:)` adds an additional blurred outline,
/// resulting in a multi-layered border.
struct StrokeModifierDemoScreen: View {
var body: some View {
@Koshimizu-Takehito
Koshimizu-Takehito / OrbitingDotsLoadingView.swift
Last active April 27, 2025 11:45
Demonstrates `OrbitingDotsLoader` and lets you preview it at any built-in `ControlSize`.
import SwiftUI
// MARK: - Demo Screen
/// Demonstrates `OrbitingDotsLoadingView` and lets you preview it at any
/// built-in `ControlSize`.
///
/// The loader is centered, while the bottom `ControlSizePicker` writes
/// to `controlSize`, automatically propagating the value down the view
/// hierarchy through `.controlSize(_:)`.
import SwiftUI
struct ContentView: View {
var body: some View {
TextShape(sample)
.fill(.orange)
.stroke(.blue, lineWidth: 2)
}
var sample: AttributedString {
@Koshimizu-Takehito
Koshimizu-Takehito / VisualEffect3.swift
Created April 12, 2025 10:59
visualEffectモディファイア
import SwiftUI
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
let scrollViewFrame = geometry.frame(in: .local)
ScrollView {
ForEach(0..<1000) { offset in
RowContent(offset: offset, scrollViewFrame: scrollViewFrame)
}
@Koshimizu-Takehito
Koshimizu-Takehito / MazeGenerator.swift
Last active April 12, 2025 05:23
迷路生成ロジック
import Combine
import Foundation
// MARK: - MazeGenerator (Model)
/// An actor that generates a maze using a depth-first search (DFS) based approach.
/// 深さ優先探索 (DFS) ベースのアルゴリズムを用いて迷路を生成する。
///
/// This actor provides an async stream of snapshots (`MazeGenerator.Snapshot`) so that observers
/// can track the maze's state and generation progress in real time.
@Koshimizu-Takehito
Koshimizu-Takehito / nvironmentValuesSample2.swift
Created March 29, 2025 08:44
EnvironmentValuesが大域変数ではないことを示すサンプルコード2
import SwiftUI
extension EnvironmentValues {
@Entry var customStringValue = "Goodbye, world!"
}
struct ContentView: View {
var body: some View {
RepRepresentable()
.environment(\.customStringValue, "Hello, world!")
@Koshimizu-Takehito
Koshimizu-Takehito / EnvironmentValuesSample1.swift
Created March 29, 2025 08:42
EnvironmentValuesが大域変数ではないことを示すサンプルコード
import SwiftUI
extension EnvironmentValues {
@Entry var myColor = Color.blue
}
struct ScreenX: View {
@Environment(\.myColor) var myColor: Color
var body: some View {
@Koshimizu-Takehito
Koshimizu-Takehito / FocusState.swift
Created March 28, 2025 01:59
FocusStateのサンプル
import SwiftUI
// MARK: - ContentView
struct ContentView: View {
var body: some View {
MyForm()
.frame(maxHeight: .infinity, alignment: .top)
.padding()
.padding(.top)