Browse Source

login flow

Marino Faggiana 7 years ago
parent
commit
e87058e54c

+ 1 - 1
iOSClient/Login/CCLogin.h

@@ -63,7 +63,7 @@ typedef enum {
 @property (nonatomic, weak) IBOutlet UIButton *login;
 @property (nonatomic, weak) IBOutlet UIButton *annulla;
 @property (nonatomic, weak) IBOutlet UIButton *toggleVisiblePassword;
-@property (nonatomic, weak) IBOutlet UIButton *traditionalLogin;
+@property (nonatomic, weak) IBOutlet UIButton *loginTypeView;
 
 
 @property enumLoginType loginType;

+ 31 - 16
iOSClient/Login/CCLogin.m

@@ -58,11 +58,13 @@
         
             // Portrait
             self.bottomLabel.hidden = NO;
+            self.loginTypeView.hidden = NO;
         
         } else {
         
             // Landscape
             self.bottomLabel.hidden = YES;
+            self.loginTypeView.hidden = YES;
 
         }
     }
@@ -131,8 +133,8 @@
     [self.annulla setTitle:NSLocalizedString(@"_cancel_", nil) forState:UIControlStateNormal];
     [self.login setTitle:NSLocalizedString(@"_login_", nil) forState:UIControlStateNormal];
     
-    [self.traditionalLogin setTitle:NSLocalizedString(@"_traditional_login_", nil) forState:UIControlStateNormal];
-    [self.traditionalLogin setTitleColor:[NCBrandColor sharedInstance].customer forState:UIControlStateNormal];
+    [self.loginTypeView setTitle:NSLocalizedString(@"_traditional_login_", nil) forState:UIControlStateNormal];
+    [self.loginTypeView setTitleColor:[NCBrandColor sharedInstance].customer forState:UIControlStateNormal];
 }
 
 - (void)viewWillAppear:(BOOL)animated
@@ -240,22 +242,23 @@
                         
                     } else {
                         
-                        _traditionalLogin.hidden = true;
-
                         _imageUser.hidden = NO;
                         _user.hidden = NO;
                         _imagePassword.hidden = NO;
                         _password.hidden = NO;
+                        
+                        [self.loginTypeView setTitle:NSLocalizedString(@"_web_login_", nil) forState:UIControlStateNormal];
                     }
 
                 } else {
                     
-                    appDelegate.activeLoginWeb = [CCLoginWeb new];
-                    appDelegate.activeLoginWeb.loginType = _loginType;
-                    appDelegate.activeLoginWeb.delegate = (id<CCLoginDelegateWeb>)self.delegate;
-                    appDelegate.activeLoginWeb.urlBase = urlBase;
-                    
                     [self dismissViewControllerAnimated:YES completion: ^{
+                        
+                        appDelegate.activeLoginWeb = [CCLoginWeb new];
+                        appDelegate.activeLoginWeb.loginType = _loginType;
+                        appDelegate.activeLoginWeb.delegate = (id<CCLoginDelegateWeb>)self.delegate;
+                        appDelegate.activeLoginWeb.urlBase = urlBase;
+                    
                         [appDelegate.activeLoginWeb presentModalWithDefaultTheme:(UIViewController *)self.delegate];
                     }];
                 }
@@ -523,14 +526,26 @@
     self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName: [UIColor darkGrayColor]};
 }
 
-- (IBAction)handleTraditionalLogin:(id)sender
+- (IBAction)handleLoginTypeView:(id)sender
 {
-    _traditionalLogin.hidden = true;
-    
-    _imageUser.hidden = NO;
-    _user.hidden = NO;
-    _imagePassword.hidden = NO;
-    _password.hidden = NO;
+    if (_user.hidden && _password.hidden) {
+        
+        _imageUser.hidden = NO;
+        _user.hidden = NO;
+        _imagePassword.hidden = NO;
+        _password.hidden = NO;
+        
+        [self.loginTypeView setTitle:NSLocalizedString(@"_web_login_", nil) forState:UIControlStateNormal];
+        
+    } else {
+        
+        _imageUser.hidden = YES;
+        _user.hidden = YES;
+        _imagePassword.hidden = YES;
+        _password.hidden = YES;
+        
+        [self.loginTypeView setTitle:NSLocalizedString(@"_traditional_login_", nil) forState:UIControlStateNormal];
+    }
 }
 
 @end

+ 4 - 4
iOSClient/Login/CCLogin.storyboard

@@ -131,14 +131,14 @@
                                 <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="owR-PS-F32" userLabel="traditionalLogin">
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="owR-PS-F32" userLabel="loginTypeView">
                                 <rect key="frame" x="0.0" y="573" width="375" height="30"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="30" id="PaU-7J-gkn"/>
                                 </constraints>
-                                <state key="normal" title="Traditional Login"/>
+                                <state key="normal" title="Login type view"/>
                                 <connections>
-                                    <action selector="handleTraditionalLogin:" destination="yj9-jo-WIn" eventType="touchUpInside" id="WNJ-Uh-C4z"/>
+                                    <action selector="handleLoginTypeView:" destination="yj9-jo-WIn" eventType="touchUpInside" id="V2I-Nr-nOu"/>
                                 </connections>
                             </button>
                         </subviews>
@@ -194,9 +194,9 @@
                         <outlet property="imageUser" destination="4OF-5u-Hd1" id="MJa-4H-w7m"/>
                         <outlet property="loadingBaseUrl" destination="oF7-f3-D2I" id="uel-s3-cAX"/>
                         <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="toggleVisiblePassword" destination="fhk-o9-J0l" id="aco-hl-Ban"/>
-                        <outlet property="traditionalLogin" destination="owR-PS-F32" id="Q2a-nJ-0hu"/>
                         <outlet property="user" destination="1Gf-Bw-Nim" id="BUW-sz-I3f"/>
                     </connections>
                 </viewController>

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -221,6 +221,7 @@
 "_error_multidomain_"           = "Address not allowed, only the following domains are valid:";
 "_account_already_exists_"      = "The account %@ already exists";
 "_traditional_login_"           = "Revert to old login method";
+"_web_login_"                   = "Revert to web login method";
 
 // Favorite