cleaning things up

This commit is contained in:
talksik
2021-12-16 22:47:51 -08:00
parent 2047ed833b
commit b7f4240edf
@@ -77,22 +77,22 @@ struct InnerCircleView: View {
header header
} }
Path { path in // Path { path in
//
//draw the axes // //draw the axes
path.move(to: CGPoint(x:0, y:universalSize.height*0.5 )) // path.move(to: CGPoint(x:0, y:universalSize.height*0.5 ))
//
path.addLine(to: CGPoint(x:universalSize.width, y: universalSize.height*0.5)) // path.addLine(to: CGPoint(x:universalSize.width, y: universalSize.height*0.5))
//
path.move(to: CGPoint(x:universalSize.width*0.5, y:0 )) // path.move(to: CGPoint(x:universalSize.width*0.5, y:0 ))
//
path.addLine(to: CGPoint(x:universalSize.width * 0.5, y: universalSize.height)) // path.addLine(to: CGPoint(x:universalSize.width * 0.5, y: universalSize.height))
//
//
//TODO: draw the acceptance boxes // //TODO: draw the acceptance boxes
} // }
.stroke(Color.black) // .stroke(Color.black)
.edgesIgnoringSafeArea(.all) // .edgesIgnoringSafeArea(.all)
} }
.onAppear() { .onAppear() {
self.animateWaves = true self.animateWaves = true
@@ -105,7 +105,7 @@ struct InnerCircleView: View {
private static let size: CGFloat = 80 private static let size: CGFloat = 80
private static let spacingBetweenColumns: CGFloat = 10 private static let spacingBetweenColumns: CGFloat = 10
private static let spacingBetweenRows: CGFloat = 10 private static let spacingBetweenRows: CGFloat = 10
private static let totalColumns: Int = Int(log2(Double(Self.numberOfItems))) private static let totalColumns: Int = Int(log2(Double(Self.numberOfItems))) + 1 // scaling the circles
@State private var selectedUserIndex = 0 @State private var selectedUserIndex = 0
@@ -133,15 +133,6 @@ struct InnerCircleView: View {
// TODO: why did I start at 1? for the image name? just decrease count for that specifically // TODO: why did I start at 1? for the image name? just decrease count for that specifically
ForEach(1..<Self.numberOfItems + 1) { value in ForEach(1..<Self.numberOfItems + 1) { value in
GeometryReader {gridProxy in GeometryReader {gridProxy in
let posRelToGrid = gridProxy.frame(in: .global) // relative to the entire screen
let midX = getRowNumber(value) % 2 == 0 ? posRelToGrid.midX + (Self.size / 2) + (Self.spacingBetweenColumns / 2) : posRelToGrid.midX
let midY = posRelToGrid.midY
// TESTING
Text("x: \(midX) y: \(midY)")
.font(.caption)
.foregroundColor(Color.black)
//
Image("Artboards_Diversity_Avatars_by_Netguru-\(value)") Image("Artboards_Diversity_Avatars_by_Netguru-\(value)")
.resizable() .resizable()
.scaledToFit() .scaledToFit()
@@ -153,15 +144,18 @@ struct InnerCircleView: View {
x: honeycombOffSetX(value), x: honeycombOffSetX(value),
y: 0 y: 0
) )
.onTapGesture {
self.selectedUserIndex = value
print("the selected item is: \(value)")
}
} // geometry reader } // geometry reader
.id(value) // id for scrollviewreader .id(value) // id for scrollviewreader
.animation(Animation.spring())
.frame(height: Self.size) .frame(height: Self.size)
.onTapGesture {
self.selectedUserIndex = value
withAnimation(Animation.spring()) {
scrollReaderValue.scrollTo(value, anchor: .top)
}
print("the selected item is: \(value)")
}
.animation(Animation.spring())
} }
} // lazyvgrid } // lazyvgrid
.padding(.trailing, Self.size / 2 + Self.spacingBetweenColumns / 2) // because of the offset of last column .padding(.trailing, Self.size / 2 + Self.spacingBetweenColumns / 2) // because of the offset of last column