This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct Graph: View { | |
| @State var cells: [Cell] = [] | |
| private let colors: [Color] = [.clear, .level0, .level1, .level2, .level3, .level4] | |
| var body: some View { | |
| Grid(horizontalSpacing: 2, verticalSpacing: 2) { | |
| ForEach(0 ..< 7, id: \.self) { row in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct TestTaskID: View { | |
| @State private var text = "" | |
| @State private var taskID = UUID() | |
| var body: some View { | |
| Text("\(text)") | |
| .task(id: taskID) { // * | |
| let url = URL(string: "https://worldtimeapi.org/api/timezone/Asia/Tokyo.txt")! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct TestView: View { | |
| @State var id = false | |
| var body: some View { | |
| AutoProgressView() | |
| .padding() | |
| .id(id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import SwiftUI | |
| import AVFoundation | |
| struct SystemSoundWheelPicker: View { | |
| @State private var sounds: [SystemSoundID] = [] | |
| @State private var playingID = -1 | |
| var body: some View { | |
| Picker("", selection: $playingID) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import AVFoundation | |
| struct TestView: View { | |
| var body: some View { | |
| Button("Play1") { | |
| AudioServicesPlaySystemSound(1000) | |
| } | |
| Divider() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Observable final class Sound: Identifiable { | |
| var id: SystemSoundID | |
| var duration: Double | |
| var playing: Bool | |
| var valid: Bool { self.duration > 0.01 } | |
| init(_ id: Int, _ duration: Double, _ playing: Bool) { | |
| self.id = SystemSoundID(id) | |
| self.duration = duration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| @Observable final class ScheduledTimer { | |
| var elapsed = TimeInterval.zero | |
| private var timer: Timer? | |
| func start() { | |
| timer = Timer.scheduledTimer(withTimeInterval: 0.001, repeats: true) { _ in | |
| self.elapsed += 0.001 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct TestView: View { | |
| var body: some View { | |
| VStack { | |
| Text("top") | |
| Text("bottom") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // inspiered by | |
| // lifegame/swift/lifegame.swift at master · tex2e/lifegame | |
| // https://github.com/tex2e/lifegame/blob/master/swift/lifegame.swift | |
| @Observable final class LifeGame { | |
| var field: [[Int]] = [] | |
| var generation = 0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let d2: [[String]] = [ | |
| // x (col) → | |
| ["あ", "い", "う", "え", "お"], | |
| ["か", "き", "く", "け", "こ"], | |
| ["さ", "し", "す", "せ", "そ"] | |
| ] | |
| print(d2) | |
| // [["あ", "い", "う", "え", "お"], ["か", "き", "く", "け", "こ"], ["さ", "し", "す", "せ", "そ"]] |