undo
saint 2024-05-22 13:25:17 -04:00
parent cce075abaa
commit 4154f8f46d
1 changed files with 15 additions and 17 deletions

View File

@ -58,15 +58,14 @@ func goToRibbon(selectedRibbon: Ribbon,
if selectedRibbon.id != destRibbon.id! || loading {
print("switching ribbons")
showOverlay.wrappedValue = true
paneConnector.wrappedValue.showOverlay = true
if loading {
paneConnector.wrappedValue.currentId = destRibbon.scrollId
}
scrollId.wrappedValue = destRibbon.scrollId
scrollOffset.wrappedValue = CGFloat(destRibbon.scrollOffset)
// refresh.wrappedValue.toggle()
paneConnector.wrappedValue.scrollId = destRibbon.scrollId
paneConnector.wrappedValue.scrollOffset = CGFloat(destRibbon.scrollOffset)
paneConnector.wrappedValue.refresh.toggle()
var updateSelectRibbon = SelectedRibbon(id: Int64(1), ribbonId: destRibbon.id!)
@ -82,9 +81,7 @@ func goToRibbon(selectedRibbon: Ribbon,
if !loading {
print("not loading")
updatedRibbon.scrollOffset = Int(floor(scrollOffsetToSave))
// updatedRibbon.scrollId = scrollIdToSave!
updatedRibbon.scrollId = scrollIdToSave
_ = try await appDatabase.saveRibbon(&updatedRibbon)
} else {
@ -313,26 +310,26 @@ struct ContentView: View {
DispatchQueue.main.async {
let gTracker = paneConnector.visibilityTracker!
Print("scroll Id target: \(scrollId)")
proxy.scrollTo(scrollId!, anchor: .top)
Print("scroll Id target: \(paneConnector.scrollId)")
proxy.scrollTo(paneConnector.scrollId, anchor: .top)
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
Print(" scroll id target", scrollId)
Print(" current id ", currentId)
Print(" scroll id target", paneConnector.scrollId)
Print(" current id ", paneConnector.currentId)
Print(gTracker.sortedViewIDs)
if currentId! != scrollId! {
if paneConnector.currentId != paneConnector.scrollId {
Print("NO MATCH")
}
Print(" current offset ", gTracker.visibleViews[scrollId!])
var curOffset = gTracker.visibleViews[scrollId!]
Print(" current offset ", gTracker.visibleViews[paneConnector.scrollId])
var curOffset = gTracker.visibleViews[paneConnector.scrollId]
Print(" stats", gTracker.visibleViews)
if curOffset != nil {
setScrollOffset = CGFloat(Int(scrollOffset!) - Int(curOffset!))
setScrollOffset = CGFloat(Int(paneConnector.scrollOffset) - Int(curOffset!))
Print("applying scroll offset \(setScrollOffset)")
refresh2.toggle()
} else {
var adjust = (Int(scrollId!)! - Int(currentId!)!) * 200
var adjust = (Int(paneConnector.scrollId)! - Int(paneConnector.currentId)!) * 200
Print("adjusting \(adjust)")
setScrollOffset = CGFloat(adjust)
@ -350,7 +347,7 @@ struct ContentView: View {
// self.showOverlay = false
withAnimation {
showOverlay = false
paneConnector.showOverlay = false
}
}
}
@ -450,7 +447,7 @@ struct ContentView: View {
)
if showOverlay {
if paneConnector.showOverlay {
Rectangle()
.frame(width: geometry.size.width - 50, height: geometry.size.height + 200)
.background(.ultraThinMaterial)
@ -587,6 +584,7 @@ struct ContentView_Previews: PreviewProvider {
}
}
//@discardableResult
extension View {
func Print(_ vars: Any...) -> some View {
for v in vars {