Browse Source

buttonPlus procedure

Marino Faggiana 8 years ago
parent
commit
7277c79e76

+ 3 - 0
iOSClient/AppDelegate.h

@@ -175,6 +175,9 @@
 - (void)updateApplicationIconBadgeNumber;
 - (BOOL)handleShortCutItem:(UIApplicationShortcutItem *)shortcutItem;
 
+- (BOOL)isVisiblePlusButton;
+- (BOOL)plusButton:(BOOL)visible;
+
 // Operation Networking
 - (void)cancelAllOperations;
 - (void)addNetworkingOperationQueue:(NSOperationQueue *)netQueue delegate:(id)delegate metadataNet:(CCMetadataNet *)metadataNet;

+ 84 - 65
iOSClient/AppDelegate.m

@@ -217,14 +217,15 @@
     [self.window setTintColor:COLOR_BRAND];
     
     UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
-    UITabBarController *tabBarController = [splitViewController.viewControllers firstObject];
+    //UITabBarController *tabBarController = [splitViewController.viewControllers firstObject];
     UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
 
     navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
     splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
     
     // Settings TabBar
-    [self createTabBarController:tabBarController];
+    [self createTabBarController];
+    [self plusButton:true];
     
     // passcode
     [[BKPasscodeLockScreenManager sharedManager] setDelegate:self];
@@ -715,6 +716,82 @@
     return iconImage;
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== TabBarController =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)createTabBarController
+{
+    UITabBarItem *item;
+    
+    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
+    UITabBarController *tabBarController = [splitViewController.viewControllers firstObject];
+    
+    [CCAspect aspectTabBar:tabBarController.tabBar hidden:NO];
+    
+    // File
+    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexFile];
+    [item setTitle:NSLocalizedString(@"_home_", nil)];
+    item.image = [UIImage imageNamed:image_tabBarFile];
+    item.selectedImage = [UIImage imageNamed:image_tabBarFile];
+    
+    // Favorite - Local
+    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexFavorite];
+    if (app.isLocalStorage) {
+        [item setTitle:NSLocalizedString(@"_local_storage_", nil)];
+        item.image = [UIImage imageNamed:image_tabBarLocal];
+        item.selectedImage = [UIImage imageNamed:image_tabBarLocal];
+    } else {
+        [item setTitle:NSLocalizedString(@"_favorites_", nil)];
+        item.image = [UIImage imageNamed:image_tabBarFavorite];
+        item.selectedImage = [UIImage imageNamed:image_tabBarFavorite];
+    }
+    
+    // Photos
+    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexPhotos];
+    [item setTitle:NSLocalizedString(@"_photo_camera_", nil)];
+    item.image = [UIImage imageNamed:image_tabBarPhotos];
+    item.selectedImage = [UIImage imageNamed:image_tabBarPhotos];
+    
+    // Settings
+    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexSettings];
+    [item setTitle:NSLocalizedString(@"_settings_", nil)];
+    item.image = [UIImage imageNamed:image_tabBarSettings];
+    item.selectedImage = [UIImage imageNamed:image_tabBarSettings];
+}
+
+- (BOOL)plusButton:(BOOL)visible
+{
+    UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
+    UITabBarController *tabBarController = [splitViewController.viewControllers firstObject];
+    
+    UIButton *buttonPlus = [tabBarController.view viewWithTag:99];
+    if (buttonPlus)
+            [buttonPlus removeFromSuperview];
+    
+    if (visible) {
+        UIImage *buttonImage = [UIImage imageNamed:@"Plus"];
+        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
+        button.tag = 99;
+        button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
+        [button setBackgroundImage:buttonImage forState:UIControlStateNormal];
+        
+        CGFloat heightDifference = buttonImage.size.height - tabBarController.tabBar.frame.size.height;
+        if (heightDifference < 0)
+            button.center = tabBarController.tabBar.center;
+        else {
+            CGPoint center = tabBarController.tabBar.center;
+            center.y = center.y - 24;//- heightDifference/2.0;
+            button.center = center;
+        }
+        
+        [tabBarController.view addSubview:button];
+    }
+    
+    if (buttonPlus) return true;
+    else return false;
+}
+
 - (void)updateApplicationIconBadgeNumber
 {
     // Core Data
@@ -735,10 +812,10 @@
 #ifdef CC
         
         /*** DROPBOX ***/
-
+        
         if ([app.typeCloud isEqualToString:typeCloudDropbox])
             if (((DBnetworking *)operation).isExecuting == NO) _queueNunDownload++;
-
+        
 #endif
     }
     
@@ -756,7 +833,7 @@
         
         if ([app.typeCloud isEqualToString:typeCloudDropbox])
             if (((DBnetworking *)operation).isExecuting == NO) _queueNumDownloadWWan++;
-
+        
 #endif
     }
     
@@ -792,8 +869,8 @@
         if ([app.typeCloud isEqualToString:typeCloudDropbox])
             if (((DBnetworking *)operation).isExecuting == NO) _queueNumUploadWWan++;
 #endif
-     }
-
+    }
+    
     // Total
     NSUInteger total = _queueNunDownload + _queueNumDownloadWWan + _queueNumUpload + _queueNumUploadWWan + [CCCoreData countTableAutomaticUploadForAccount:self.activeAccount selector:nil];
     
@@ -814,64 +891,6 @@
     }
 }
 
-- (void)createTabBarController:(UITabBarController *)tabBarController
-{
-    UITabBarItem *item;
-    
-    [CCAspect aspectTabBar:tabBarController.tabBar hidden:NO];
-    
-    // File
-    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexFile];
-    [item setTitle:NSLocalizedString(@"_home_", nil)];
-    item.image = [UIImage imageNamed:image_tabBarFile];
-    item.selectedImage = [UIImage imageNamed:image_tabBarFile];
-    
-    // Favorite - Local
-    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexFavorite];
-    if (app.isLocalStorage) {
-        [item setTitle:NSLocalizedString(@"_local_storage_", nil)];
-        item.image = [UIImage imageNamed:image_tabBarLocal];
-        item.selectedImage = [UIImage imageNamed:image_tabBarLocal];
-    } else {
-        [item setTitle:NSLocalizedString(@"_favorites_", nil)];
-        item.image = [UIImage imageNamed:image_tabBarFavorite];
-        item.selectedImage = [UIImage imageNamed:image_tabBarFavorite];
-    }
-    
-    // Photos
-    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexPhotos];
-    [item setTitle:NSLocalizedString(@"_photo_camera_", nil)];
-    item.image = [UIImage imageNamed:image_tabBarPhotos];
-    item.selectedImage = [UIImage imageNamed:image_tabBarPhotos];
-    
-    // Settings
-    item = [tabBarController.tabBar.items objectAtIndex:TabBarApplicationIndexSettings];
-    [item setTitle:NSLocalizedString(@"_settings_", nil)];
-    item.image = [UIImage imageNamed:image_tabBarSettings];
-    item.selectedImage = [UIImage imageNamed:image_tabBarSettings];
-    
-    /*
-    UIImage *buttonImage = [UIImage imageNamed:image_brandNavigationController];
-    
-    UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
-    button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height);
-    [button setBackgroundImage:buttonImage forState:UIControlStateNormal];
-    //[button setBackgroundImage:highlightImage forState:UIControlStateHighlighted];
-    
-    CGFloat heightDifference = buttonImage.size.height - tabBarController.tabBar.frame.size.height;
-    if (heightDifference < 0)
-        button.center = tabBarController.tabBar.center;
-    else
-    {
-        CGPoint center = tabBarController.tabBar.center;
-        center.y = center.y - heightDifference/2.0;
-        button.center = center;
-    }
-    
-    [tabBarController.view addSubview:button];
-    */ 
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Media Player Control =====
 #pragma --------------------------------------------------------------------------------------------

+ 21 - 0
iOSClient/Images.xcassets/Plus.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "Plus@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/Plus.imageset/Plus@2x.png


+ 2 - 0
iOSClient/Main/CCDetail.m

@@ -95,6 +95,8 @@
         self.tabBarController.tabBar.hidden = YES;
         self.tabBarController.tabBar.translucent = YES;
     }
+    
+    [app plusButton:false];
 }
 
 - (void)viewDidAppear:(BOOL)animated

+ 3 - 0
iOSClient/Main/CCMain.m

@@ -199,6 +199,9 @@
     [self createReSelectMenu];
     if (_isSelectedMode) [self setUINavigationBarSeleziona];
     else [self setUINavigationBarDefault];
+    
+    // Plus Button
+    [app plusButton:true];
 }
 
 // E' arrivato

+ 6 - 0
iOSClient/Main/CCSplit.m

@@ -70,8 +70,11 @@
     }
 }
 
+
 - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
 {
+    BOOL buttonPlus = [app plusButton:false];
+    
     [coordinator animateAlongsideTransition:nil completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
         
         if (self.view.frame.size.width == ([[UIScreen mainScreen] bounds].size.width*([[UIScreen mainScreen] bounds].size.width<[[UIScreen mainScreen] bounds].size.height))+([[UIScreen mainScreen] bounds].size.height*([[UIScreen mainScreen] bounds].size.width>[[UIScreen mainScreen] bounds].size.height))) {
@@ -82,6 +85,9 @@
             
             // Landscape
         }
+        
+        if (buttonPlus)
+            [app plusButton:true];
     }];
     
     [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];