Browse Source

background view/color ActionSheet

Marino Faggiana 8 years ago
parent
commit
99001a5d1f

+ 0 - 2
Libraries external/AHKActionSheet/AHKActionSheet.h

@@ -54,8 +54,6 @@ typedef void(^AHKActionSheetHandler)(AHKActionSheet *actionSheet);
 @property (strong, nonatomic) NSNumber *buttonTextCenteringEnabled UI_APPEARANCE_SELECTOR;
 /// Color of the separator between buttons.
 @property (strong, nonatomic) UIColor *separatorColor UI_APPEARANCE_SELECTOR;
-/// Background color of the button when it's tapped (internally it's a UITableViewCell)
-@property (strong, nonatomic) UIColor *selectedBackgroundColor UI_APPEARANCE_SELECTOR;
 /// 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;

+ 15 - 13
Libraries external/AHKActionSheet/AHKActionSheet.m

@@ -79,7 +79,6 @@ static const CGFloat maxWidth = 414.0f;
     [appearance setSeparatorHeight: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 setButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f]}];
     [appearance setDisableButtonTextAttributes:@{ NSFontAttributeName : [UIFont systemFontOfSize:17.0f]}];
@@ -145,7 +144,7 @@ static const CGFloat maxWidth = 414.0f;
     if (cell == nil)
         cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier forIndexPath:indexPath];
     
-    cell.selectionStyle = UITableViewCellSelectionStyleNone;
+    //cell.selectionStyle = UITableViewCellSelectionStyleNone;
     
     AHKActionSheetItem *item = self.items[(NSUInteger)indexPath.row];
 
@@ -196,11 +195,7 @@ static const CGFloat maxWidth = 414.0f;
     label.textAlignment = [self.buttonTextCenteringEnabled boolValue] ? NSTextAlignmentCenter : NSTextAlignmentLeft;
     
     cell.backgroundColor = item.backgroundColor;
-
-    if (self.selectedBackgroundColor && ![cell.selectedBackgroundView.backgroundColor isEqual:self.selectedBackgroundColor]) {
-        cell.selectedBackgroundView = [[UIView alloc] init];
-        cell.selectedBackgroundView.backgroundColor = self.selectedBackgroundColor;
-    }
+    cell.selectedBackgroundView = [self createBackgroundView:tableView cell:cell forRowAtIndexPath:indexPath color:self.separatorColor];
     
     for (UIView *subview in [cell.contentView subviews])
         [subview removeFromSuperview];
@@ -232,6 +227,11 @@ static const CGFloat maxWidth = 414.0f;
 {
     AHKActionSheetItem *item = self.items[(NSUInteger)indexPath.row];
     
+    cell.backgroundView = [self createBackgroundView:tableView cell:cell forRowAtIndexPath:indexPath color:item.backgroundColor];
+}
+
+- (UIView *)createBackgroundView:(UITableView *)tableView cell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath color:(UIColor *)color
+{
     CGFloat cornerRadius = 10.f;
     cell.backgroundColor = UIColor.clearColor;
     CAShapeLayer *layer = [[CAShapeLayer alloc] init];
@@ -257,10 +257,6 @@ static const CGFloat maxWidth = 414.0f;
         addLine = YES;
     }
     
-    layer.path = pathRef;
-    CFRelease(pathRef);
-    layer.fillColor = item.backgroundColor.CGColor;
-    
     if (addLine == YES) {
         CALayer *lineLayer = [[CALayer alloc] init];
         CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
@@ -268,13 +264,19 @@ static const CGFloat maxWidth = 414.0f;
         lineLayer.backgroundColor = tableView.separatorColor.CGColor;
         [layer addSublayer:lineLayer];
     }
-    
+
+    layer.path = pathRef;
+    CFRelease(pathRef);
+    layer.fillColor = color.CGColor;
+
     UIView *testView = [[UIView alloc] initWithFrame:bounds];
     [testView.layer insertSublayer:layer atIndex:0];
     testView.backgroundColor = UIColor.clearColor;
-    cell.backgroundView = testView;
+
+    return testView;
 }
 
+
 #pragma mark - UIScrollViewDelegate
 
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView

+ 0 - 3
iOSClient/Create/CCCreateCloud.swift

@@ -49,7 +49,6 @@ class CreateMenuAdd: NSObject {
         actionSheet?.cancelButtonHeight = 50.0
         actionSheet?.separatorHeight = 5.0
         
-        actionSheet?.selectedBackgroundColor = UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 0.1)
         actionSheet?.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
         
         actionSheet?.buttonTextAttributes = fontButton
@@ -94,7 +93,6 @@ class CreateMenuAdd: NSObject {
         actionSheet?.cancelButtonHeight = 50.0
         actionSheet?.separatorHeight = 5.0
         
-        actionSheet?.selectedBackgroundColor = UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 0.1)
         actionSheet?.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
 
         actionSheet?.buttonTextAttributes = fontButton
@@ -143,7 +141,6 @@ class CreateMenuAdd: NSObject {
         actionSheet?.cancelButtonHeight = 50.0
         actionSheet?.separatorHeight = 5.0
         
-        actionSheet?.selectedBackgroundColor = UIColor(colorLiteralRed: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 0.1)
         actionSheet?.separatorColor = UIColor(colorLiteralRed: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 0.2)
 
         actionSheet?.buttonTextAttributes = fontButton

+ 1 - 3
iOSClient/Favorite/CCFavorite.m

@@ -390,9 +390,7 @@
     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 };

+ 1 - 3
iOSClient/Main/CCMain.m

@@ -4063,9 +4063,7 @@
     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 };