Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created April 4, 2020 07:25
Show Gist options
  • Save wizard1066/363e3c4842c33713c173f01f2e2fd20d to your computer and use it in GitHub Desktop.
Save wizard1066/363e3c4842c33713c173f01f2e2fd20d to your computer and use it in GitHub Desktop.
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))
.onDrop(of: ["public.utf8-plain-text"], delegate: dropDelegate)
.onTapGesture {
if self.poke != "" {
self.textText[fCalc(c: column, r: row, x: self.textValue.count)] = self.poke
self.textColors[fCalc(c: column, r: row, x: self.textValue.count)] = backgrounds[Int(self.poke)! - 1]
self.poke = ""
}
}
// .onAppear {
// self.textText[fCalc(c: column, r: row, x: self.textValue.count)] = String(fCalc(c: column, r: row, x: self.textValue.count))
// }
} else {
Text(self.textText[fCalc(c: column, r: row, x: self.textValue.count)])
.onTapGesture {
if self.poke != "" {
self.textText[fCalc(c: column, r: row, x: self.textValue.count)] = self.poke
self.textColors[fCalc(c: column, r: row, x: self.textValue.count)] = backgrounds[Int(self.poke)! - 1]
self.poke = ""
} else {
self.textText[fCalc(c: column, r: row, x: self.textValue.count)] = ""
self.textColors[fCalc(c: column, r: row, x: self.textValue.count)] = Color.clear
}
}
.font(Fonts.futuraCondensedMedium(size:fontSize))
.frame(width: minWidith, height: minHeight, alignment: .center)
.background(self.textColors[fCalc(c: column, r: row, x: self.textValue.count)])
.onDrop(of: ["public.utf8-plain-text"], delegate: dropDelegate)
.onDrag {
self.textColors[fCalc(c: column, r: row, x: self.textValue.count)] = Color.clear
let copyCell = self.textText[fCalc(c: column, r: row, x: self.textValue.count)]
self.textText[fCalc(c: column, r: row, x: self.textValue.count)] = ""
return NSItemProvider(object: copyCell as NSItemProviderWriting) }
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment