Browse Source

Add openLoginView on AppDelegate

Marino Faggiana 7 years ago
parent
commit
b21dc66d3f
2 changed files with 40 additions and 0 deletions
  1. 7 0
      iOSClient/AppDelegate.h
  2. 33 0
      iOSClient/AppDelegate.m

+ 7 - 0
iOSClient/AppDelegate.h

@@ -41,6 +41,8 @@
 #import "CCSettings.h"
 #import "CCFavorites.h"
 
+@class CCLoginWeb;
+
 @interface AppDelegate : UIResponder <UIApplicationDelegate, BKPasscodeLockScreenManagerDelegate, BKPasscodeViewControllerDelegate, LMMediaPlayerViewDelegate, TWMessageBarStyleSheet, CCNetworkingDelegate>
 
 // Timer Process
@@ -118,6 +120,8 @@
 @property (nonatomic, retain) CCSettings *activeSettings;
 @property (nonatomic, retain) CCActivity *activeActivity;
 @property (nonatomic, retain) CCTransfers *activeTransfers;
+@property (nonatomic, retain) CCLogin *activeLogin;
+@property (nonatomic, retain) CCLoginWeb *activeLoginWeb;
 
 @property (nonatomic, strong) NSMutableDictionary *listMainVC;
 @property (nonatomic, strong) NSMutableDictionary *listProgressMetadata;
@@ -128,6 +132,9 @@
 // Maintenance Mode
 @property BOOL maintenanceMode;
 
+// Login View
+- (void)openLoginView:(id)delegate loginType:(enumLoginType)enumLoginType;
+
 // Setting Active Account
 - (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activePassword:(NSString *)activePassword;
 

+ 33 - 0
iOSClient/AppDelegate.m

@@ -352,6 +352,39 @@
     });
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== Login =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)openLoginView:(id)delegate loginType:(enumLoginType)enumLoginType
+{
+    if ([NCBrandOptions sharedInstance].use_login_web) {
+        
+        if (!_activeLoginWeb.isViewLoaded || !_activeLoginWeb.view.window) {
+        
+            _activeLoginWeb = [CCLoginWeb new];
+            _activeLoginWeb.delegate = delegate;
+            _activeLoginWeb.loginType = enumLoginType;
+        
+            dispatch_async(dispatch_get_main_queue(), ^ {
+                [_activeLoginWeb presentModalWithDefaultTheme:delegate];
+            });
+        }
+        
+    } else {
+        
+        if (!_activeLoginWeb.isViewLoaded || !_activeLoginWeb.view.window) {
+
+            _activeLogin = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"CCLoginNextcloud"];
+            _activeLogin.delegate = delegate;
+            _activeLogin.loginType = enumLoginType;
+        
+            [self.window makeKeyAndVisible];
+            [self.window.rootViewController presentViewController:_activeLogin animated:YES completion:nil];
+        }
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Process Auto Upload < k_timerProcess seconds > =====
 #pragma --------------------------------------------------------------------------------------------