Marino Faggiana 7 жил өмнө
parent
commit
ae61ff614d

+ 3 - 5
Share/ShareViewController.m

@@ -144,11 +144,9 @@
     UIBarButtonItem *rightButtonUpload, *leftButtonCancel;
 
     // Theming
-    tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilites];
-    if ([NCBrandOptions sharedInstance].use_themingColor && capabilities.themingColor.length > 0) {
-        UIColor *newColor = [CCGraphics colorFromHexString:capabilities.themingColor];
-        if (newColor)
-            [NCBrandColor sharedInstance].brand = newColor;
+    if ([NCBrandOptions sharedInstance].use_themingColor) {
+        tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilites];
+        [CCGraphics settingThemingColor:capabilities.themingColor themingColorElement:capabilities.themingColorElement themingColorText:capabilities.themingColorText];
     }
     self.navigationController.navigationBar.barTintColor = [NCBrandColor sharedInstance].brand;
     self.navigationController.navigationBar.tintColor = [NCBrandColor sharedInstance].brandText;

+ 10 - 44
iOSClient/AppDelegate.m

@@ -1028,56 +1028,22 @@
 
 - (void)settingThemingColorBrand
 {
-    UIColor *newColor, *newColorElement, *newColorText;
-    
-    if (self.activeAccount.length > 0) {
-    
-        tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilites];
+    if (self.activeAccount.length == 0 || self.maintenanceMode)
+        return;
     
-        if ([NCBrandOptions sharedInstance].use_themingColor) {
+    if ([NCBrandOptions sharedInstance].use_themingColor) {
         
-            // COLOR
-            if (capabilities.themingColor.length == 7) {
-                newColor = [CCGraphics colorFromHexString:capabilities.themingColor];
-            } else {
-                newColor = [NCBrandColor sharedInstance].customer;
-            }
-            
-            // COLOR TEXT
-            if (capabilities.themingColorText.length == 7) {
-                newColorText = [CCGraphics colorFromHexString:capabilities.themingColorText];
-            } else {
-                newColorText = [NCBrandColor sharedInstance].customerText;
-            }
-            
-            // COLOR ELEMENT
-            if (capabilities.themingColorElement.length == 7) {
-                newColorElement = [CCGraphics colorFromHexString:capabilities.themingColorElement];
-            } else {
-                if ([capabilities.themingColorText isEqualToString:@"#000000"])
-                    newColorElement = [UIColor blackColor];
-                else
-                    newColorElement = newColor;
-            }
-            
-        } else {
+        tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilites];
+
+        [CCGraphics settingThemingColor:capabilities.themingColor themingColorElement:capabilities.themingColorElement themingColorText:capabilities.themingColorText];
             
-            newColor = [NCBrandColor sharedInstance].customer;
-            newColorElement = [NCBrandColor sharedInstance].customer;
-            newColorText = [NCBrandColor sharedInstance].customerText;
-        }
-        
     } else {
-        
-        newColor = [NCBrandColor sharedInstance].customer;
-        newColorElement = [NCBrandColor sharedInstance].customer;
-        newColorText = [NCBrandColor sharedInstance].customerText;
+    
+        [NCBrandColor sharedInstance].brand = [NCBrandColor sharedInstance].customer;
+        [NCBrandColor sharedInstance].brandElement = [NCBrandColor sharedInstance].customer;
+        [NCBrandColor sharedInstance].brandText = [NCBrandColor sharedInstance].customerText;
     }
     
-    [NCBrandColor sharedInstance].brand = newColor;
-    [NCBrandColor sharedInstance].brandElement = newColorElement;
-    [NCBrandColor sharedInstance].brandText = newColorText;
-
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"changeTheming" object:nil];
 }
 

+ 2 - 0
iOSClient/Utility/CCGraphics.h

@@ -52,6 +52,8 @@
 
 + (void)addImageToTile:(NSString *)title colorTitle:(UIColor *)colorTitle imageTitle:(UIImage *)imageTitle navigationItem:(UINavigationItem *)navigationItem;
 
++ (void)settingThemingColor:(NSString *)themingColor themingColorElement:(NSString *)themingColorElement themingColorText:(NSString *)themingColorText;
+
 @end
 
 @interface CCAvatar : UIImageView

+ 35 - 0
iOSClient/Utility/CCGraphics.m

@@ -25,6 +25,7 @@
 
 #import "CCUtility.h"
 #import "NSString+TruncateToWidth.h"
+#import "NCBridgeSwift.h"
 
 @implementation CCGraphics
 
@@ -434,6 +435,40 @@ Color difference is determined by the following formula:
     [navView sizeToFit];
 }
 
++ (void)settingThemingColor:(NSString *)themingColor themingColorElement:(NSString *)themingColorElement themingColorText:(NSString *)themingColorText
+{
+    UIColor *newColor, *newColorElement, *newColorText;
+    
+    // COLOR
+    if (themingColor.length == 7) {
+        newColor = [CCGraphics colorFromHexString:themingColor];
+    } else {
+        newColor = [NCBrandColor sharedInstance].customer;
+    }
+            
+    // COLOR TEXT
+    if (themingColorText.length == 7) {
+        newColorText = [CCGraphics colorFromHexString:themingColorText];
+    } else {
+        newColorText = [NCBrandColor sharedInstance].customerText;
+    }
+            
+    // COLOR ELEMENT
+    if (themingColorElement.length == 7) {
+        newColorElement = [CCGraphics colorFromHexString:themingColorElement];
+    } else {
+        if ([themingColorText isEqualToString:@"#000000"])
+            newColorElement = [UIColor blackColor];
+        else
+            newColorElement = newColor;
+    }
+            
+    
+    [NCBrandColor sharedInstance].brand = newColor;
+    [NCBrandColor sharedInstance].brandElement = newColorElement;
+    [NCBrandColor sharedInstance].brandText = newColorText;
+}
+
 @end
 
 // ------------------------------------------------------------------------------------------------------