Skip to content

Instantly share code, notes, and snippets.

@mireabot
mireabot / WorkoutExpandedCard.swift
Created March 7, 2025 16:38
WorkoutExpandedCard
// Workout data model
struct WorkoutData {
let name: String
let date: Date
let duration: TimeInterval
let exerciseCount: Int
let effortPercentage: Double
}
struct WorkoutExpandedCard: View {
@Koshimizu-Takehito
Koshimizu-Takehito / CountdownView.swift
Last active June 15, 2025 19:39
カウントダウンアニメーション
import SwiftUI
// https://x.com/TAAT626/status/1895841081365053901
// https://gist.github.com/TAATHub/8f9e7d987c82ef0eea62d2e420d51144
struct CountdownView: View {
@State private var counter = Counter()
var body: some View {
let radius = 120.0
ZStack {
// Modified TAATHub/GradientBorderAnimation.swift on 2025/03/01, Y.Nagatomo
// https://gist.github.com/TAATHub/0d312611e0b31265f85d3c555bf43039
// Gradient Border Animation
// See Also: https://x.com/sucodeee/status/1894700908824395843
import SwiftUI
struct ContentView: View {
@State var rotation: CGFloat = 0
@1998code
1998code / ContentView.swift
Created February 28, 2025 14:08
Shimmer Effect 2025
// Copyright © 2025 MING
// MIT License
import SwiftUI
struct ContentView: View {
@State private var colorful: Bool = true
@State private var dragLocation: CGPoint = .zero
var body: some View {
// Gradient Border Animation
// See Also: https://x.com/sucodeee/status/1894700908824395843
import SwiftUI
struct ContentView: View {
@State var rotation: CGFloat = 0
var body: some View {
VStack(spacing: 40) {
@Koshimizu-Takehito
Koshimizu-Takehito / HPicker.swift
Last active July 8, 2025 12:23
水平方向のピッカー
import SwiftUI
struct HPicker<SelectionValue, Content>: View where SelectionValue: Hashable, Content: View {
private var items: [SelectionValue]
private var numberOfDisplays: Int
private var content: (SelectionValue) -> Content
@Binding private var selection: SelectionValue?
@State private var contentOffset: Double = 0
@State private var itemWidth: Double = 100.0
@jrsaruo
jrsaruo / HorizontalInlinePicker.swift
Last active February 24, 2025 06:31
Horizontal Inline Picker by SwiftUI
import SwiftUI
// https://x.com/jrsaruo_tech/status/1893585977760743750
@available(iOS 18, *)
struct HorizontalInlinePicker<SelectionValue, Content>: View where SelectionValue: Hashable, Content: View {
@Binding var selection: SelectionValue
@State private var centerValue: SelectionValue?
#include <metal_stdlib>
using namespace metal;
float smoothMin(float x1, float x2, float k) {
float h = clamp(0.5 - 0.5 * (x2 - x1) / k, 0.0, 1.0);
return mix(x1, x2, h) - k * h * (1.0 - h);
}
float circleSDF(float2 point, float2 center, float radius) {
return length(point - center) - radius;
import SwiftUI
struct ContentView: View {
var body: some View {
WavingText()
.foregroundStyle(.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(hue: 220/360, saturation: 0.3, brightness: 0.9))
}
}
import SwiftUI
struct ContentView: View {
@State var isExpanded = [true] + Array(repeating: false, count: PageItem.samples.count)
var body: some View {
ZStack {
ForEach(1..<isExpanded.count, id: \.self) { offset in
let item = PageItem.samples[(offset-1) % PageItem.samples.count]
PageView(