This file contains 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
struct ContentView: View { | |
let colors: [Color] = [.red, .green, .blue] | |
@State | |
var model = ScrollModel() | |
var body: some View { | |
NavigationStack { | |
ScrollViewReader { value in | |
List { | |
ForEach(model.ids, id: \.self) { i in |
This file contains 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
// | |
// TextEditorView.swift | |
// SelectableEditorView | |
// | |
// Created by satoutakeshi on 2023/07/15. | |
// | |
import SwiftUI | |
#if canImport(UIKit) | |
import UIKit |
This file contains 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
// | |
// ViewController.swift | |
// CALayerFrame | |
// | |
// Created by satoutakeshi on 2021/10/02. | |
// | |
import UIKit | |
class ViewController: UIViewController { |
This file contains 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
// Created by satoutakeshi on 2021/01/30 in MIT License | |
// | |
import SwiftUI | |
struct SuperEllipse: View { | |
var body: some View { | |
Image(systemName: "moon") | |
.resizable() | |
.frame(width: 100, height: 100) |
This file contains 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
final class DataSource: ObservableObject { | |
@Published var counter = 0 | |
} | |
struct StateObjectCounterView: View { | |
@StateObject private var dataSource = DataSource() | |
var body: some View { | |
VStack { | |
Button("increment counter") { | |
dataSource.counter += 1 |
This file contains 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
master_array = [[1, 2], [3, 4]] | |
remote_array = [{"id" => 12, "config" => [3, 4]}, {"id" => 533, "config" => [1, 2]}] | |
result_test = ["a", "b"] # master_arrayと同じindexでオブジェクトを作りたい。 { "config" : [1, 2], "id":"a"} | |
array_result = master_array.map.with_index { |item, index| | |
remote = remote_array.find {|i| item == i["config"]} | |
result = { | |
"result" => result_test[index], | |
"configs" => item, | |
"id" => remote["id"] |
This file contains 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
enum BoxType: String { | |
case unknown | |
case red | |
case green | |
case blue | |
} | |
final class SingleSelectableBoxViewModel: ObservableObject { | |
@Published var selectedBox: BoxType = .unknown | |
var cancels: [AnyCancellable] = [] |
This file contains 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 Combine | |
final class MultipleSelectableViewModel: ObservableObject { | |
@Published var isSelectedRed: Bool = false | |
@Published var isSelectedGreen: Bool = false | |
@Published var isSelectedBlue: Bool = false | |
var cancels: [Cancellable] = [] |
This file contains 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
struct ErrorInfo: Error { | |
var showError: Bool | |
var message: String | |
} | |
struct ContentView: View { | |
@State var errorInfo: ErrorInfo = ErrorInfo(showError: false, message: "") | |
@State var onAppear: Bool = false | |
var body: some View { | |
ZStack { |
NewerOlder