Skip to content

Instantly share code, notes, and snippets.

@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:31
abgwtpB
struct InsideView: View {
@Binding var rect: [CGRect]
var body: some View {
return GeometryReader { geometry in
Rectangle()
.fill(Color.yellow)
.frame(width: 64, height: 32, alignment: .center)
.opacity(0.5)
.onAppear {
self.rect.append(geometry.frame(in: .global))
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:33
abgwtpC
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
return VStack {
if self.textColors[fCalc(c: column, r: row)] == Color.clear {
Text(self.textText[fCalc(c: column, r: row)])
.font(Fonts.futuraCondensedMedium(size:48))
.frame(width: 64, height: 64, alignment: .center)
.background(InsideView(rect: self.$rect))
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:34
abgwtpD
struct TheDropDelegate: DropDelegate {
@Binding var textID:Int?
@Binding var textText:[String]
@Binding var rect:[CGRect]
@Binding var textColors:[Color]
func validateDrop(info: DropInfo) -> Bool {
return info.hasItemsConforming(to: ["public.utf8-plain-text"])
}
func dropEntered(info: DropInfo) {
print("drop entered")
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:39
abgwtpE
func confirmColours(textColors:[Color],figures:Int) -> Bool? {
for loop in 0 ..< figures {
if textColors[loop] == Color.clear {
return false
}
}
}
@wizard1066
wizard1066 / .swift
Created April 2, 2020 07:40
abpwtpF
func confirmColours(textColors:[Color],figures:Int) -> Bool? {
for loop in 0 ..< figures {
if textColors[loop] == Color.clear {
return false
}
}
var tfigures = figures - 1
let rfigure = Int(Double(figures).squareRoot())
for _ in 0..<rfigure {
var superSet = Set<String>()
@wizard1066
wizard1066 / .swift
Created April 4, 2020 06:17
abgwtp10
func dropUpdated(info: DropInfo) -> DropProposal? {
let item = info.hasItemsConforming(to: ["public.utf8-plain-text"])
let dp = DropProposal(operation: .move)
self.startStop = true
// self.textValue = ""
runOnce = false
return dp
}
@wizard1066
wizard1066 / .swift
Created April 4, 2020 07:03
abgwtp11
.onReceive(resetPublisher, perform: { (_) in
self.showingReset = true
})
Spacer().alert(isPresented:$showingReset) {
Alert(title: Text("Reset Sure?"), message: Text("Zudoku Reset?"), primaryButton: .destructive(Text("Reset")) {
for loop in 0 ..< self.textValue.count * self.textValue.count {
self.textText[loop] = ""
self.textColors[loop] = Color.clear
@wizard1066
wizard1066 / .swift
Created April 4, 2020 07:24
abgwtp12
HStack(alignment: .center, spacing: 8) {
ForEach((0 ..< textValue.count), id: \.self) { column in
Text(self.textValue[column])
.font(Fonts.futuraCondensedMedium(size: fontSize))
.frame(width: minWidith, height: minHeight, alignment: .center)
.background(backgrounds[column])
.cornerRadius(minHeight/2)
.onTapGesture {
self.poke = self.textValue[column]
}
@wizard1066
wizard1066 / .swift
Created April 4, 2020 07:25
abgwtp13
VStack(alignment: .center, spacing: 8) {
ForEach((0 ..< self.textValue.count).reversed(), id: \.self) { row in
HStack(alignment: .center, spacing: 8) {
ForEach((0 ..< self.textValue.count).reversed(), id: \.self) { column in
return VStack {
if self.textColors[fCalc(c: column, r: row, x: self.textValue.count)] == Color.clear {
Text(self.textText[fCalc(c: column, r: row, x: self.textValue.count)])
.font(Fonts.futuraCondensedMedium(size:fontSize - 12))
.frame(width: minWidith, height: minHeight, alignment: .center)
.background(InsideView(rect: self.$rect))
@wizard1066
wizard1066 / .swift
Created April 4, 2020 07:54
abgwtp14
func performDrop(info: DropInfo) -> Bool {
textID = dropTarget(info: info)
if textID == nil {
return false
}
if let item = info.itemProviders(for: ["public.utf8-plain-text"]).first {
item.loadItem(forTypeIdentifier: "public.utf8-plain-text", options: nil) { (urlData, error) in
DispatchQueue.main.async {