Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod: Ensure We Account For Odd Number Of Images When Finding Center #280

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions TapkuLibrary.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TapkuLibrary'
s.version = '0.3.6'
s.version = '0.3.8'
s.platform = :ios
s.author = { 'Devin Ross' => 'devin@devinsheaven.com' }
s.license = { :type => 'MIT', :file => 'License.txt' }
Expand All @@ -15,4 +15,4 @@ Pod::Spec.new do |s|
s.source_files = 'src/TapkuLibrary/*.{h,m}'
s.resources = 'src/TapkuLibrary.bundle'
s.frameworks = 'QuartzCore'
end
end
45 changes: 39 additions & 6 deletions src/TapkuLibrary/TKAlertCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ - (void) showAlerts{

UIInterfaceOrientation o = [UIApplication sharedApplication].statusBarOrientation;
CGFloat degrees = 0;
if(o == UIInterfaceOrientationLandscapeLeft ) degrees = -90;
else if(o == UIInterfaceOrientationLandscapeRight ) degrees = 90;
else if(o == UIInterfaceOrientationPortraitUpsideDown) degrees = 180;
if([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending) {
if (o == UIInterfaceOrientationLandscapeLeft) degrees = -90;
else if (o == UIInterfaceOrientationLandscapeRight) degrees = 90;
else if (o == UIInterfaceOrientationPortraitUpsideDown) degrees = 180;
}
_alertView.transform = CGAffineTransformMakeRotation(degrees * M_PI / 180);
_alertView.transform = CGAffineTransformScale(_alertView.transform, 2, 2);

Expand Down Expand Up @@ -222,9 +224,11 @@ - (void) animationStep2{

UIInterfaceOrientation o = [UIApplication sharedApplication].statusBarOrientation;
CGFloat degrees = 0;
if(o == UIInterfaceOrientationLandscapeLeft ) degrees = -90;
else if(o == UIInterfaceOrientationLandscapeRight ) degrees = 90;
else if(o == UIInterfaceOrientationPortraitUpsideDown) degrees = 180;
if([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending) {
if (o == UIInterfaceOrientationLandscapeLeft) degrees = -90;
else if (o == UIInterfaceOrientationLandscapeRight) degrees = 90;
else if (o == UIInterfaceOrientationPortraitUpsideDown) degrees = 180;
}
_alertView.transform = CGAffineTransformMakeRotation(degrees * M_PI / 180);
_alertView.transform = CGAffineTransformScale(_alertView.transform, 0.5, 0.5);

Expand All @@ -239,6 +243,9 @@ - (void) animationStep3{

}
- (void) postAlertWithMessage:(NSString*)message image:(UIImage*)image{
if ([self isAlreadyShowingAlertForMessage:message image:image])
return;

if(message && image)
[_alerts addObject:@[message,image]];
else if(message)
Expand All @@ -251,6 +258,32 @@ - (void) postAlertWithMessage:(NSString*)message{
[self postAlertWithMessage:message image:nil];
}

-(Boolean) isAlreadyShowingAlertForMessage:(NSString *) message image:(UIImage *) image {
Boolean imageSame = NO;
Boolean messageSame = NO;
for (NSArray *alert in _alerts) {
NSString *alertMessage;
UIImage *alertImage;

alertMessage = alert[0];
if (alert.count == 2) {
alertImage = alert[1];
}

messageSame = ([message isEqualToString:alertMessage]);
if (messageSame) {
if (image && alertImage) {
imageSame = (image.size.width == alertImage.size.width &&
image.size.height == alertImage.size.height);
} else if (!image && !alertImage)
imageSame = YES;
}
if (imageSame && messageSame)
break;
}

return (imageSame && messageSame);
}

#pragma mark System Observation Changes
CGRect subtractRect(CGRect wf,CGRect kf);
Expand Down
6 changes: 3 additions & 3 deletions src/TapkuLibrary/TKCoverflowView.m
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ - (NSInteger) _calculatedIndexWithContentOffset:(CGPoint)point{

CGFloat per = point.x / self.contentSize.width;
CGFloat ind = _numberOfCovers * per;
CGFloat mi = ind / (_numberOfCovers/2);
CGFloat mi = ind / (_numberOfCovers/2.0);
mi = 1 - mi;
mi = mi / 2;
mi = mi / 2.0;
NSInteger index = (int)(ind+mi);

index = MIN(MAX(0,index),_numberOfCovers-1);
Expand Down Expand Up @@ -513,4 +513,4 @@ - (void) setImage:(UIImage*)image{
self.reflectedImageView.image = image;
}

@end
@end