Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Friend-LGA committed Nov 13, 2015
1 parent 3f3b8ef commit 7defffe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Demo/LGAlertViewDemo/TableViewControllerCustomActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
alertView.messageTextColor = [UIColor blackColor];
alertView.width = MIN(self.view.bounds.size.width, self.view.bounds.size.height);
alertView.offsetVertical = 0.f;
alertView.cancelButtonOffset = 0.f;
alertView.cancelButtonOffsetY = 0.f;
[alertView showAnimated:YES completionHandler:nil];
}
else if (indexPath.row == 5)
Expand Down Expand Up @@ -184,7 +184,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
alertView.messageTextColor = [UIColor blackColor];
alertView.width = MIN(self.view.bounds.size.width, self.view.bounds.size.height);
alertView.offsetVertical = 0.f;
alertView.cancelButtonOffset = 0.f;
alertView.cancelButtonOffsetY = 0.f;
alertView.titleTextAlignment = NSTextAlignmentLeft;
alertView.messageTextAlignment = NSTextAlignmentLeft;
alertView.buttonsTextAlignment = NSTextAlignmentRight;
Expand Down Expand Up @@ -217,7 +217,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
alertView.messageTextColor = [UIColor blackColor];
alertView.width = MIN(self.view.bounds.size.width, self.view.bounds.size.height);
alertView.offsetVertical = 0.f;
alertView.cancelButtonOffset = 0.f;
alertView.cancelButtonOffsetY = 0.f;
alertView.titleTextAlignment = NSTextAlignmentLeft;
alertView.messageTextAlignment = NSTextAlignmentLeft;
alertView.destructiveButtonTextAlignment = NSTextAlignmentRight;
Expand Down Expand Up @@ -251,7 +251,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
alertView.messageTextColor = [UIColor blackColor];
alertView.width = MIN(self.view.bounds.size.width, self.view.bounds.size.height);
alertView.offsetVertical = 0.f;
alertView.cancelButtonOffset = 0.f;
alertView.cancelButtonOffsetY = 0.f;
alertView.titleTextAlignment = NSTextAlignmentLeft;
alertView.messageTextAlignment = NSTextAlignmentLeft;
alertView.destructiveButtonTextAlignment = NSTextAlignmentRight;
Expand Down
2 changes: 1 addition & 1 deletion LGAlertView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'LGAlertView'
s.version = '2.0.8'
s.version = '2.0.9'
s.platform = :ios, '6.0'
s.license = 'MIT'
s.homepage = 'https://github.com/Friend-LGA/LGAlertView'
Expand Down
2 changes: 1 addition & 1 deletion LGAlertView/LGAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ typedef NS_ENUM(NSUInteger, LGAlertViewWindowLevel)
/** Top and bottom offsets from borders of the screen */
@property (assign, nonatomic) CGFloat offsetVertical;
/** Offset between cancel button and main view when style is LGAlertViewStyleActionSheet. Default is 8.f */
@property (assign, nonatomic) CGFloat cancelButtonOffset;
@property (assign, nonatomic) CGFloat cancelButtonOffsetY;
@property (assign, nonatomic) CGFloat heightMax;
@property (assign, nonatomic) CGFloat width;

Expand Down
12 changes: 6 additions & 6 deletions LGAlertView/LGAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define kLGAlertViewWidthStyleAlert (320.f - 20*2)
#define kLGAlertViewWidthStyleActionSheet (320.f - 16*2)
#define kLGAlertViewInnerMarginH (_style == LGAlertViewStyleAlert ? 16.f : 12.f)
#define kLGAlertViewIsCancelButtonSeparate(alertView) (alertView.style == LGAlertViewStyleActionSheet && alertView.cancelButtonOffset > 0.f && !kLGAlertViewPadAndNotForce(alertView))
#define kLGAlertViewIsCancelButtonSeparate(alertView) (alertView.style == LGAlertViewStyleActionSheet && alertView.cancelButtonOffsetY > 0.f && !kLGAlertViewPadAndNotForce(alertView))
#define kLGAlertViewButtonWidthMin 64.f
#define kLGAlertViewWindowPrevious(index) (index > 0 && index < kLGAlertViewWindowsArray.count ? [kLGAlertViewWindowsArray objectAtIndex:(index-1)] : nil)
#define kLGAlertViewWindowNext(index) (kLGAlertViewWindowsArray.count > index+1 ? [kLGAlertViewWindowsArray objectAtIndex:(index+1)] : nil)
Expand Down Expand Up @@ -848,7 +848,7 @@ - (void)setupDefaults
_buttonsHeight = (([UIDevice currentDevice].systemVersion.floatValue < 9.0 || _style == LGAlertViewStyleAlert) ? 44.f : 56.f);
_textFieldsHeight = 44.f;
_offsetVertical = -1;
_cancelButtonOffset = kLGAlertViewOffsetHorizontal;
_cancelButtonOffsetY = kLGAlertViewOffsetHorizontal;
_heightMax = -1.f;
_width = -1.f;

Expand Down Expand Up @@ -2583,7 +2583,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size
heightMax = _heightMax;

if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton)
heightMax -= (_buttonsHeight+_cancelButtonOffset);
heightMax -= (_buttonsHeight+_cancelButtonOffsetY);
else if (_cancelOnTouch &&
!_cancelButtonTitle.length &&
size.width < width+_buttonsHeight*2)
Expand Down Expand Up @@ -2616,7 +2616,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size
{
CGFloat bottomShift = kLGAlertViewOffsetVertical;
if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton)
bottomShift += _buttonsHeight+_cancelButtonOffset;
bottomShift += _buttonsHeight+_cancelButtonOffsetY;

scrollViewFrame = CGRectMake(size.width/2-width/2, size.height-bottomShift-heightMax, width, heightMax);
}
Expand All @@ -2627,7 +2627,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size
{
CGRect cancelButtonFrame = CGRectZero;
if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton)
cancelButtonFrame = CGRectMake(size.width/2-width/2, size.height-_cancelButtonOffset-_buttonsHeight, width, _buttonsHeight);
cancelButtonFrame = CGRectMake(size.width/2-width/2, size.height-_cancelButtonOffsetY-_buttonsHeight, width, _buttonsHeight);

_scrollViewCenterShowed = CGPointMake(scrollViewFrame.origin.x+scrollViewFrame.size.width/2, scrollViewFrame.origin.y+scrollViewFrame.size.height/2);
_cancelButtonCenterShowed = CGPointMake(cancelButtonFrame.origin.x+cancelButtonFrame.size.width/2, cancelButtonFrame.origin.y+cancelButtonFrame.size.height/2);
Expand All @@ -2636,7 +2636,7 @@ - (void)layoutInvalidateWithSize:(CGSize)size

CGFloat commonHeight = scrollViewFrame.size.height+kLGAlertViewOffsetVertical;
if (kLGAlertViewIsCancelButtonSeparate(self) && _cancelButton)
commonHeight += _buttonsHeight+_cancelButtonOffset;
commonHeight += _buttonsHeight+_cancelButtonOffsetY;

_scrollViewCenterHidden = CGPointMake(scrollViewFrame.origin.x+scrollViewFrame.size.width/2, scrollViewFrame.origin.y+scrollViewFrame.size.height/2+commonHeight+_layerBorderWidth+_layerShadowRadius);
_cancelButtonCenterHidden = CGPointMake(cancelButtonFrame.origin.x+cancelButtonFrame.size.width/2, cancelButtonFrame.origin.y+cancelButtonFrame.size.height/2+commonHeight);
Expand Down

0 comments on commit 7defffe

Please sign in to comment.