2021-02-19 16:28:05 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								//  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//     C a m e r a V i e w + C o d e S c a n n i n g . s w i f t  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//     C u v e n t  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//     C r e a t e d   b y   M a r c   R o u s a v y   o n   1 6 . 1 2 . 2 0 .  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//     C o p y r i g h t   ©   2 0 2 0   F a c e b o o k .   A l l   r i g h t s   r e s e r v e d .  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  AVFoundation  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  Foundation  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								extension  CameraView :  AVCaptureMetadataOutputObjectsDelegate  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  func  metadataOutput ( _ :  AVCaptureMetadataOutput ,  didOutput  metadataObjects :  [ AVMetadataObject ] ,  from  _ :  AVCaptureConnection )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-25 14:03:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  metadataObjects . isEmpty  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-19 16:28:05 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								      return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    let  objects  =  metadataObjects . map  {  ( object )  ->  [ String :  Any ] ?  in 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      guard  let  object  =  object  as ?  AVMetadataMachineReadableCodeObject  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nil 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      return  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " code " :  object . stringValue  as  Any , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " type " :  object . type . descriptor , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        " bounds " :  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          " minX " :  object . bounds . minX , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          " minY " :  object . bounds . minY , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          " maxX " :  object . bounds . maxX , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          " maxY " :  object . bounds . maxY , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          " width " :  object . bounds . width , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          " height " :  object . bounds . height , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    invokeOnCodeScanned ( codes :  objects ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  private  func  invokeOnCodeScanned ( codes :  [ [ String :  Any ] ? ] )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    guard  let  onCodeScanned  =  self . onCodeScanned  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      ReactLogger . log ( level :  . warning ,  message :  " onCodeScanned was invoked with no listeners. This means that the Camera is unnecessarily scanning codes. This indicates a memory leak. " ,  alsoLogToJS :  true ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    onCodeScanned ( [ " codes " :  codes ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}