From 678400c05ef9642cd67656a4604b8f92df3a8a97 Mon Sep 17 00:00:00 2001 From: saint Date: Tue, 4 Jun 2024 07:34:15 -0400 Subject: [PATCH] small refactor --- gloss/ContentView.swift | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/gloss/ContentView.swift b/gloss/ContentView.swift index 51fe3b9..61095de 100644 --- a/gloss/ContentView.swift +++ b/gloss/ContentView.swift @@ -377,16 +377,16 @@ struct ContentView: View { DragGesture() .onChanged { gesture in let margin = CGFloat(50) + let dragThreshold = CGFloat(10) print("mao viewState :\(viewState.width)") print(pulledOut.width) + // threshold of how much to swipe before the view drags - if abs(gesture.translation.width) > 10 { + if abs(gesture.translation.width) > dragThreshold { viewState.width = gesture.translation.width - // if gesture.translation.width < -50, pulledOut.width == CGFloat(0) { - // } } - if viewState.width < -50 && pulledOut.width <= 0 { + if viewState.width < -margin && pulledOut.width <= 0 { dragOffset = margin + viewState.width + pulledOut.width } @@ -413,15 +413,6 @@ struct ContentView: View { setPulledOutWith = pulledOutLeft } - // if setPulledOutWith < 0 { - // setDragOffset = CGFloat(50) + setPulledOutWith - // } else if setPulledOutWith > 0 { - // setDragOffset = setPulledOutWith - // } else { - // setDragOffset = .zero - // } - - print("mao setPulledOutWith \(setPulledOutWith)") withAnimation(.spring(response: 0.2)) { pulledOut.width = setPulledOutWith dragOffset = setDragOffset @@ -429,28 +420,7 @@ struct ContentView: View { } } ) - - - // 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) - - // // .frame(width: geometry.size.width - 50) - // .offset(x: pulledOut.width) - // .offset(x: viewState.width, y: viewState.height) - // .zIndex(2) - // } } - - .onChange(of: paneConnector.refresh) { _ in - Print("we changing changing") - } } } func handleVisibilityChanged2(_: String, change _: VisibilityChange, tracker _: VisibilityTracker) {}