Skip to content

Commit

Permalink
* Ability to zoom the photo view controller to fit, and detect when i…
Browse files Browse the repository at this point in the history
…t is zoomed

* New badge variation with smaller font size
  • Loading branch information
joehewitt committed Jun 4, 2009
1 parent 1a71688 commit b789448
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
14 changes: 11 additions & 3 deletions src/TTDefaultStyleSheet.m
Expand Up @@ -181,19 +181,27 @@ - (TTStyle*)whiteBezel {
[TTSolidBorderStyle styleWithColor:RGBCOLOR(178, 178, 178) width:1 next:nil]]];
}

- (TTStyle*)badge {
- (TTStyle*)badgeWithFontSize:(CGFloat)fontSize {
return
[TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:TT_ROUNDED] next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(1, 1, 1, 1) next:
[TTShadowStyle styleWithColor:RGBACOLOR(0,0,0,1) blur:3 offset:CGSizeMake(0, 4) next:
[TTReflectiveFillStyle styleWithColor:RGBCOLOR(221, 17, 27) next:
[TTInsetStyle styleWithInset:UIEdgeInsetsMake(-1, -1, -1, -1) next:
[TTSolidBorderStyle styleWithColor:[UIColor whiteColor] width:2 next:
[TTBoxStyle styleWithPadding:UIEdgeInsetsMake(1, 6, 3, 6) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:13]
[TTBoxStyle styleWithPadding:UIEdgeInsetsMake(2, 7, 2, 7) next:
[TTTextStyle styleWithFont:[UIFont boldSystemFontOfSize:fontSize]
color:[UIColor whiteColor] next:nil]]]]]]]];
}

- (TTStyle*)miniBadge {
return [self badgeWithFontSize:12];
}

- (TTStyle*)badge {
return [self badgeWithFontSize:15];
}

- (TTStyle*)tabBar {
UIColor* border = [TTSTYLEVAR(tabBarTintColor) multiplyHue:0 saturation:0 value:0.7];
return
Expand Down
14 changes: 9 additions & 5 deletions src/TTScrollView.m
Expand Up @@ -102,10 +102,6 @@ - (BOOL)pulled {
return _pageEdges.left > 0 || _pageEdges.top > 0 || _pageEdges.right < 0 || _pageEdges.bottom < 0;
}

- (BOOL)zoomed {
return _pageEdges.left != _pageEdges.right || _pageEdges.top != _pageEdges.bottom;
}

- (BOOL)flicked {
if (!self.flipped) {
if (_pageEdges.left > kFlickThreshold && ![self isFirstPage]) {
Expand Down Expand Up @@ -996,7 +992,7 @@ - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
} else if (touch.tapCount == 2 && self.canZoom) {
CGPoint pt = [self touchLocation:touch];
if (self.zoomed) {
[self startAnimationTo:[self reversePageEdges] duration:kFlickDuration];
[self zoomToFit];
} else {
[self startAnimationTo:[self zoomPageEdgesTo:pt] duration:kFlickDuration];
}
Expand Down Expand Up @@ -1029,6 +1025,10 @@ - (void)deviceOrientationDidChange:(void*)object {

///////////////////////////////////////////////////////////////////////////////////////////////////

- (BOOL)zoomed {
return _pageEdges.left != _pageEdges.right || _pageEdges.top != _pageEdges.bottom;
}

- (void)setDataSource:(id<TTScrollViewDataSource>)dataSource {
_dataSource = dataSource;
[self reloadData];
Expand Down Expand Up @@ -1132,4 +1132,8 @@ - (UIView*)pageAtIndex:(NSInteger)pageIndex {
return [self pageAtIndex:pageIndex create:NO];
}

- (void)zoomToFit {
[self startAnimationTo:[self reversePageEdges] duration:kFlickDuration];
}

@end
1 change: 1 addition & 0 deletions src/Three20/TTDefaultStyleSheet.h
Expand Up @@ -55,4 +55,5 @@

- (TTStyle*)selectionFillStyle:(TTStyle*)next;


@end
10 changes: 10 additions & 0 deletions src/Three20/TTScrollView.h
Expand Up @@ -50,6 +50,11 @@
*/
@property(nonatomic) NSInteger centerPageIndex;

/**
*
*/
@property(nonatomic,readonly) BOOL zoomed;

/**
*
*/
Expand Down Expand Up @@ -107,6 +112,11 @@
*/
- (UIView*)pageAtIndex:(NSInteger)pageIndex;

/**
*
*/
- (void)zoomToFit;

@end

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit b789448

Please sign in to comment.