2019-09-26 03:32:47 +02:00
# import "ScanQRCodeVC.h"
2019-08-23 07:12:08 +02:00
# import "Session-Swift.h"
NS_ASSUME _NONNULL _BEGIN
2019-09-26 03:32:47 +02:00
@ interface ScanQRCodeVC ( )
2019-08-23 07:12:08 +02:00
@ property ( nonatomic ) OWSQRCodeScanningViewController * qrCodeScanningVC ;
@ end
2019-09-26 03:32:47 +02:00
@ implementation ScanQRCodeVC
2019-08-23 07:12:08 +02:00
- ( UIInterfaceOrientationMask ) supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait ; }
- ( void ) viewDidLoad
{
[ super viewDidLoad ] ;
// Background color
self . view . backgroundColor = Theme . backgroundColor ;
// QR code scanning VC
self . qrCodeScanningVC = [ OWSQRCodeScanningViewController new ] ;
self . qrCodeScanningVC . scanDelegate = self . delegate ;
[ self . view addSubview : self . qrCodeScanningVC . view ] ;
[ self . qrCodeScanningVC . view autoPinEdgeToSuperviewEdge : ALEdgeLeading ] ;
[ self . qrCodeScanningVC . view autoPinEdgeToSuperviewEdge : ALEdgeTrailing ] ;
[ self . qrCodeScanningVC . view autoPinToTopLayoutGuideOfViewController : self withInset : 0.0 ] ;
[ self . qrCodeScanningVC . view autoPinToSquareAspectRatio ] ;
// Explanation label
UILabel * explanationLabel = [ UILabel new ] ;
explanationLabel . text = NSLocalizedString ( @ "Scan the QR code of the person you'd like to securely message. They can find their QR code by going into Loki Messenger's in-app settings and clicking \" Show QR Code \ "." , @ "" ) ;
explanationLabel . textColor = Theme . primaryColor ;
explanationLabel . font = UIFont . ows_dynamicTypeSubheadlineClampedFont ;
explanationLabel . numberOfLines = 0 ;
explanationLabel . lineBreakMode = NSLineBreakByWordWrapping ;
explanationLabel . textAlignment = NSTextAlignmentCenter ;
// Bottom view
UIView * bottomView = [ UIView new ] ;
[ self . view addSubview : bottomView ] ;
[ bottomView autoPinEdge : ALEdgeTop toEdge : ALEdgeBottom ofView : self . qrCodeScanningVC . view ] ;
[ bottomView autoPinEdgeToSuperviewEdge : ALEdgeLeading ] ;
[ bottomView autoPinEdgeToSuperviewEdge : ALEdgeTrailing ] ;
[ bottomView autoPinEdgeToSuperviewEdge : ALEdgeBottom ] ;
[ bottomView addSubview : explanationLabel ] ;
[ explanationLabel autoPinWidthToSuperviewWithMargin : 32 ] ;
[ explanationLabel autoPinHeightToSuperviewWithMargin : 32 ] ;
// Title
self . title = NSLocalizedString ( @ "Scan QR Code" , "" ) ;
}
- ( void ) viewDidAppear : ( BOOL ) animated
{
[ super viewDidAppear : animated ] ;
[ UIDevice . currentDevice ows_setOrientation : UIInterfaceOrientationPortrait ] ;
dispatch_async ( dispatch_get _main _queue ( ) , ^ {
[ self . qrCodeScanningVC startCapture ] ;
} ) ;
}
@ end
NS_ASSUME _NONNULL _END