Update ScanQRCodeWrapperVC for multi device QR code scanning

This commit is contained in:
Niels Andriesse 2019-11-19 14:41:56 +11:00
parent 4afeba866b
commit ade1fc3239
2 changed files with 17 additions and 2 deletions

View file

@ -81,7 +81,8 @@ final class NewConversationVC : OWSViewController, OWSQRScannerDelegate {
@objc private func scanQRCode() {
ows_ask(forCameraPermissions: { [weak self] hasCameraAccess in
if hasCameraAccess {
let scanQRCodeWrapperVC = ScanQRCodeWrapperVC()
let message = 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\".", comment: "")
let scanQRCodeWrapperVC = ScanQRCodeWrapperVC(message: message)
scanQRCodeWrapperVC.delegate = self
self?.navigationController!.pushViewController(scanQRCodeWrapperVC, animated: true)
} else {

View file

@ -1,12 +1,26 @@
final class ScanQRCodeWrapperVC : UIViewController {
var delegate: (UIViewController & OWSQRScannerDelegate)? = nil
private let message: String
private let scanQRCodeVC = OWSQRCodeScanningViewController()
// MARK: Settings
override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .portrait }
// MARK: Lifecycle
init(message: String) {
self.message = message
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
preconditionFailure("Use init(title:) instead.")
}
override init(nibName: String?, bundle: Bundle?) {
preconditionFailure("Use init(title:) instead.")
}
override func viewDidLoad() {
// Background color
view.backgroundColor = Theme.backgroundColor
@ -27,7 +41,7 @@ final class ScanQRCodeWrapperVC : UIViewController {
bottomView.pin(.bottom, to: .bottom, of: view)
// Explanation label
let explanationLabel = UILabel()
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\".", comment: "")
explanationLabel.text = message
explanationLabel.textColor = Theme.primaryColor
explanationLabel.font = .ows_dynamicTypeSubheadlineClamped
explanationLabel.numberOfLines = 0