View ViewController.swift
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 { |
View SuperEllipse.swift
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) |
View Content.swift
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 |
View merge.rb
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"] |
View SingleSelectableView.swift
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] = [] |
View MultipleSelectableView.swift
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] = [] |
View ContentView.swift
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 { |
View scaleAndOrient.swift
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
func scaleAndOrient(image: UIImage) -> UIImage { | |
// Set a default value for limiting image size. | |
let maxResolution: CGFloat = 640 | |
guard let cgImage = image.cgImage else { | |
print("UIImage has no CGImage backing it!") | |
return image | |
} |
View ContentView.swift
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 { | |
var body: some View { | |
NavigationView { | |
NavigationLink(destination: Text("sdetail")) { | |
Text("master") | |
.navigationBarTitle("nav", displayMode: .inline) | |
} | |
.navigationBarTitle("nav", displayMode: .large) | |
Text("detassssssil") |
NewerOlder