Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 2, 2020 07:30
Show Gist options
  • Save wizard1066/53b1f11f646a7365208bcca317861663 to your computer and use it in GitHub Desktop.
Save wizard1066/53b1f11f646a7365208bcca317861663 to your computer and use it in GitHub Desktop.
abgwtpA
import SwiftUI
import CoreServices
struct Fonts {
static func futuraCondensedMedium(size:CGFloat) -> Font{
return Font.custom("Futura-CondensedMedium",size: size)
}
}
let backgrounds = [Color.red,Color.blue,Color.orange,Color.green]
struct ContentView: View {
@State private var rect:[CGRect] = []
@State private var textText = [String](repeating: "", count: 16)
@State private var textID:Int? = 0
@State private var textValue:[String] = [" 1 "," 2 "," 3 "," 4 "]
var body: some View {
let dropDelegate = TheDropDelegate(textID: $textID, textText: $textText, rect: $rect)
return VStack {
Spacer()
HStack(alignment: .center, spacing: 20) {
ForEach((0 ..< 4), id: \.self) { column in
Text(self.textValue[column])
.font(Fonts.futuraCondensedMedium(size: 64))
.background(backgrounds[column])
.cornerRadius(32)
.onDrag {
return NSItemProvider(object: self.textValue[column] as NSItemProviderWriting) }
}
}
Spacer()
VStack(alignment: .center, spacing: 5) {
ForEach((0 ..< 4).reversed(), id: \.self) { row in
HStack(alignment: .center, spacing: 5) {
ForEach((0 ..< 4).reversed(), id: \.self) { column in
Text(self.textText[(column + (row*4))])
.font(Fonts.futuraCondensedMedium(size:48))
.frame(width: 64, height: 32, alignment: .center)
.background(InsideView(rect: self.$rect))
.onDrop(of: ["public.utf8-plain-text"], delegate: dropDelegate)
}
}
}
}
Spacer()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment