Browse Source

theming color

Marino Faggiana 8 years ago
parent
commit
246c8b2002
3 changed files with 28 additions and 15 deletions
  1. 1 0
      iOSClient/AppDelegate.h
  2. 25 1
      iOSClient/AppDelegate.m
  3. 2 14
      iOSClient/Main/CCMain.m

+ 1 - 0
iOSClient/AppDelegate.h

@@ -162,6 +162,7 @@
 - (void)aspectNavigationControllerBar:(UINavigationBar *)nav encrypted:(BOOL)encrypted online:(BOOL)online hidden:(BOOL)hidden;
 - (void)aspectTabBar:(UITabBar *)tab hidden:(BOOL)hidden;
 - (void)plusButtonVisibile:(BOOL)visible;
+- (void)settingThemingColor:(NSString *)capabilitiesColor;
 
 // Operation Networking
 - (void)cancelAllOperations;

+ 25 - 1
iOSClient/AppDelegate.m

@@ -204,7 +204,7 @@
     self.player.delegate = self;
     
     // Theming Color
-    self.themingColor = [NCBrandColor sharedInstance].brand;
+    [self settingThemingColor:nil];
     
     // ico Image Cache
     self.icoImagesCache = [[NSMutableDictionary alloc] init];
@@ -988,6 +988,30 @@
     }
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== Theming Color =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)settingThemingColor:(NSString *)capabilitiesColor
+{
+    if (self.activeAccount.length > 0) {
+    
+        TableCapabilities *tableCapabilities = [CCCoreData getCapabilitesForAccount:self.activeAccount];
+    
+        if (k_option_use_themingColor && tableCapabilities.themingColor.length > 0) {
+        
+            self.themingColor = [CCGraphics colorFromHexString:tableCapabilities.themingColor];
+            
+            if (![capabilitiesColor isEqualToString:tableCapabilities.themingColor])
+                [[NSNotificationCenter defaultCenter] postNotificationName:@"changeTheming" object:nil];
+        
+        } else {
+        
+            self.themingColor = [NCBrandColor sharedInstance].brand;
+        }
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Media Player Control =====
 #pragma --------------------------------------------------------------------------------------------

+ 2 - 14
iOSClient/Main/CCMain.m

@@ -1189,21 +1189,9 @@
 
 - (void)getCapabilitiesOfServerSuccess:(OCCapabilities *)capabilities
 {
-    TableCapabilities *oldCapabilities = [CCCoreData getCapabilitesForAccount:app.activeAccount];
-    [CCCoreData addCapabilities:capabilities account:app.activeAccount];
-    
     // Change Theming color
-    if (k_option_use_themingColor) {
-        
-        app.themingColor = [CCGraphics colorFromHexString:capabilities.themingColor];
-        
-        if (![oldCapabilities.themingColor isEqualToString:capabilities.themingColor]) {
-         
-            [[NSNotificationCenter defaultCenter] postNotificationName:@"changeTheming" object:nil];
-
-            self.navigationController.navigationBar.barTintColor = app.themingColor;
-        }
-    }
+    [app settingThemingColor:capabilities.themingColor];
+    [CCCoreData addCapabilities:capabilities account:app.activeAccount];
     
     // Search bar if change version
     if (app.serverVersion != capabilities.versionMajor) {