diff --git a/gloss.xcodeproj/project.xcworkspace/xcuserdata/saint.xcuserdatad/UserInterfaceState.xcuserstate b/gloss.xcodeproj/project.xcworkspace/xcuserdata/saint.xcuserdatad/UserInterfaceState.xcuserstate index df7fb00..a2c245c 100644 Binary files a/gloss.xcodeproj/project.xcworkspace/xcuserdata/saint.xcuserdatad/UserInterfaceState.xcuserstate and b/gloss.xcodeproj/project.xcworkspace/xcuserdata/saint.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/gloss/ContentView.swift b/gloss/ContentView.swift index 0e1969f..d47e328 100644 --- a/gloss/ContentView.swift +++ b/gloss/ContentView.swift @@ -68,7 +68,7 @@ struct SwitchButton : View { action: { Task { var selectedRibbon = sr[0] - Print("SELECTED RIBBON", selectedRibbon) + // Print("SELECTED RIBBON", selectedRibbon) let userDefaults = UserDefaults.standard // var scrollOffsetToSave = userDefaults.object(forKey: "currentOffset") as? CGFloat @@ -77,8 +77,8 @@ struct SwitchButton : View { var scrollOffsetToSave = currentOffset var scrollIdToSave = currentId - Print("scrollOffsetToSave: ", scrollOffsetToSave) - Print("scrollIdToSave: ", scrollIdToSave) + // Print("scrollOffsetToSave: ", scrollOffsetToSave) + // Print("scrollIdToSave: ", scrollIdToSave) var updatedRibbon = selectedRibbon @@ -88,7 +88,7 @@ struct SwitchButton : View { if (selectedRibbon.id != ribbon.id!) { - Print("switching") + // Print("switching") scrollId = ribbon.scrollId scrollOffset = CGFloat(ribbon.scrollOffset) @@ -102,12 +102,12 @@ struct SwitchButton : View { userDefaults.set(scrollOffset, forKey: "currentOffset") var updateSelectRibbon = SelectedRibbon(id: Int64(1), ribbonId: ribbon.id!) - Print("Saving selected ribbon") - Print(updateSelectRibbon) + // Print("Saving selected ribbon") + // Print(updateSelectRibbon) do { _ = try await appDatabase.saveSelectedRibbon(&updateSelectRibbon) } catch { - Print("something wrong") + // Print("something wrong") } } @@ -116,14 +116,14 @@ struct SwitchButton : View { updatedRibbon.scrollId = scrollIdToSave! _ = try await appDatabase.saveRibbon(&updatedRibbon) - _ = Print("saved updatedRibbon", updatedRibbon) + // _ = Print("saved updatedRibbon", updatedRibbon) - Print("UPDATED") + // Print("UPDATED") scrollOffsetToSave = userDefaults.object(forKey: "currentOffset") as? CGFloat scrollIdToSave = userDefaults.object(forKey: "currentId") as? String - Print("scrollOffsetToSave: ", scrollOffsetToSave) - Print("scrollIdToSave: ", scrollIdToSave) + // Print("scrollOffsetToSave: ", scrollOffsetToSave) + // Print("scrollIdToSave: ", scrollIdToSave) } } @@ -209,7 +209,7 @@ private struct SegRow: View { // .id(seg.id) //.onTapGesture { // selectedLine = seg.id - // //Print(selectedLine) + //Print(selectedLine) //} // .listRowBackground(Color(red: 0.2, green: 0.8, blue: 0.2)) @@ -220,7 +220,7 @@ private struct SegRow: View { // .id(seg.id) //.onTapGesture { // selectedLine = seg.id - // //Print(selectedLine) + //Print(selectedLine) //} }) // } @@ -279,7 +279,7 @@ struct ContentView: View { } var body: some View { - Print("rendering") + // Print("rendering") GeometryReader { geometry in ZStack{ @@ -306,8 +306,8 @@ struct ContentView: View { refresh:$refresh ) .buttonStyle(BlueButtonStyle()) - Print("RIBBON") - Print(ribbon) + // Print("RIBBON") + // Print(ribbon) } } .frame(width: geometry.size.width, height: geometry.size.height, alignment: .topLeading) @@ -331,8 +331,8 @@ struct ContentView: View { .trackVisibility(id: "\(seg.id)") // .onChange(of: geometry.frame(in: .named("scrollView"))) { imageRect in - // Print(imageRect) - // Print(outerProxy) + //Print(imageRect) + //Print(outerProxy) // if isInView(innerRect: imageRect, isIn: outerProxy) { // visibleIndex.insert(item) // } else { @@ -346,29 +346,34 @@ struct ContentView: View { .onChange(of: refresh) { target in //if let target = target { //gTracker!.visibleViews["123123"] = CGFloat(100) - Print("ON CHANGE", gTracker!.visibleViews) - Print("removing", gTracker!.visibleViews.removeAll()) + // Print("ON CHANGE", gTracker!.visibleViews) + // Print("removing", gTracker!.visibleViews.removeAll()) proxy.scrollTo(scrollId! , anchor: .top) + Task { + // try? await Task.sleep(nanoseconds: 1_000_000_000) + DispatchQueue.main.async { - setScrollOffset = CGFloat(scrollOffset!) + // setScrollOffset = CGFloat(scrollOffset!) + setScrollOffset = CGFloat(Int(currentOffset!) * -1 + Int(scrollOffset!)) refresh2.toggle() - + } + } //} } .introspectScrollView { scrollView in - // Print("introspect") + Print("introspect") // scrollView.delegate = scrollDelegate - // Print("Scroll delegate offset", scrollDelegate.scrollOffset) + //Print("Scroll delegate offset", scrollDelegate.scrollOffset) if (setScrollOffset != nil) { - Print("Setting scroll offset", setScrollOffset) + // Print("Setting scroll offset", setScrollOffset) scrollView.contentOffset.y = scrollView.contentOffset.y + setScrollOffset! DispatchQueue.main.async { setScrollOffset = nil } } // if (thisScrollView == nil) { - // Print("init scroll") + Print("init scroll") // thisScrollView = scrollView // scrollView.contentOffset.y = CGFloat(selectedRibbon[0].scrollOffset) // } @@ -387,11 +392,11 @@ struct ContentView: View { if (endedDrag) { endedDrag = false scrollOffset = readOffset.y - 20 - _ = Print("meow") + // _ = Print("meow") } // logger.error("hello222") // NSLog("hellooo") - //Print(viewState.width) + Print(viewState.width) if (abs(gesture.translation.width) > 20) { viewState.width = gesture.translation.width } @@ -448,7 +453,7 @@ struct ContentView: View { // let userDefaults = UserDefaults.standard // Write/Set Value - Print(currentId!) + // Print(currentId!) // Print(tracker.visibleViews[currentId?]!) // userDefaults.set(currentId, forKey: "currentId") // userDefaults.set(tracker.visibleViews[currentId]!, forKey: "currentOffset") @@ -457,15 +462,15 @@ struct ContentView: View { // var updateScrollState = ScrollState(id: Int64(1), // scrollId: currentId!, // scrollOffset: Int64(tracker.visibleViews[currentId!]!)) - // Print("Savingg") - // Print(updateScrollState) + Print("Savingg") + //Print(updateScrollState) // Task(priority: .default) { // do { // _ = try await appDatabase.saveScrollState(&updateScrollState) // } catch { - // Print("something wrong") + Print("something wrong") // } // } }