Skip to content

Instantly share code, notes, and snippets.

View DaisukeNagata's full-sized avatar
:octocat:
Focusing

EveryDaySoft DaisukeNagata

:octocat:
Focusing
View GitHub Profile
struct AlertChoiceView: View {
@State private var offSet: CGFloat = UIScreen.main.bounds.height/2
@State private var selection: Int = 1
@ObservedObject var viewRouter = ViewRouter()
@State private var edge: Edge = Edge.bottom
// 画面の閉じる判定
var body: some View {
GeometryReader { geometry in
@DaisukeNagata
DaisukeNagata / gist:a3dd13c81526f3c8d8f3743bae6c4bd0
Created April 18, 2020 14:28
SwiftUI_NotificationCenter fore and back
import SwiftUI
struct ContentView: View {
@State var model = OrientationModel()
var body: some View {
VStack {
Text("Hello, World!")
}
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
SetDesgin(c: Color.red) { Text("name") }
SetDesgin(c: Color.yellow) {Text("name") }
SetDesgin(c: Color.green) {Text("name") }
}
}
import SwiftUI
struct ContentView: View {
@State var st: String?
var body: some View {
DispatchQueue.main.async {
self.st = "123"
}
import SwiftUI
struct ContentView: View {
let d = [1,1,1,1,1,1,1,1,1,1]
var body: some View {
VStack {
Text("Sample")
}.onAppear {
self.d.lazy.map { v in
print(v, "lazy")
import SwiftUI
struct ContentView: View {
@State private var hovering = false
var body: some View {
Button(action: {
self.hovering.toggle()
}) {
let numArray:[Int?] = [60, 70, 90, nil, 90, 0, 80, 80, 0, 80]
check()
func check() {
for (i, v) in numArray.enumerated() {
if ((numArray.firstIndex(where: { _ in 0 != v && v != nil })) != nil) {
print("インデックス: \(i)")
}
}
}
import SwiftUI
struct ContentView: View {
@ObservedObject var bind = STBind()
init() {
bind.st = "111"
}
let id = ["111": 111, "222": 222, "333": 333, "444": 444, "555": 555]
let thisissorted = id.sorted { (l, r) -> Bool in
return l.value < r.value ? false : true
}
print(thisissorted)
let dic = [Dictionary<String, String>.Element]() // Not Syntactic Sugar
let dic = [(key: "", value: "")] // Syntactic Sugar