Bluesky app fork with some witchin' additions 💫

revert changes to scroll forwarder (#8328)

authored by hailey.at and committed by

GitHub e7fe9ab5 abbdeb4f

+13 -30
+13 -30
modules/expo-scroll-forwarder/ios/ExpoScrollForwarderView.swift
··· 9 9 } 10 10 } 11 11 12 - private var scrollView: UIScrollView? 12 + private var rctScrollView: RCTScrollView? 13 13 private var rctRefreshCtrl: RCTRefreshControl? 14 14 private var cancelGestureRecognizers: [UIGestureRecognizer]? 15 15 private var animTimer: Timer? ··· 68 68 } 69 69 70 70 @IBAction func callOnPan(_ sender: UIPanGestureRecognizer) { 71 - guard let sv = self.scrollView else { 71 + guard let rctsv = self.rctScrollView, let sv = rctsv.scrollView else { 72 72 return 73 73 } 74 74 ··· 113 113 } 114 114 115 115 func startDecayAnimation(_ translation: CGFloat, _ velocity: CGFloat) { 116 - guard let sv = self.scrollView else { 116 + guard let sv = self.rctScrollView?.scrollView else { 117 117 return 118 118 } 119 119 ··· 160 160 161 161 return offset 162 162 } 163 - 164 - private func findScrollView(in view: UIView, foundCount: Int) -> UIScrollView? { 165 - var foundCount = foundCount 166 - if let sv = view as? UIScrollView { return sv } 167 - for child in view.subviews { 168 - if let found = findScrollView(in: child, foundCount: foundCount) { 169 - if foundCount == 1 { 170 - print("found sv: \(found)") 171 - // return found 172 - } else { 173 - print("found sv: \(found)") 174 - foundCount += 1 175 - } 176 - } 163 + 164 + func tryFindScrollView() { 165 + guard let scrollViewTag = scrollViewTag else { 166 + return 177 167 } 178 - return nil 179 - } 180 168 181 - func tryFindScrollView() { 182 169 // Before we switch to a different scrollview, we always want to remove the cancel gesture recognizer. 183 170 // Otherwise we might end up with duplicates when we switch back to that scrollview. 184 171 self.removeCancelGestureRecognizers() 185 - 186 - guard let sv = self.findScrollView(in: self.superview!.superview!.superview!, foundCount: 0) else { 187 - print("⚠️ ExpoScrollForwarder: couldn’t find UIScrollView under tag \(tag)") 188 - return 189 - } 190 172 191 - self.scrollView = sv 192 - self.rctRefreshCtrl = sv.refreshControl as? RCTRefreshControl 173 + self.rctScrollView = self.appContext? 174 + .findView(withTag: scrollViewTag, ofType: RCTScrollView.self) 175 + self.rctRefreshCtrl = self.rctScrollView?.scrollView.refreshControl as? RCTRefreshControl 193 176 194 177 self.addCancelGestureRecognizers() 195 178 } 196 179 197 180 func addCancelGestureRecognizers() { 198 181 self.cancelGestureRecognizers?.forEach { r in 199 - self.scrollView?.addGestureRecognizer(r) 182 + self.rctScrollView?.scrollView?.addGestureRecognizer(r) 200 183 } 201 184 } 202 185 203 186 func removeCancelGestureRecognizers() { 204 187 self.cancelGestureRecognizers?.forEach { r in 205 - self.scrollView?.removeGestureRecognizer(r) 188 + self.rctScrollView?.scrollView?.removeGestureRecognizer(r) 206 189 } 207 190 } 208 191 ··· 219 202 } 220 203 221 204 func scrollToOffset(_ offset: Int, animated: Bool = true) { 222 - self.scrollView?.scrollRectToVisible(CGRect(x: 0, y: offset, width: 0, height: 0), animated: animated) 205 + self.rctScrollView?.scroll(toOffset: CGPoint(x: 0, y: offset), animated: animated) 223 206 } 224 207 225 208 func stopTimer() {