From c934dd5c21bc2cf37676bf4bf330c638e47fa7f3 Mon Sep 17 00:00:00 2001 From: saint Date: Thu, 23 May 2024 10:57:00 -0400 Subject: [PATCH] builds but not working really this is with the refactor thing and yeah need to fix more stuff but it builds at least --- gloss/ContentView.swift | 121 ++++++---------------------------------- 1 file changed, 16 insertions(+), 105 deletions(-) diff --git a/gloss/ContentView.swift b/gloss/ContentView.swift index cda3ac0..ac74900 100644 --- a/gloss/ContentView.swift +++ b/gloss/ContentView.swift @@ -293,98 +293,9 @@ struct ContentView: View { VStack { // Top pane - ScrollViewReader { proxy in - VisibilityTrackingScrollView(action: handleVisibilityChanged) { - LazyVStack { - ForEach(segs) { seg in - SegRow(seg: seg, - ribbonId: selectedRibbon[0].id!) - .id("\(seg.id)") - .offset(x: -dragOffset) - .padding(EdgeInsets(top: 10, leading: 20, bottom: 40, trailing: 20)) - .trackVisibility(id: "\(seg.id)") - } - } - .background(Color(red: 0.18, green: 0.18, blue: 0.18)) - } - - .onAppear { - goToRibbon(selectedRibbon: selectedRibbon[0], - destRibbon: selectedRibbon[0], - appDatabase: appDatabase, - paneConnector: $paneConnector, - loading: true) - } - .onChange(of: paneConnector.refresh) { _ in - - Task { - DispatchQueue.main.async { - let gTracker = paneConnector.visibilityTracker! - - Print("scroll Id target: \(paneConnector.scrollId)") - proxy.scrollTo(paneConnector.scrollId, anchor: .top) - - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - Print(" scroll id target", paneConnector.scrollId) - Print(" current id ", paneConnector.currentId) - Print(gTracker.sortedViewIDs) - if paneConnector.currentId != paneConnector.scrollId { - Print("NO MATCH") - } - - Print(" current offset ", gTracker.visibleViews[paneConnector.scrollId]) - var curOffset = gTracker.visibleViews[paneConnector.scrollId] - Print(" stats", gTracker.visibleViews) - if curOffset != nil { - paneConnector.setScrollOffset = CGFloat(Int(paneConnector.scrollOffset) - Int(curOffset!)) - // setScrollOffset = CGFloat(Int(paneConnector.scrollOffset) - Int(curOffset!)) - // setScrollOffset = CGFloat(Int(paneConnector.scrollOffset) - Int(curOffset!)) - Print("applying scroll offset \(paneConnector.setScrollOffset)") - - // paneConnector = paneConnector.copy() as! PaneConnector - self.refresh.toggle() - } else { - var adjust = (Int(paneConnector.scrollId)! - Int(paneConnector.currentId)!) * 200 - Print("adjusting \(adjust)") - - paneConnector.setScrollOffset = CGFloat(adjust) - refresh.toggle() - } - } - } - } - } - .introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in - Print("introspect") - - // Weird hack for reactivity - if self.refresh { - let reactive = self.refresh - } - - // if self.paneConnector != nil { - // let reactive = self.paneConnector - // } - - if paneConnector.setScrollOffset != nil { - DispatchQueue.main.async { - scrollView.contentOffset.y = scrollView.contentOffset.y + paneConnector.setScrollOffset! - paneConnector.setScrollOffset = nil - - withAnimation(.easeIn(duration: 0.2)) { - paneConnector.showOverlay = false - self.refresh.toggle() - } - } - } - - Print("end introspect") - } - .listStyle(PlainListStyle()) - } - .zIndex(1) - .background(Color(red: 0.2, green: 0.2, blue: 0.2)) - .frame(width: geometry.size.width - 50, height: geometry.size.height / 2 - vertSep) + Pane(paneConnector: paneConnector, + segs: segs, + selectedRibbon: selectedRibbon) ////// @@ -475,21 +386,21 @@ struct ContentView: View { ) - if self.paneConnector.showOverlay { - Rectangle() - .frame(width: geometry.size.width - 50, height: geometry.size.height + 200) - .background(.ultraThinMaterial) + // if self.paneConnector.showOverlay { + // Rectangle() + // .frame(width: geometry.size.width - 50, height: geometry.size.height + 200) + // .background(.ultraThinMaterial) - // .blur(radius: 0.8) - .offset(x: 30, y: -100) - .opacity(0.98) - .transition(.opacity) + // // .blur(radius: 0.8) + // .offset(x: 30, y: -100) + // .opacity(0.98) + // .transition(.opacity) - // .frame(width: geometry.size.width - 50) - .offset(x: pulledOut.width) - .offset(x: viewState.width, y: viewState.height) - .zIndex(2) - } + // // .frame(width: geometry.size.width - 50) + // .offset(x: pulledOut.width) + // .offset(x: viewState.width, y: viewState.height) + // .zIndex(2) + // } } } }