Skip to content

Instantly share code, notes, and snippets.

@wizard1066
wizard1066 / .swift
Created April 4, 2020 07:59
abgwtp15
func boardFull(textColors:[Color],figures:Int) -> Bool {
for loop in 0 ..< figures {
if textColors[loop] == Color.clear {
return false
}
}
return true
}
@wizard1066
wizard1066 / .swift
Created April 4, 2020 10:54
abgwtp16
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 {
@wizard1066
wizard1066 / .swift
Created April 6, 2020 06:42
abgwtp17
HStack(alignment: .center) {
Spacer().padding()
Stepper("Cell", onIncrement: {
if self.sliderData.sliderValue < cellsUsed(sliderDB: self.sliderDB, figures: self.rect.count) {
let (id, figure, color) = self.sliderDB[Int(self.sliderData.sliderValue)]
if id != nil {
self.textText[id!] = figure!
self.textColors[id!] = color!
}
self.sliderData.sliderValue += 1
@wizard1066
wizard1066 / .swift
Created April 6, 2020 06:55
abgwtp18
HStack(alignment: .center) {
Spacer().padding()
Stepper("Cell", onIncrement: {
if self.sliderValue < cellsUsed(sliderDB: self.sliderDB, figures: self.rect.count) {
let (id, figure, color) = self.sliderDB[Int(self.sliderValue)]
if id != nil {
self.textText[id!] = figure!
self.textColors[id!] = color!
}
self.sliderValue += 1
@wizard1066
wizard1066 / .swift
Created April 6, 2020 07:21
abgwtp19
func cellHistory(column:Int, row:Int, tVcount:Int, poke:String, sliderValue:inout Int, sliderDB:inout [(Int?,String?,Color?)], textText:inout [String], textColors:inout [Color]) {
sliderDB[Int(sliderValue)] = ((fCalc(c: column, r: row, x: tVcount)),poke,backgrounds[Int(poke)! - 1])
sliderValue = sliderValue + 1
textText[fCalc(c: column, r: row, x: tVcount)] = poke
textColors[fCalc(c: column, r: row, x: tVcount)] = backgrounds[Int(poke)! - 1]
}
@wizard1066
wizard1066 / .swift
Created April 6, 2020 13:02
abgwtp20
func cellHistoryV(column:Int, row:Int, tVcount:Int, poke:String, stepperInst:StepperData, textText:inout [String], textColors:inout [Color]) {
let newRec = stepperSteps(stepIndex: (fCalc(c: column, r: row, x: tVcount)), stepText: poke, stepColor: backgrounds[Int(poke)! - 1])
stepperInst.stepperDB[stepperInst.stepperValue] = newRec
stepperInst.stepperValue = stepperInst.stepperValue + 1
textText[fCalc(c: column, r: row, x: tVcount)] = poke
textColors[fCalc(c: column, r: row, x: tVcount)] = backgrounds[Int(poke)! - 1]
}
func cellsUsedV(stepperInst:StepperData, figures:Int) -> Int {
@wizard1066
wizard1066 / .swift
Created April 6, 2020 14:21
abgwtp21
func cellHistoryV(column:Int, row:Int, tVcount:Int, poke:String, stepperInst:StepperData, textText:inout [String], textColors:inout [Color]) {
let newRec = stepperSteps(stepIndex: (fCalc(c: column, r: row, x: tVcount)), stepText: poke, stepColor: backgrounds[Int(poke)! - 1])
if textColors[fCalc(c: column, r: row, x: tVcount)] != Color.clear {
let index = stepperInst.stepperDB.firstIndex { $0.stepIndex == fCalc(c: column, r: row, x: tVcount) }
stepperInst.stepperDB[index!] = newRec
} else {
stepperInst.stepperDB[stepperInst.stepperValue] = newRec
stepperInst.stepperValue = stepperInst.stepperValue + 1
}
@wizard1066
wizard1066 / .swift
Created April 6, 2020 14:57
abgwtp22
var rectIndex = 0
struct InsideViewV: View {
@ObservedObject var stepperInst:StepperData
var body: some View {
return VStack {
// if toggle {
GeometryReader { geometry in
Rectangle()
.fill(Color.yellow)
@wizard1066
wizard1066 / .swift
Created April 6, 2020 14:58
abgwtp23
func dropTargetV(info: DropInfo) -> Int? {
for squareno in 0..<rectIndex {
if stepperInst.stepperDB[squareno].stepRect != nil {
if stepperInst.stepperDB[squareno].stepRect!.contains(info.location) {
return squareno
}
}
}
return nil
}
@wizard1066
wizard1066 / .swift
Created April 12, 2020 06:53
ddwtp1
struct dominoView: View {
@State var topNo:Int!
@State var lowNo:Int!
var body: some View {
return ZStack {
RoundedRectangle(cornerRadius: 5)
.stroke(Color.black, lineWidth: 2)
.frame(width: 48, height: 80, alignment: .top)
.background(Color.clear)