marinofaggiana 6 жил өмнө
parent
commit
d902f42459

+ 3 - 0
iOSClient/Login/CCLogin.h

@@ -28,6 +28,7 @@
 #import "OCNetworking.h"
 
 @class CCLoginWeb;
+@class NCLoginQRCode;
 
 @protocol CCLoginDelegate <NSObject>
 
@@ -56,6 +57,8 @@
 @property (nonatomic, weak) IBOutlet UIButton *toggleVisiblePassword;
 @property (nonatomic, weak) IBOutlet UIButton *loginTypeView;
 
+@property (nonatomic, weak) IBOutlet UIButton *qrCode;
+
 @property NSInteger loginType;
 
 @end

+ 7 - 0
iOSClient/Login/CCLogin.m

@@ -398,6 +398,13 @@
     }
 }
 
+- (IBAction)handleQRCode:(id)sender
+{
+    NCLoginQRCode *qrCode = [[NCLoginQRCode alloc] initWithDelegate:self];
+    
+    [qrCode scan];
+}
+
 -(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
 {
     // The pinnning check

+ 10 - 0
iOSClient/Login/CCLogin.storyboard

@@ -124,12 +124,20 @@
                                     <action selector="handleAnnulla:" destination="yj9-jo-WIn" eventType="touchUpInside" id="XyT-Gg-W9A"/>
                                 </connections>
                             </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6tp-bh-Z9k" userLabel="QRCode">
+                                <rect key="frame" x="194.66666666666666" y="440.66666666666669" width="25" height="25"/>
+                                <state key="normal" image="loginURL"/>
+                                <connections>
+                                    <action selector="handleQRCode:" destination="yj9-jo-WIn" eventType="touchUpInside" id="IW6-a9-880"/>
+                                </connections>
+                            </button>
                         </subviews>
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <constraints>
                             <constraint firstItem="8lf-3Y-f5R" firstAttribute="trailing" secondItem="Kfq-Bg-a0E" secondAttribute="trailing" constant="13" id="3Rl-VS-3Op"/>
                             <constraint firstItem="1Gf-Bw-Nim" firstAttribute="leading" secondItem="4OF-5u-Hd1" secondAttribute="trailing" constant="10" id="4CC-7B-dkI"/>
                             <constraint firstItem="HQd-pF-3cE" firstAttribute="top" secondItem="8lf-3Y-f5R" secondAttribute="top" constant="264" id="9hf-b4-BDZ"/>
+                            <constraint firstItem="6tp-bh-Z9k" firstAttribute="centerX" secondItem="8lf-3Y-f5R" secondAttribute="centerX" id="Apc-1U-CwU"/>
                             <constraint firstItem="BpI-xK-1SU" firstAttribute="top" secondItem="8lf-3Y-f5R" secondAttribute="top" id="Fep-pw-QEQ"/>
                             <constraint firstItem="fhk-o9-J0l" firstAttribute="leading" secondItem="jU7-Iw-XfU" secondAttribute="trailing" constant="10" id="FmL-e8-YKk"/>
                             <constraint firstItem="8lf-3Y-f5R" firstAttribute="centerX" secondItem="BpI-xK-1SU" secondAttribute="centerX" id="IxG-UI-0vq"/>
@@ -143,6 +151,7 @@
                             <constraint firstItem="7q8-rl-x2M" firstAttribute="leading" secondItem="8lf-3Y-f5R" secondAttribute="leading" constant="10" id="bf8-6l-dfs"/>
                             <constraint firstItem="4OF-5u-Hd1" firstAttribute="leading" secondItem="8lf-3Y-f5R" secondAttribute="leading" constant="10" id="e7p-K8-Tt3"/>
                             <constraint firstItem="s9o-RX-XeS" firstAttribute="leading" secondItem="8lf-3Y-f5R" secondAttribute="leading" constant="10" id="gYr-20-hOQ"/>
+                            <constraint firstItem="6tp-bh-Z9k" firstAttribute="centerY" secondItem="8lf-3Y-f5R" secondAttribute="centerY" id="iV8-CJ-R2u"/>
                             <constraint firstItem="7q8-rl-x2M" firstAttribute="centerY" secondItem="jU7-Iw-XfU" secondAttribute="centerY" id="jhu-Tk-ifA"/>
                             <constraint firstItem="8lf-3Y-f5R" firstAttribute="bottom" secondItem="owR-PS-F32" secondAttribute="bottom" id="kxd-eg-KfO"/>
                             <constraint firstItem="szn-G7-5sK" firstAttribute="top" secondItem="BpI-xK-1SU" secondAttribute="bottom" id="lWz-Yy-NCO"/>
@@ -169,6 +178,7 @@
                         <outlet property="login" destination="HQd-pF-3cE" id="dpI-ns-Ivh"/>
                         <outlet property="loginTypeView" destination="owR-PS-F32" id="Rdw-tW-R0G"/>
                         <outlet property="password" destination="jU7-Iw-XfU" id="OWi-V0-Eij"/>
+                        <outlet property="qrCode" destination="6tp-bh-Z9k" id="Tw3-op-BgR"/>
                         <outlet property="toggleVisiblePassword" destination="fhk-o9-J0l" id="aco-hl-Ban"/>
                         <outlet property="user" destination="1Gf-Bw-Nim" id="BUW-sz-I3f"/>
                     </connections>

+ 6 - 4
iOSClient/Login/NCLoginQRCode.swift

@@ -21,11 +21,10 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-
 import Foundation
 import QRCodeReader
 
-class NCLoginQRCode: QRCodeReaderViewControllerDelegate {
+class NCLoginQRCode: NSObject, QRCodeReaderViewControllerDelegate {
     
     lazy var reader: QRCodeReader = QRCodeReader()
     weak var delegate: UIViewController?
@@ -44,12 +43,15 @@ class NCLoginQRCode: QRCodeReaderViewControllerDelegate {
         return QRCodeReaderViewController(builder: builder)
     }()
 
+    override init() {
+        
+    }
     
-    public init(delegate: UIViewController) {
+    @objc public init(delegate: UIViewController) {
         self.delegate = delegate
     }
     
-    func scanInModalAction() {
+    @objc func scan() {
         guard checkScanPermissions() else { return }
         
         readerVC.modalPresentationStyle = .formSheet