Selaa lähdekoodia

fix color login detect

marinofaggiana 5 vuotta sitten
vanhempi
commit
6b26643ba3
1 muutettua tiedostoa jossa 25 lisäystä ja 14 poistoa
  1. 25 14
      iOSClient/Login/CCLogin.m

+ 25 - 14
iOSClient/Login/CCLogin.m

@@ -31,6 +31,7 @@
 {
     AppDelegate *appDelegate;
     UIView *rootView;
+    UIColor *textColor;
 }
 @end
 
@@ -57,18 +58,28 @@
 
     // Background color
     self.view.backgroundColor = NCBrandColor.sharedInstance.customer;
+    // Text Color
+    BOOL isTooLight = NCBrandColor.sharedInstance.customer.isTooLight;
+    BOOL isTooDark = NCBrandColor.sharedInstance.customer.isTooDark;
+    if (isTooLight) {
+        textColor = [UIColor blackColor];
+    } else if (isTooDark) {
+        textColor = [UIColor whiteColor];
+    } else {
+        textColor = [UIColor whiteColor];
+    }
     
     // Image Brand
     self.imageBrand.image = [UIImage imageNamed:@"logo"];
     
     // Annulla
     [self.annulla setTitle:NSLocalizedString(@"_cancel_", nil) forState:UIControlStateNormal];
-    self.annulla.tintColor = NCBrandColor.sharedInstance.customerText;
+    self.annulla.tintColor = textColor;
     
     // Base URL
-    _imageBaseUrl.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginURL"] multiplier:2 color:NCBrandColor.sharedInstance.customerText];
-    _baseUrl.textColor = NCBrandColor.sharedInstance.customerText;
-    _baseUrl.tintColor = NCBrandColor.sharedInstance.customerText;
+    _imageBaseUrl.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginURL"] multiplier:2 color:textColor];
+    _baseUrl.textColor = textColor;
+    _baseUrl.tintColor = textColor;
     _baseUrl.placeholder = NSLocalizedString(@"_login_url_", nil);
     UILabel *baseUrlPlaceholder = object_getIvar(_baseUrl, ivar);
     baseUrlPlaceholder.textColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.7];
@@ -76,9 +87,9 @@
     [self.baseUrl setDelegate:self];
     
     // User
-    _imageUser.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginUser"] multiplier:2 color:NCBrandColor.sharedInstance.customerText];
-    _user.textColor = NCBrandColor.sharedInstance.customerText;
-    _user.tintColor = NCBrandColor.sharedInstance.customerText;
+    _imageUser.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginUser"] multiplier:2 color:textColor];
+    _user.textColor = textColor;
+    _user.tintColor = textColor;
     _user.placeholder = NSLocalizedString(@"_username_", nil);
     UILabel *userPlaceholder = object_getIvar(_user, ivar);
     userPlaceholder.textColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.7];
@@ -87,9 +98,9 @@
     [self.user setDelegate:self];
 
     // Password
-    _imagePassword.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginPassword"] multiplier:2 color:NCBrandColor.sharedInstance.customerText];
-    _password.textColor = NCBrandColor.sharedInstance.customerText;
-    _password.tintColor = NCBrandColor.sharedInstance.customerText;
+    _imagePassword.image = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"loginPassword"] multiplier:2 color:textColor];
+    _password.textColor = textColor;
+    _password.tintColor = textColor;
     _password.placeholder = NSLocalizedString(@"_password_", nil);
     UILabel *passwordPlaceholder = object_getIvar(_password, ivar);
     passwordPlaceholder.textColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.7];
@@ -100,7 +111,7 @@
     
     // Login
     [self.login setTitle:NSLocalizedString(@"_login_", nil) forState:UIControlStateNormal] ;
-    self.login.backgroundColor = NCBrandColor.sharedInstance.customerText;
+    self.login.backgroundColor = textColor;
     self.login.tintColor = [UIColor blackColor];
     self.login.layer.cornerRadius = 20;
     self.login.clipsToBounds = YES;
@@ -263,7 +274,7 @@
 {
     if (textField == self.password) {
         self.toggleVisiblePassword.hidden = NO;
-        self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName:NCBrandColor.sharedInstance.customerText};
+        self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName:textColor};
     }
 }
 
@@ -271,7 +282,7 @@
 {
     if (textField == self.password) {
         self.toggleVisiblePassword.hidden = YES;
-        self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName:NCBrandColor.sharedInstance.customerText};
+        self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName:textColor};
     }
 }
 
@@ -422,7 +433,7 @@
     
     self.password.text = @"";
     self.password.text = currentPassword;
-    self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName: NCBrandColor.sharedInstance.customerText};
+    self.password.defaultTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName: textColor};
 }
 
 - (IBAction)handleLoginTypeView:(id)sender