Skip to content

Instantly share code, notes, and snippets.

View benigumocom's full-sized avatar
🏠
🙆

chanzmao benigumocom

🏠
🙆
View GitHub Profile
@benigumocom
benigumocom / TestRounded.swift
Last active May 20, 2024 04:34
【Swift】少数の丸め方あれこれ - rounded() 👉 https://android.benigumo.com/20240520/swift-rounded/
import SwiftUI
struct Chart: View {
var function: (Double) -> Double
var by: Double
private let height = 20.0
private var data: [Double] {
stride(from: -3.0, to: 3.0 + by , by: by)
@benigumocom
benigumocom / TestColorValues.swift
Last active May 18, 2024 04:55
【Swift】Color の RGB + Opacity の数値を求める 👉 https://android.benigumo.com/20240518/color-rgbo/
import SwiftUI
struct TestColorValues: View {
var color: Color
@Environment(\.self) private var environment
private var resolved: Color.Resolved {
color.resolve(in: environment)
}
@benigumocom
benigumocom / TestDragGesture.swift
Last active May 15, 2024 08:36
【SwiftUI】View を ドラッグ して移動 する 👉 https://android.benigumo.com/20240514/drag-view/
import SwiftUI
struct TestDragGesture: View {
@State private var location = CGPoint(x: 150, y: 150)
@State private var startLocation: CGPoint?
var body: some View {
Circle()
.fill(.orange)
.frame(width: 200)
@benigumocom
benigumocom / TestSymbolTransition.swift
Last active May 9, 2024 07:36
【SwiftUI】.contentTransition(.symbolEffect(.replace)) 👉 https://android.benigumo.com/20240509/contenttransition/
import SwiftUI
struct TestSymbolTransition: View {
@State private var value = true
var body: some View {
VStack {
Button {
value.toggle()
extension GroupBoxStyle where Self == MusicGroupBoxStyle {
static var music: MusicGroupBoxStyle { .init() }
//static var music: Self { Self() }
}
import SwiftUI
struct BackgroundCheckeredPattern<Content: View>: View {
var size: CGFloat = 10
@ViewBuilder var content: () -> Content
var body: some View {
ZStack {
CheckeredPattern(size: size)
.edgesIgnoringSafeArea(.all)
import SwiftUI
struct TestButton: View {
var body: some View {
VStack(spacing: 16) {
Button {
} label: {
Label("Default", systemImage: "face.smiling")
}
@benigumocom
benigumocom / DebounceTextField.swift
Last active April 28, 2024 05:44
【SwiftUI】TextField debounce | Debouncing TextField 👉 https://android.benigumo.com/20240427/textfield-debounce/
import SwiftUI
import Throttler
struct TestDebounceTextField: View {
@State var debouncedText = ""
var body: some View {
VStack {
Text("\(debouncedText)")
@benigumocom
benigumocom / SnapList.swift
Last active April 24, 2024 06:03
【SwiftUI】ScrollView や List を snap する 👉 https://android.benigumo.com/20240424/snap-list/
import SwiftUI
struct SnapList: View {
private let colors: [Color] = [
.white, .black, .red, .blue, .yellow, .green
]
var body: some View {
ScrollView {
LazyVStack(spacing: 0) {
@benigumocom
benigumocom / TestShadow.swift
Last active April 23, 2024 21:05
【SwiftUI】shadow() with compositingGroup() 👉 https://android.benigumo.com/20240424/shadow-effect/
import SwiftUI
struct TestShadow: View {
var body: some View {
VStack {
Text("こちらへ")
Text("▶")
}
.padding()
.background(.yellow)