ui: scanning QR code view

pull/689/head
Ryan Zhao 3 years ago
parent bf75055096
commit 734f29e212

@ -39,8 +39,7 @@ final class NewDMVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControll
}() }()
private lazy var scanQRCodeWrapperVC: ScanQRCodeWrapperVC = { private lazy var scanQRCodeWrapperVC: ScanQRCodeWrapperVC = {
let message = NSLocalizedString("vc_create_private_chat_scan_qr_code_explanation", comment: "") let result = ScanQRCodeWrapperVC(message: nil)
let result = ScanQRCodeWrapperVC(message: message)
result.delegate = self result.delegate = self
return result return result
}() }()

@ -2,14 +2,14 @@
final class ScanQRCodeWrapperVC : BaseVC { final class ScanQRCodeWrapperVC : BaseVC {
var delegate: (UIViewController & OWSQRScannerDelegate)? = nil var delegate: (UIViewController & OWSQRScannerDelegate)? = nil
var isPresentedModally = false var isPresentedModally = false
private let message: String private let message: String?
private let scanQRCodeVC = OWSQRCodeScanningViewController() private let scanQRCodeVC = OWSQRCodeScanningViewController()
// MARK: Settings // MARK: Settings
override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait }
// MARK: Lifecycle // MARK: Lifecycle
init(message: String) { init(message: String?) {
self.message = message self.message = message
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
} }
@ -36,25 +36,30 @@ final class ScanQRCodeWrapperVC : BaseVC {
scanQRCodeVCView.pin(.leading, to: .leading, of: view) scanQRCodeVCView.pin(.leading, to: .leading, of: view)
scanQRCodeVCView.pin(.trailing, to: .trailing, of: view) scanQRCodeVCView.pin(.trailing, to: .trailing, of: view)
scanQRCodeVCView.autoPinEdge(.top, to: .top, of: view) scanQRCodeVCView.autoPinEdge(.top, to: .top, of: view)
scanQRCodeVCView.autoPinToSquareAspectRatio() if let message = message {
// Set up bottom view scanQRCodeVCView.autoPinToSquareAspectRatio()
let bottomView = UIView() // Set up bottom view
view.addSubview(bottomView) let bottomView = UIView()
bottomView.pin(.top, to: .bottom, of: scanQRCodeVCView) view.addSubview(bottomView)
bottomView.pin(.leading, to: .leading, of: view) bottomView.pin(.top, to: .bottom, of: scanQRCodeVCView)
bottomView.pin(.trailing, to: .trailing, of: view) bottomView.pin(.leading, to: .leading, of: view)
bottomView.pin(.bottom, to: .bottom, of: view) bottomView.pin(.trailing, to: .trailing, of: view)
// Set up explanation label bottomView.pin(.bottom, to: .bottom, of: view)
let explanationLabel = UILabel() // Set up explanation label
explanationLabel.text = message let explanationLabel = UILabel()
explanationLabel.textColor = Colors.text explanationLabel.text = message
explanationLabel.font = .systemFont(ofSize: Values.smallFontSize) explanationLabel.textColor = Colors.text
explanationLabel.numberOfLines = 0 explanationLabel.font = .systemFont(ofSize: Values.smallFontSize)
explanationLabel.lineBreakMode = .byWordWrapping explanationLabel.numberOfLines = 0
explanationLabel.textAlignment = .center explanationLabel.lineBreakMode = .byWordWrapping
bottomView.addSubview(explanationLabel) explanationLabel.textAlignment = .center
explanationLabel.autoPinWidthToSuperview(withMargin: 32) bottomView.addSubview(explanationLabel)
explanationLabel.autoPinHeightToSuperview(withMargin: 32) explanationLabel.autoPinWidthToSuperview(withMargin: 32)
explanationLabel.autoPinHeightToSuperview(withMargin: 32)
} else {
scanQRCodeVCView.autoPinEdge(.bottom, to: .bottom, of: view)
}
// Title // Title
title = "Scan QR Code" title = "Scan QR Code"
} }

Loading…
Cancel
Save