Quellcode durchsuchen

continue library actionsheet

Marino Faggiana vor 8 Jahren
Ursprung
Commit
6b11443089

+ 1 - 1
Libraries external/AHKActionSheet/AHKActionSheet.h

@@ -53,7 +53,7 @@ typedef void(^AHKActionSheetHandler)(AHKActionSheet *actionSheet);
 /// Text attributes of the title (passed in initWithTitle: or set via `title` property)
 @property (copy, nonatomic) NSDictionary *titleTextAttributes UI_APPEARANCE_SELECTOR;
 @property (copy, nonatomic) NSDictionary *buttonTextAttributes UI_APPEARANCE_SELECTOR;
-@property (copy, nonatomic) NSDictionary *disabledButtonTextAttributes UI_APPEARANCE_SELECTOR;
+@property (copy, nonatomic) NSDictionary *disableButtonTextAttributes UI_APPEARANCE_SELECTOR;
 @property (copy, nonatomic) NSDictionary *destructiveButtonTextAttributes UI_APPEARANCE_SELECTOR;
 @property (copy, nonatomic) NSDictionary *encryptedButtonTextAttributes UI_APPEARANCE_SELECTOR;
 @property (copy, nonatomic) NSDictionary *cancelButtonTextAttributes UI_APPEARANCE_SELECTOR;

+ 35 - 18
Libraries external/AHKActionSheet/AHKActionSheet.m

@@ -72,17 +72,13 @@ static const CGFloat kSpaceDivide = 5.0f;
     [appearance setCancelButtonHeight:44.0f];
     [appearance setAutomaticallyTintButtonImages:@YES];
     [appearance setSelectedBackgroundColor:[UIColor colorWithWhite:0.1f alpha:0.2f]];
-    [appearance setCancelButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f],
-                                                 NSForegroundColorAttributeName : [UIColor darkGrayColor] }];
+    [appearance setCancelButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f], NSForegroundColorAttributeName : [UIColor darkGrayColor] }];
     [appearance setButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f]}];
-    [appearance setDisabledButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:14.0f],
-                                                   NSForegroundColorAttributeName : [UIColor colorWithWhite:0.6f alpha:1.0] }];
-    [appearance setDestructiveButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f],
-                                                      NSForegroundColorAttributeName : [UIColor redColor] }];
-    [appearance setTitleTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:14.0f],
-                                          NSForegroundColorAttributeName : [UIColor grayColor] }];
+    [appearance setDisableButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f]}];
+    [appearance setDestructiveButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f], NSForegroundColorAttributeName : [UIColor redColor] }];
+    [appearance setTitleTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:14.0f], NSForegroundColorAttributeName : [UIColor grayColor] }];
     [appearance setCancelOnPanGestureEnabled:@(NO)];
-    [appearance setCancelOnTapEmptyAreaEnabled:@(NO)];
+    [appearance setCancelOnTapEmptyAreaEnabled:@(YES)];
     [appearance setAnimationDuration:kDefaultAnimationDuration];
 }
 
@@ -149,7 +145,7 @@ static const CGFloat kSpaceDivide = 5.0f;
             attributes = self.buttonTextAttributes;
             break;
         case AHKActionSheetButtonTypeDisabled:
-            attributes = self.disabledButtonTextAttributes;
+            attributes = self.disableButtonTextAttributes;
             cell.selectionStyle = UITableViewCellSelectionStyleNone;
             break;
         case AHKActionSheetButtonTypeDestructive:
@@ -160,18 +156,39 @@ static const CGFloat kSpaceDivide = 5.0f;
             break;
     }
 
-    NSAttributedString *attrTitle = [[NSAttributedString alloc] initWithString:item.title attributes:attributes];
-    cell.textLabel.attributedText = attrTitle;
-    cell.textLabel.textAlignment = [self.buttonTextCenteringEnabled boolValue] ? NSTextAlignmentCenter : NSTextAlignmentLeft;
-
     // Use image with template mode with color the same as the text (when enabled).
     BOOL useTemplateMode = [UIImage instancesRespondToSelector:@selector(imageWithRenderingMode:)] && [self.automaticallyTintButtonImages boolValue];
-    cell.imageView.image = useTemplateMode ? [item.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] : item.image;
+    
+    if (item.type != AHKActionSheetButtonTypeDisabled) {
+        
+        NSAttributedString *attrTitle = [[NSAttributedString alloc] initWithString:item.title attributes:attributes];
+        cell.textLabel.attributedText = attrTitle;
+        cell.textLabel.textAlignment = [self.buttonTextCenteringEnabled boolValue] ? NSTextAlignmentCenter : NSTextAlignmentLeft;
+        
+        cell.imageView.image = useTemplateMode ? [item.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] : item.image;
 
-    if ([UIImageView instancesRespondToSelector:@selector(tintColor)]){
-        cell.imageView.tintColor = attributes[NSForegroundColorAttributeName] ? attributes[NSForegroundColorAttributeName] : [UIColor blackColor];
+        if ([UIImageView instancesRespondToSelector:@selector(tintColor)]){
+            cell.imageView.tintColor = attributes[NSForegroundColorAttributeName] ? attributes[NSForegroundColorAttributeName] : [UIColor blackColor];
+        }
+        
+    } else {
+        
+        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, _buttonHeight/2 - 15, 30, 30)];
+        imageView.backgroundColor = [UIColor clearColor];
+        //[imageView.layer setCornerRadius:8.0f];
+        [imageView.layer setMasksToBounds:YES];
+        [imageView setImage:item.image];
+        [cell.contentView addSubview:imageView];
+        
+        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(cell.frame.size.height + 5 , 0, cell.frame.size.width - cell.frame.size.height - 20, cell.frame.size.height)];
+        NSAttributedString *attrTitle = [[NSAttributedString alloc] initWithString:item.title attributes:attributes];
+        label.text =  [NSString stringWithFormat: @"test"];
+        label.numberOfLines = 0;
+        label.attributedText = attrTitle;
+        label.textAlignment = NSTextAlignmentLeft;
+        [cell.contentView addSubview:label];
     }
-
+    
     cell.backgroundColor = item.backgroundColor;
 
     if (self.selectedBackgroundColor && ![cell.selectedBackgroundView.backgroundColor isEqual:self.selectedBackgroundColor]) {

+ 0 - 3
iOSClient/Create/CCCreateCloud.swift

@@ -39,7 +39,6 @@ class CreateMenuAdd: NSObject {
         let actionSheet = AHKActionSheet.init(view: view, title: nil)
         
         actionSheet?.animationDuration = 0.2
-        actionSheet?.cancelOnTapEmptyAreaEnabled = 1
         actionSheet?.automaticallyTintButtonImages = 0
         
         actionSheet?.blurRadius = 0.0
@@ -83,7 +82,6 @@ class CreateMenuAdd: NSObject {
         let actionSheet = AHKActionSheet.init(view: view, title: nil)
         
         actionSheet?.animationDuration = 0.2
-        actionSheet?.cancelOnTapEmptyAreaEnabled = 1
         
         actionSheet?.blurRadius = 0.0
         actionSheet?.blurTintColor = UIColor(white: 0.0, alpha: 0.50)
@@ -126,7 +124,6 @@ class CreateMenuAdd: NSObject {
         let actionSheet = AHKActionSheet.init(view: view, title: nil)
         
         actionSheet?.animationDuration = 0.2
-        actionSheet?.cancelOnTapEmptyAreaEnabled = 1
         
         actionSheet?.blurRadius = 0.0
         actionSheet?.blurTintColor = UIColor(white: 0.0, alpha: 0.50)

+ 4 - 38
iOSClient/Favorite/CCFavorite.m

@@ -369,36 +369,6 @@
     } else return nil;
 }
 
-+ (UIView *)headerActionSheet:(UITableViewController *)vc image:(UIImage *)image title:(NSString *)title cryptated:(BOOL)cryptated
-{
-    CGFloat width = CGRectGetWidth(vc.view.bounds);
-    //CGFloat height = CGRectGetHeight(vc.view.bounds);
-    
-    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 60)];
-    headerView.backgroundColor = COLOR_NAVBAR_IOS7;
-    
-    // IMAGE
-    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
-    imageView.frame = CGRectMake(13, 15, 30, 30);
-    
-    [headerView addSubview:imageView];
-    
-    // LABEL
-    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(55, 0, width-55-10, 60)];
-    label.numberOfLines = 0;
-    label.text = title;
-    
-    if (cryptated) label.textColor = COLOR_ENCRYPTED;
-    else label.textColor = COLOR_CLEAR;
-    
-    label.font = [UIFont systemFontOfSize:13];
-    label.backgroundColor = [UIColor clearColor];
-    
-    [headerView addSubview:label];
-    
-    return  headerView;
-}
-
 - (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     UIImage *iconHeader;
@@ -413,22 +383,21 @@
     AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithView:self.view title:nil];
     
     actionSheet.animationDuration = 0.2;
-    actionSheet.cancelOnTapEmptyAreaEnabled = @(YES);
-    actionSheet.automaticallyTintButtonImages = @(NO);
     
     actionSheet.blurRadius = 0.0f;
     actionSheet.blurTintColor = [UIColor colorWithWhite:0.0f alpha:0.50f];
     
     actionSheet.buttonHeight = 50.0;
     actionSheet.cancelButtonHeight = 50.0f;
-    actionSheet.separatorHeight = 30.0f;
+    actionSheet.separatorHeight = 5.0f;
     
     actionSheet.selectedBackgroundColor = COLOR_SELECT_BACKGROUND;
-
+    
     actionSheet.encryptedButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_ENCRYPTED };
     actionSheet.buttonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_GRAY };
     actionSheet.cancelButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:16], NSForegroundColorAttributeName:COLOR_BRAND };
-
+    actionSheet.disableButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_GRAY };
+    
     actionSheet.separatorColor = COLOR_SEPARATOR_TABLE;
     actionSheet.cancelButtonTitle = NSLocalizedString(@"_cancel_",nil);
 
@@ -437,9 +406,6 @@
         iconHeader = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/.%@.ico", self.serverUrlLocal, self.metadata.fileNamePrint]];
     else
         iconHeader = [UIImage imageNamed:self.metadata.iconName];
-
-    UIView *headerView = [[self class] headerActionSheet:self image:iconHeader title:self.metadata.fileNamePrint cryptated:self.metadata.cryptated];
-    actionSheet.headerView = headerView;
         
     [actionSheet addButtonWithTitle:NSLocalizedString(@"_open_in_", nil)
                               image:[UIImage imageNamed:image_actionSheetOpenIn]

+ 49 - 110
iOSClient/Main/CCMain.m

@@ -3967,36 +3967,6 @@
     return NSLocalizedString(@"_more_", nil);
 }
 
-+ (UIView *)headerActionSheet:(UITableViewController *)vc image:(UIImage *)image title:(NSString *)title cryptated:(BOOL)cryptated
-{
-    CGFloat width = CGRectGetWidth(vc.view.bounds);
-    //CGFloat height = CGRectGetHeight(vc.view.bounds);
-    
-    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 60)];
-    headerView.backgroundColor = COLOR_NAVBAR_IOS7;
-    
-    // IMAGE
-    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
-    imageView.frame = CGRectMake(13, 15, 30, 30);
-    
-    [headerView addSubview:imageView];
-    
-    // LABEL
-    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(55, 0, width-55-10, 60)];
-    label.numberOfLines = 0;
-    label.text = title;
-    
-    if (cryptated) label.textColor = COLOR_ENCRYPTED;
-    else label.textColor = COLOR_CLEAR;
-    
-    label.font = [UIFont systemFontOfSize:13];
-    label.backgroundColor = [UIColor clearColor];
-    
-    [headerView addSubview:label];
-    
-    return  headerView;
-}
-
 - (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     _metadata = [self getMetadataFromSectionDataSource:indexPath];
@@ -4026,6 +3996,31 @@
         else titoloLock = [NSString stringWithFormat:NSLocalizedString(@"_protect_passcode_", nil)];
     }
     
+    /******************************************* AHKActionSheet *******************************************/
+    
+    UIImage *iconHeader;
+    
+    AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithView:self.view title:nil];
+    
+    actionSheet.animationDuration = 0.2;
+    
+    actionSheet.blurRadius = 0.0f;
+    actionSheet.blurTintColor = [UIColor colorWithWhite:0.0f alpha:0.50f];
+    
+    actionSheet.buttonHeight = 50.0;
+    actionSheet.cancelButtonHeight = 50.0f;
+    actionSheet.separatorHeight = 5.0f;
+    
+    actionSheet.selectedBackgroundColor = COLOR_SELECT_BACKGROUND;
+    
+    actionSheet.encryptedButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_ENCRYPTED };
+    actionSheet.buttonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_GRAY };
+    actionSheet.cancelButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:16], NSForegroundColorAttributeName:COLOR_BRAND };
+    actionSheet.disableButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:COLOR_GRAY };
+    
+    actionSheet.separatorColor = COLOR_SEPARATOR_TABLE;
+    actionSheet.cancelButtonTitle = NSLocalizedString(@"_cancel_",nil);
+    
     /******************************************* DIRECTORY *******************************************/
     
     if (_metadata.directory) {
@@ -4038,37 +4033,19 @@
         // Directory bloccata ?
         if ([CCCoreData isDirectoryLock:lockServerUrl activeAccount:app.activeAccount] && [[CCUtility getBlockCode] length] && app.sessionePasscodeLock == nil) lockDirectory = YES;
         
-        AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithView:self.view title:nil];
-        
-        actionSheet.animationDuration = 0.2;
-        actionSheet.cancelOnTapEmptyAreaEnabled = @(YES);
-        actionSheet.automaticallyTintButtonImages = @(NO);
-
-        actionSheet.blurRadius = 0.0f;
-        actionSheet.blurTintColor = [UIColor colorWithWhite:0.0f alpha:0.50f];
-        
-        actionSheet.buttonHeight = 50.0;
-        actionSheet.cancelButtonHeight = 50.0f;
-        actionSheet.separatorHeight = 30.0f;
-        
-        actionSheet.selectedBackgroundColor = COLOR_SELECT_BACKGROUND;
-        
-        actionSheet.encryptedButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_ENCRYPTED };
-        actionSheet.buttonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_GRAY };
-        actionSheet.cancelButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:16], NSForegroundColorAttributeName:COLOR_BRAND };
-
-        actionSheet.separatorColor = COLOR_SEPARATOR_TABLE;
-        actionSheet.cancelButtonTitle = NSLocalizedString(@"_cancel_",nil);
-
         iconHeader = [UIImage imageNamed:_metadata.iconName];
-        
-        UIView *headerView = [[self class] headerActionSheet:self image:iconHeader title:_metadata.fileNamePrint cryptated:_metadata.cryptated];
-        
-        actionSheet.headerView = headerView;
 
         NSString *cameraUploadFolderName = [CCCoreData getCameraUploadFolderNameActiveAccount:app.activeAccount];
         NSString *cameraUploadFolderPath = [CCCoreData getCameraUploadFolderPathActiveAccount:app.activeAccount activeUrl:app.activeUrl typeCloud:app.typeCloud];
         
+        [actionSheet addButtonWithTitle: _metadata.fileNamePrint
+                                  image: iconHeader
+                        backgroundColor: COLOR_NAVBAR_IOS7
+                                 height: 50.0
+                                   type: AHKActionSheetButtonTypeDisabled
+                                handler: nil
+        ];
+
         if (!([_metadata.fileName isEqualToString:cameraUploadFolderName] == YES && [_localServerUrl isEqualToString:cameraUploadFolderPath] == YES) && !lockDirectory) {
             
             [actionSheet addButtonWithTitle:NSLocalizedString(@"_rename_", nil)
@@ -4189,39 +4166,20 @@
     
     if ([_metadata.type isEqualToString:metadataType_file] && !_metadata.directory) {
         
-        UIImage *iconHeader;
-        
-        AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithView:self.view title:nil];
-        
-        actionSheet.animationDuration = 0.2;
-        actionSheet.cancelOnTapEmptyAreaEnabled = @(YES);
-        actionSheet.automaticallyTintButtonImages = @(NO);
-        
-        actionSheet.blurRadius = 0.0f;
-        actionSheet.blurTintColor = [UIColor colorWithWhite:0.0f alpha:0.50f];
-        
-        actionSheet.buttonHeight = 50.0;
-        actionSheet.cancelButtonHeight = 50.0f;
-        actionSheet.separatorHeight = 30.0f;
-        
-        actionSheet.selectedBackgroundColor = COLOR_SELECT_BACKGROUND;
-        
-        actionSheet.encryptedButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_ENCRYPTED };
-        actionSheet.buttonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_GRAY };
-        actionSheet.cancelButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:16], NSForegroundColorAttributeName:COLOR_BRAND };
-        
-        actionSheet.separatorColor = COLOR_SEPARATOR_TABLE;
-        actionSheet.cancelButtonTitle = NSLocalizedString(@"_cancel_",nil);
-        
         // assegnamo l'immagine anteprima se esiste, altrimenti metti quella standars
         if ([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, _metadata.fileID]])
             iconHeader = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.ico", app.directoryUser, _metadata.fileID]];
         else
             iconHeader = [UIImage imageNamed:_metadata.iconName];
-    
-        UIView *headerView = [[self class] headerActionSheet:self image:iconHeader title:_metadata.fileNamePrint cryptated:_metadata.cryptated];
-        actionSheet.headerView = headerView;
-
+        
+        [actionSheet addButtonWithTitle: _metadata.fileNamePrint
+                                  image: iconHeader
+                        backgroundColor: COLOR_NAVBAR_IOS7
+                                 height: 50.0
+                                   type: AHKActionSheetButtonTypeDisabled
+                                handler: nil
+        ];
+        
         [actionSheet addButtonWithTitle:NSLocalizedString(@"_rename_", nil)
                                   image:[UIImage imageNamed:image_actionSheetRename]
                         backgroundColor:[UIColor whiteColor]
@@ -4346,34 +4304,15 @@
     
     if ([_metadata.type isEqualToString:metadataType_model]) {
         
-        UIImage *iconHeader;
-     
-        AHKActionSheet *actionSheet = [[AHKActionSheet alloc] initWithView:self.view title:nil];
-     
-        actionSheet.animationDuration = 0.2;
-        actionSheet.cancelOnTapEmptyAreaEnabled = @(YES);
-        actionSheet.automaticallyTintButtonImages = @(NO);
-        
-        actionSheet.blurRadius = 0.0f;
-        actionSheet.blurTintColor = [UIColor colorWithWhite:0.0f alpha:0.50f];
-        
-        actionSheet.buttonHeight = 50.0;
-        actionSheet.cancelButtonHeight = 50.0f;
-        actionSheet.separatorHeight = 30.0f;
-        
-        actionSheet.selectedBackgroundColor = COLOR_SELECT_BACKGROUND;
-        
-        actionSheet.encryptedButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_ENCRYPTED };
-        actionSheet.buttonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:COLOR_GRAY };
-        actionSheet.cancelButtonTextAttributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:16], NSForegroundColorAttributeName:COLOR_BRAND };
-        
-        actionSheet.separatorColor = COLOR_SEPARATOR_TABLE;
-        actionSheet.cancelButtonTitle = NSLocalizedString(@"_cancel_",nil);
-
         iconHeader = [UIImage imageNamed:_metadata.iconName];
      
-        UIView *headerView = [[self class] headerActionSheet:self image:iconHeader title:_metadata.fileNamePrint cryptated:_metadata.cryptated];
-        actionSheet.headerView = headerView;
+        [actionSheet addButtonWithTitle: _metadata.fileNamePrint
+                                  image: iconHeader
+                        backgroundColor: COLOR_NAVBAR_IOS7
+                                 height: 50.0
+                                   type: AHKActionSheetButtonTypeDisabled
+                                handler: nil
+        ];
         
         if ([_metadata.model isEqualToString:@"note"]) {