Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
indulgeIn committed Apr 24, 2019
1 parent f99f3b1 commit c04a904
Show file tree
Hide file tree
Showing 20 changed files with 389 additions and 327 deletions.
20 changes: 10 additions & 10 deletions Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion YBImageBrowser.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Pod::Spec.new do |s|


s.name = "YBImageBrowser"
s.version = "2.1.7"
s.version = "2.1.8"
s.summary = "image browser for iOS (powerful, superior performance)"
s.description = <<-DESC
image browser for iOS (powerful, superior performance),
Expand Down
10 changes: 5 additions & 5 deletions YBImageBrowser/AuxiliaryView/YBImageBrowserProgressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ - (void)drawRect:(CGRect)rect {
[bottomPath stroke];

[[UIColor whiteColor] setStroke];
UIBezierPath *activePath = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:-M_PI / 2.0 endAngle:M_PI * 2 * self->_progress - M_PI / 2.0 clockwise:true];
UIBezierPath *activePath = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:-M_PI / 2.0 endAngle:M_PI * 2 * _progress - M_PI / 2.0 clockwise:true];
activePath.lineWidth = strokeWidth;
activePath.lineCapStyle = kCGLineCapRound;
activePath.lineJoinStyle = kCGLineCapRound;
[activePath stroke];

NSString *string = [NSString stringWithFormat:@"%.0lf%@", self->_progress * 100, @"%"];
NSString *string = [NSString stringWithFormat:@"%.0lf%@", _progress * 100, @"%"];
NSMutableAttributedString *atts = [[NSMutableAttributedString alloc] initWithString:string attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:10], NSForegroundColorAttributeName:[UIColor whiteColor]}];
CGSize size = atts.size;
[atts drawAtPoint:CGPointMake(center.x - size.width / 2.0, center.y - size.height / 2.0)];
Expand Down Expand Up @@ -152,7 +152,7 @@ - (void)updateConstraints {

- (void)showProgress:(CGFloat)progress {
self.userInteractionEnabled = NO;
self->_type = YBImageBrowserProgressTypeProgress;
_type = YBImageBrowserProgressTypeProgress;
self.drawView.hidden = NO;
self.textLabel.hidden = YES;
self.imageView.hidden = YES;
Expand All @@ -164,7 +164,7 @@ - (void)showProgress:(CGFloat)progress {

- (void)showLoading {
self.userInteractionEnabled = NO;
self->_type = YBImageBrowserProgressTypeLoad;
_type = YBImageBrowserProgressTypeLoad;
self.drawView.hidden = YES;
self.textLabel.hidden = YES;
self.imageView.hidden = NO;
Expand All @@ -190,7 +190,7 @@ - (void)stopImageViewAnimation {

- (void)showText:(NSString *)text click:(void(^)(void))click {
self.userInteractionEnabled = click ? YES : NO;
self->_type = YBImageBrowserProgressTypeText;
_type = YBImageBrowserProgressTypeText;
self.drawView.hidden = YES;
self.textLabel.hidden = NO;
self.imageView.hidden = YES;
Expand Down
26 changes: 13 additions & 13 deletions YBImageBrowser/AuxiliaryView/YBImageBrowserSheetView.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ @implementation YBImageBrowserSheetView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self->_heightOfCell = 50;
self->_cancelText = [YBIBCopywriter shareCopywriter].cancel;
self->_maxHeightScale = 0.7;
self->_animateDuration = 0.2;
_heightOfCell = 50;
_cancelText = [YBIBCopywriter shareCopywriter].cancel;
_maxHeightScale = 0.7;
_animateDuration = 0.2;

[self addSubview:self.tableView];
}
Expand All @@ -90,20 +90,20 @@ - (instancetype)initWithFrame:(CGRect)frame {
- (void)yb_browserShowSheetViewWithData:(id<YBImageBrowserCellDataProtocol>)data layoutDirection:(YBImageBrowserLayoutDirection)layoutDirection containerSize:(CGSize)containerSize {
if (self.actions.count <= 0) return;

self->_data = data;
_data = data;

CGFloat width = containerSize.width, height = containerSize.height;

CGFloat tableViewHeight = MIN(self.heightOfCell * self.actions.count + self.heightOfCell + 5 + YBIB_HEIGHT_EXTRABOTTOM, height * self.maxHeightScale);
self->_hideFrame = CGRectMake(0, height, width, tableViewHeight);
self->_showFrame = CGRectMake(0, height - tableViewHeight, width, tableViewHeight);
_hideFrame = CGRectMake(0, height, width, tableViewHeight);
_showFrame = CGRectMake(0, height - tableViewHeight, width, tableViewHeight);

self.frame = CGRectMake(0, 0, width, height);
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0];
self.tableView.frame = self->_hideFrame;
self.tableView.frame = _hideFrame;
[self.tableView reloadData];
self.footer.frame = CGRectMake(0, 0, width, YBIB_HEIGHT_EXTRABOTTOM);
[UIView animateWithDuration:self->_animateDuration animations:^{
[UIView animateWithDuration:_animateDuration animations:^{
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.35];
self.tableView.frame = self->_showFrame;
}];
Expand All @@ -120,7 +120,7 @@ - (void)yb_browserHideSheetViewWithAnimation:(BOOL)animation {
[self removeFromSuperview];
};
if (animation) {
[UIView animateWithDuration:self->_animateDuration animations:animationsBlock completion:completionBlock];
[UIView animateWithDuration:_animateDuration animations:animationsBlock completion:completionBlock];
} else {
animationsBlock();
completionBlock(NO);
Expand Down Expand Up @@ -175,13 +175,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0) {
if ([self.actions[indexPath.row].identity isEqualToString:kYBImageBrowserSheetActionIdentitySaveToPhotoAlbum]) {
if ([self->_data respondsToSelector:@selector(yb_browserSaveToPhotoAlbum)] && [self->_data respondsToSelector:@selector(yb_browserAllowSaveToPhotoAlbum)] && [self->_data yb_browserAllowSaveToPhotoAlbum]) {
[self->_data yb_browserSaveToPhotoAlbum];
if ([_data respondsToSelector:@selector(yb_browserSaveToPhotoAlbum)] && [_data respondsToSelector:@selector(yb_browserAllowSaveToPhotoAlbum)] && [_data yb_browserAllowSaveToPhotoAlbum]) {
[_data yb_browserSaveToPhotoAlbum];
} else {
[[UIApplication sharedApplication].keyWindow yb_showForkTipView:[YBIBCopywriter shareCopywriter].unableToSave];
}
} else {
self.actions[indexPath.row].action(self->_data);
self.actions[indexPath.row].action(_data);
}
}
[self yb_browserHideSheetViewWithAnimation:YES];
Expand Down
8 changes: 4 additions & 4 deletions YBImageBrowser/AuxiliaryView/YBImageBrowserTipView.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ @implementation YBImageBrowserTipView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self->_tipType = YBImageBrowserTipTypeNone;
_tipType = YBImageBrowserTipTypeNone;

self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8];
self.userInteractionEnabled = NO;
Expand All @@ -98,7 +98,7 @@ - (void)updateConstraints {
}

- (void)layoutSubviews {
if (self->_tipType != YBImageBrowserTipTypeNone) {
if (_tipType != YBImageBrowserTipTypeNone) {
[self _startAnimation];
}
[super layoutSubviews];
Expand All @@ -108,7 +108,7 @@ - (void)layoutSubviews {

- (void)startAnimationWithText:(NSString *)text type:(YBImageBrowserTipType)tipType {
self.textLabel.text = text;
self->_tipType = tipType;
_tipType = tipType;
[self setNeedsLayout];
}

Expand All @@ -129,7 +129,7 @@ - (void)_startAnimation {
CGFloat r = 13.0;
CGFloat x = self.bounds.size.width / 2.0;
CGFloat y = 38.0;
switch (self->_tipType) {
switch (_tipType) {
case YBImageBrowserTipTypeHook: {
[bezierPath moveToPoint:CGPointMake(x - r - r / 2, y)];
[bezierPath addLineToPoint:CGPointMake(x - r / 2, y + r)];
Expand Down
24 changes: 12 additions & 12 deletions YBImageBrowser/AuxiliaryView/YBImageBrowserToolBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ - (instancetype)initWithFrame:(CGRect)frame
- (void)setOperationButtonImage:(UIImage *)image title:(NSString *)title operation:(YBImageBrowserToolBarOperationBlock)operation {
[self.operationButton setImage:image forState:UIControlStateNormal];
[self.operationButton setTitle:title forState:UIControlStateNormal];
self->_operation = operation;
self->_operationType = YBImageBrowserToolBarOperationTypeCustom;
_operation = operation;
_operationType = YBImageBrowserToolBarOperationTypeCustom;
}

- (void)hideOperationButton {
Expand All @@ -67,7 +67,7 @@ - (void)yb_browserUpdateLayoutWithDirection:(YBImageBrowserLayoutDirection)layou
}

- (void)yb_browserPageIndexChanged:(NSUInteger)pageIndex totalPage:(NSUInteger)totalPage data:(id<YBImageBrowserCellDataProtocol>)data {
switch (self->_operationType) {
switch (_operationType) {
case YBImageBrowserToolBarOperationTypeSave: {
if ([data respondsToSelector:@selector(yb_browserSaveToPhotoAlbum)] && [data respondsToSelector:@selector(yb_browserAllowSaveToPhotoAlbum)] && [data yb_browserAllowSaveToPhotoAlbum]) {
self.operationButton.hidden = NO;
Expand All @@ -83,39 +83,39 @@ - (void)yb_browserPageIndexChanged:(NSUInteger)pageIndex totalPage:(NSUInteger)t
}
break;
case YBImageBrowserToolBarOperationTypeCustom: {
self.operationButton.hidden = !self->_operation;
self.operationButton.hidden = !_operation;
}
break;
}

self->_data = data;
_data = data;
if (totalPage <= 1) {
self.indexLabel.hidden = YES;
} else {
self.indexLabel.hidden = NO;
self.indexLabel.text = [NSString stringWithFormat:@"%ld/%ld", pageIndex + 1, totalPage];
self.indexLabel.text = [NSString stringWithFormat:@"%ld/%ld", (unsigned long)(pageIndex + 1), (unsigned long)totalPage];
}
}

#pragma mark - event

- (void)clickOperationButton:(UIButton *)button {
switch (self->_operationType) {
switch (_operationType) {
case YBImageBrowserToolBarOperationTypeSave: {
if ([self->_data respondsToSelector:@selector(yb_browserSaveToPhotoAlbum)]) {
[self->_data yb_browserSaveToPhotoAlbum];
if ([_data respondsToSelector:@selector(yb_browserSaveToPhotoAlbum)]) {
[_data yb_browserSaveToPhotoAlbum];
} else {
[[UIApplication sharedApplication].keyWindow yb_showForkTipView:[YBIBCopywriter shareCopywriter].unableToSave];
}
}
break;
case YBImageBrowserToolBarOperationTypeMore: {
self.yb_browserShowSheetViewBlock(self->_data);
self.yb_browserShowSheetViewBlock(_data);
}
break;
case YBImageBrowserToolBarOperationTypeCustom: {
if (self->_operation) {
self->_operation(self->_data);
if (_operation) {
_operation(_data);
}
}
break;
Expand Down
Loading

0 comments on commit c04a904

Please sign in to comment.