twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
1.02k stars 293 forks source link

Avoid redundant reload when sheet is pulled down #21

Closed nozokada closed 3 years ago

nozokada commented 4 years ago

This is a fix for #11 where the video capture session restarts and the preview layer is reloaded because pulling down a sheet partially (not completely) fires viewWillDisappear and viewDidAppear.

I made the following changes:

  1. Added a nil check to viewDidAppear to avoid redundant preview layer instantiation
  2. Changed viewWillDisappear into viewDidDisappear so that the capture session won't stop until the sheet is completely pulled down and closed
alobaili commented 3 years ago

@twostraws Any chance you can review and merge this PR soon? I've tested it in iOS 14.1 and it's still working correctly.

Thank you for your time and efforts!

twostraws commented 3 years ago

I can merge this if you resolve the conflicts.

twostraws commented 3 years ago

Thank you!