@@ -30,12 +30,11 @@ import OneTimePassword
30
30
class TokenScannerViewController : UIViewController , QRScannerDelegate {
31
31
private let scanner = QRScanner ( )
32
32
private let videoLayer = AVCaptureVideoPreviewLayer ( )
33
- private let messageView = UIButton ( )
34
33
35
34
private var viewModel : TokenScanner . ViewModel
36
35
private let dispatchAction : ( TokenScanner . Action ) -> Void
37
36
38
- fileprivate let permissionLabel : UILabel = {
37
+ private let permissionLabel : UILabel = {
39
38
let linkTitle = " Go to Settings → "
40
39
let message = " To add a new token via QR code, Authenticator needs permission to access the camera. \n \( linkTitle) "
41
40
let paragraphStyle = NSMutableParagraphStyle ( )
@@ -56,6 +55,18 @@ class TokenScannerViewController: UIViewController, QRScannerDelegate {
56
55
return label
57
56
} ( )
58
57
58
+ private lazy var permissionButton : UIButton = {
59
+ let button = UIButton ( frame: UIScreen . main. bounds)
60
+ button. backgroundColor = . otpBackgroundColor
61
+ button. addTarget ( self , action: #selector( TokenScannerViewController . editPermissions) , for: . touchUpInside)
62
+
63
+ self . permissionLabel. frame = button. bounds. insetBy ( dx: 35 , dy: 35 )
64
+ self . permissionLabel. autoresizingMask = [ . flexibleWidth, . flexibleHeight]
65
+ button. addSubview ( self . permissionLabel)
66
+
67
+ return button
68
+ } ( )
69
+
59
70
// MARK: Initialization
60
71
61
72
init ( viewModel: TokenScanner . ViewModel , dispatchAction: @escaping ( TokenScanner . Action ) -> Void ) {
@@ -95,16 +106,10 @@ class TokenScannerViewController: UIViewController, QRScannerDelegate {
95
106
videoLayer. frame = view. layer. bounds
96
107
view. layer. addSublayer ( videoLayer)
97
108
98
- messageView. backgroundColor = UIColor . otpBackgroundColor
99
- messageView. autoresizingMask = [ . flexibleWidth, . flexibleHeight]
100
- messageView. frame = view. bounds
101
- messageView. isHidden = true
102
- messageView. addTarget ( self , action: #selector( TokenScannerViewController . editPermissions) , for: . touchUpInside)
103
- view. addSubview ( messageView)
104
-
105
- permissionLabel. autoresizingMask = [ . flexibleWidth, . flexibleHeight]
106
- permissionLabel. frame = messageView. bounds. insetBy ( dx: 35 , dy: 35 )
107
- messageView. addSubview ( permissionLabel)
109
+ permissionButton. frame = view. bounds
110
+ permissionButton. autoresizingMask = [ . flexibleWidth, . flexibleHeight]
111
+ permissionButton. isHidden = true
112
+ view. addSubview ( permissionButton)
108
113
109
114
if CommandLine . isDemo {
110
115
// If this is a demo, display an image in place of the AVCaptureVideoPreviewLayer.
@@ -150,7 +155,7 @@ class TokenScannerViewController: UIViewController, QRScannerDelegate {
150
155
}
151
156
152
157
private func showMissingAccessMessage( ) {
153
- messageView . isHidden = false
158
+ permissionButton . isHidden = false
154
159
}
155
160
156
161
override func viewWillDisappear( _ animated: Bool ) {
0 commit comments