This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
157 changed files
with
5,059 additions
and
1,542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. | ||
* All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface BITActivityIndicatorButton : UIButton | ||
|
||
- (void)setShowsActivityIndicator:(BOOL)showsIndicator; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. | ||
* All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#import "BITActivityIndicatorButton.h" | ||
|
||
@interface BITActivityIndicatorButton() | ||
|
||
@property (nonatomic, strong) UIActivityIndicatorView *indicator; | ||
@property (nonatomic) BOOL indicatorVisible; | ||
|
||
@end | ||
|
||
@implementation BITActivityIndicatorButton | ||
|
||
- (void)setShowsActivityIndicator:(BOOL)showsIndicator { | ||
if (self.indicatorVisible == showsIndicator){ | ||
return; | ||
} | ||
|
||
if (!self.indicator){ | ||
self.indicator = [[UIActivityIndicatorView alloc] initWithFrame:self.bounds]; | ||
[self addSubview:self.indicator]; | ||
[self.indicator setColor:[UIColor blackColor]]; | ||
} | ||
|
||
self.indicatorVisible = showsIndicator; | ||
|
||
if (showsIndicator){ | ||
[self.indicator startAnimating]; | ||
self.indicator.alpha = 1; | ||
self.layer.borderWidth = 1; | ||
self.layer.borderColor = [UIColor lightGrayColor].CGColor; | ||
self.layer.cornerRadius = 5; | ||
self.imageView.image = nil; | ||
} else { | ||
[self.indicator stopAnimating]; | ||
self.layer.cornerRadius = 0; | ||
self.indicator.alpha = 0; | ||
self.layer.borderWidth = 0; | ||
|
||
} | ||
|
||
} | ||
|
||
- (void)layoutSubviews { | ||
[super layoutSubviews]; | ||
|
||
[self.indicator setFrame:self.bounds]; | ||
|
||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Author: Moritz Haarmann <[email protected]> | ||
* | ||
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. | ||
* All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#import "BITImageAnnotation.h" | ||
|
||
@interface BITArrowImageAnnotation : BITImageAnnotation | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
/* | ||
* Author: Moritz Haarmann <[email protected]> | ||
* | ||
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. | ||
* All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person | ||
* obtaining a copy of this software and associated documentation | ||
* files (the "Software"), to deal in the Software without | ||
* restriction, including without limitation the rights to use, | ||
* copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#import "BITArrowImageAnnotation.h" | ||
|
||
#define kArrowPointCount 7 | ||
|
||
|
||
@interface BITArrowImageAnnotation() | ||
|
||
@property (nonatomic, strong) CAShapeLayer *shapeLayer; | ||
@property (nonatomic, strong) CAShapeLayer *strokeLayer; | ||
|
||
@end | ||
|
||
@implementation BITArrowImageAnnotation | ||
|
||
- (instancetype)initWithFrame:(CGRect)frame { | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
self.shapeLayer = [CAShapeLayer layer]; | ||
self.shapeLayer.strokeColor = [UIColor whiteColor].CGColor; | ||
self.shapeLayer.lineWidth = 5; | ||
self.shapeLayer.fillColor = [UIColor redColor].CGColor; | ||
|
||
self.strokeLayer = [CAShapeLayer layer]; | ||
self.strokeLayer.strokeColor = [UIColor redColor].CGColor; | ||
self.strokeLayer.lineWidth = 10; | ||
self.strokeLayer.fillColor = [UIColor clearColor].CGColor; | ||
[self.layer addSublayer:self.strokeLayer]; | ||
|
||
[self.layer addSublayer:self.shapeLayer]; | ||
|
||
|
||
} | ||
return self; | ||
} | ||
|
||
- (void)buildShape { | ||
CGFloat baseWidth = MAX(self.frame.size.width, self.frame.size.height); | ||
CGFloat topHeight = MAX(baseWidth / 3.0f,10); | ||
|
||
|
||
CGFloat lineWidth = MAX(baseWidth / 10.0f,3); | ||
CGFloat startX, startY, endX, endY; | ||
|
||
CGRect boundRect = CGRectInset(self.bounds, 0, 0); | ||
CGFloat arrowLength= sqrt(pow(CGRectGetWidth(boundRect), 2) + pow(CGRectGetHeight(boundRect), 2)); | ||
if (arrowLength < 30){ | ||
|
||
CGFloat factor = 30.f/arrowLength; | ||
|
||
boundRect = CGRectApplyAffineTransform(boundRect, CGAffineTransformMakeScale(factor,factor)); | ||
} | ||
|
||
if ( self.movedDelta.width < 0){ | ||
startX = CGRectGetMinX(boundRect); | ||
endX = CGRectGetMaxX(boundRect); | ||
} else { | ||
startX = CGRectGetMaxX(boundRect); | ||
endX = CGRectGetMinX(boundRect); | ||
|
||
} | ||
|
||
if ( self.movedDelta.height < 0){ | ||
startY = CGRectGetMinY(boundRect); | ||
endY = CGRectGetMaxY(boundRect); | ||
} else { | ||
startY = CGRectGetMaxY(boundRect); | ||
endY = CGRectGetMinY(boundRect); | ||
|
||
} | ||
|
||
|
||
if (abs(CGRectGetWidth(boundRect)) < 30 || abs(CGRectGetHeight(boundRect)) < 30){ | ||
CGFloat smallerOne = MIN(abs(CGRectGetHeight(boundRect)), abs(CGRectGetWidth(boundRect))); | ||
|
||
CGFloat factor = smallerOne/30.f; | ||
|
||
CGRectApplyAffineTransform(boundRect, CGAffineTransformMakeScale(factor,factor)); | ||
} | ||
|
||
UIBezierPath *path = [self bezierPathWithArrowFromPoint:CGPointMake(endX, endY) toPoint:CGPointMake(startX, startY) tailWidth:lineWidth headWidth:topHeight headLength:topHeight]; | ||
|
||
self.shapeLayer.path = path.CGPath; | ||
self.strokeLayer.path = path.CGPath; | ||
[CATransaction begin]; | ||
[CATransaction setAnimationDuration:0]; | ||
self.strokeLayer.lineWidth = lineWidth/1.5f; | ||
self.shapeLayer.lineWidth = lineWidth / 3.0f; | ||
|
||
[CATransaction commit]; | ||
|
||
} | ||
|
||
|
||
- (UIBezierPath *)bezierPathWithArrowFromPoint:(CGPoint)startPoint | ||
toPoint:(CGPoint)endPoint | ||
tailWidth:(CGFloat)tailWidth | ||
headWidth:(CGFloat)headWidth | ||
headLength:(CGFloat)headLength { | ||
CGFloat length = hypotf(endPoint.x - startPoint.x, endPoint.y - startPoint.y); | ||
|
||
CGPoint points[kArrowPointCount]; | ||
[self getAxisAlignedArrowPoints:points | ||
forLength:length | ||
tailWidth:tailWidth | ||
headWidth:headWidth | ||
headLength:headLength]; | ||
|
||
CGAffineTransform transform = [self transformForStartPoint:startPoint | ||
endPoint:endPoint | ||
length:length]; | ||
|
||
CGMutablePathRef cgPath = CGPathCreateMutable(); | ||
CGPathAddLines(cgPath, &transform, points, sizeof points / sizeof *points); | ||
CGPathCloseSubpath(cgPath); | ||
|
||
UIBezierPath *uiPath = [UIBezierPath bezierPathWithCGPath:cgPath]; | ||
CGPathRelease(cgPath); | ||
return uiPath; | ||
} | ||
|
||
- (void)getAxisAlignedArrowPoints:(CGPoint[kArrowPointCount])points | ||
forLength:(CGFloat)length | ||
tailWidth:(CGFloat)tailWidth | ||
headWidth:(CGFloat)headWidth | ||
headLength:(CGFloat)headLength { | ||
CGFloat tailLength = length - headLength; | ||
points[0] = CGPointMake(0, tailWidth / 2); | ||
points[1] = CGPointMake(tailLength, tailWidth / 2); | ||
points[2] = CGPointMake(tailLength, headWidth / 2); | ||
points[3] = CGPointMake(length, 0); | ||
points[4] = CGPointMake(tailLength, -headWidth / 2); | ||
points[5] = CGPointMake(tailLength, -tailWidth / 2); | ||
points[6] = CGPointMake(0, -tailWidth / 2); | ||
} | ||
|
||
+ (CGAffineTransform)dqd_transformForStartPoint:(CGPoint)startPoint | ||
endPoint:(CGPoint)endPoint | ||
length:(CGFloat)length { | ||
CGFloat cosine = (endPoint.x - startPoint.x) / length; | ||
CGFloat sine = (endPoint.y - startPoint.y) / length; | ||
return (CGAffineTransform){ cosine, sine, -sine, cosine, startPoint.x, startPoint.y }; | ||
} | ||
|
||
- (CGAffineTransform)transformForStartPoint:(CGPoint)startPoint | ||
endPoint:(CGPoint)endPoint | ||
length:(CGFloat)length { | ||
CGFloat cosine = (endPoint.x - startPoint.x) / length; | ||
CGFloat sine = (endPoint.y - startPoint.y) / length; | ||
return (CGAffineTransform){ cosine, sine, -sine, cosine, startPoint.x, startPoint.y }; | ||
} | ||
|
||
#pragma mark - UIView | ||
|
||
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | ||
|
||
CGPathRef strokePath = CGPathCreateCopyByStrokingPath(self.shapeLayer.path, NULL, fmaxf(90.0f, self.shapeLayer.lineWidth), kCGLineCapRound,kCGLineJoinMiter,0); | ||
|
||
BOOL containsPoint = CGPathContainsPoint(strokePath, NULL, point, NO); | ||
|
||
CGPathRelease(strokePath); | ||
|
||
if (containsPoint){ | ||
return self; | ||
} else { | ||
return nil; | ||
} | ||
|
||
} | ||
|
||
- (void)layoutSubviews{ | ||
[super layoutSubviews]; | ||
|
||
[self buildShape]; | ||
} | ||
|
||
@end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.