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

Fix media queries issue for the index / add fullscreen capability #31

Open
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BakerView/BakerBook.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
@property (copy, nonatomic) NSNumber *bakerPageTurnSwipe;
@property (copy, nonatomic) NSNumber *bakerMediaAutoplay;

@property (copy, nonatomic) NSNumber *bakerIndexFullscreen;
@property (copy, nonatomic) NSNumber *bakerIndexWidth;
@property (copy, nonatomic) NSNumber *bakerIndexHeight;
@property (copy, nonatomic) NSNumber *bakerIndexBounce;
Expand Down
7 changes: 7 additions & 0 deletions BakerView/BakerBook.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ @implementation BakerBook
@synthesize bakerPageTurnSwipe;
@synthesize bakerMediaAutoplay;

@synthesize bakerIndexFullscreen;
@synthesize bakerIndexWidth;
@synthesize bakerIndexHeight;
@synthesize bakerIndexBounce;
Expand Down Expand Up @@ -198,6 +199,7 @@ - (BOOL)loadBookData:(NSDictionary *)bookData
self.bakerPageTurnSwipe = [bookData objectForKey:@"-baker-page-turn-swipe"];
self.bakerMediaAutoplay = [bookData objectForKey:@"-baker-media-autoplay"];

self.bakerIndexFullscreen = [bookData objectForKey:@"-baker-index-fullscreen"];
self.bakerIndexWidth = [bookData objectForKey:@"-baker-index-width"];
self.bakerIndexHeight = [bookData objectForKey:@"-baker-index-height"];
self.bakerIndexBounce = [bookData objectForKey:@"-baker-index-bounce"];
Expand Down Expand Up @@ -247,6 +249,9 @@ - (void)loadBookJSONDefault
if (self.bakerIndexBounce == nil) {
self.bakerIndexBounce = [NSNumber numberWithBool:NO];
}
if (self.bakerIndexFullscreen == nil) {
self.bakerIndexFullscreen = [NSNumber numberWithBool:NO];
}
if (self.bakerStartAtPage == nil) {
self.bakerStartAtPage = [NSNumber numberWithInt:1];
}
Expand Down Expand Up @@ -363,6 +368,7 @@ - (BOOL)validateNumber:(NSNumber *)number forParam:(NSString *)param
@"-baker-page-turn-tap",
@"-baker-page-turn-swipe",
@"-baker-media-autoplay",
@"-baker-index-fullscreen",
@"-baker-index-width",
@"-baker-index-height",
@"-baker-index-bounce",
Expand Down Expand Up @@ -461,6 +467,7 @@ - (void)dealloc
[bakerPageTurnSwipe release];
[bakerMediaAutoplay release];

[bakerIndexFullscreen release];
[bakerIndexWidth release];
[bakerIndexHeight release];
[bakerIndexBounce release];
Expand Down
2 changes: 2 additions & 0 deletions BakerView/IndexViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
int actualIndexWidth;
int actualIndexHeight;

BOOL fullscreen;
BOOL disabled;
BOOL loadedFromBundle;

Expand All @@ -59,6 +60,7 @@
- (void)setBounceForWebView:(UIWebView *)webView bounces:(BOOL)bounces;
- (void)setPageSizeForOrientation:(UIInterfaceOrientation)orientation;
- (BOOL)isIndexViewHidden;
- (BOOL)isFullscreen;
- (BOOL)isDisabled;
- (void)setIndexViewHidden:(BOOL)hidden withAnimation:(BOOL)animation;
- (void)willRotate;
Expand Down
44 changes: 30 additions & 14 deletions BakerView/IndexViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ - (id)initWithBook:(BakerBook *)bakerBook fileName:(NSString *)name webViewDeleg
webViewDelegate = delegate;

disabled = NO;
fullscreen = [self isFullscreen];
indexWidth = 0;
indexHeight = 0;

Expand Down Expand Up @@ -105,14 +106,24 @@ - (void)setPageSizeForOrientation:(UIInterfaceOrientation)orientation {
}

- (void)setActualSize {
actualIndexWidth = MIN(indexWidth, pageWidth);
actualIndexHeight = MIN(indexHeight, pageHeight);
if (fullscreen) {
actualIndexWidth = pageWidth;
actualIndexHeight = pageHeight;
} else {
actualIndexWidth = MIN(indexWidth, pageWidth);
actualIndexHeight = MIN(indexHeight, pageHeight);
}

}

- (BOOL)isIndexViewHidden {
return [UIApplication sharedApplication].statusBarHidden;
}

- (BOOL)isFullscreen {
return (BOOL)[book.bakerIndexFullscreen boolValue];
}

- (BOOL)isDisabled {
return disabled;
}
Expand All @@ -129,7 +140,7 @@ - (void)setIndexViewHidden:(BOOL)hidden withAnimation:(BOOL)animation {
if ([self stickToLeft]) {
frame = CGRectMake(0, [self trueY] + pageHeight - actualIndexHeight, actualIndexWidth, actualIndexHeight);
} else {
frame = CGRectMake(0, [self trueY] + pageHeight - indexHeight, actualIndexWidth, actualIndexHeight);
frame = CGRectMake(0, [self trueY] + pageHeight - actualIndexHeight, actualIndexWidth, actualIndexHeight);
}

}
Expand Down Expand Up @@ -221,18 +232,20 @@ - (void)loadContent {
}
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
id width = book.bakerIndexWidth;
id height = book.bakerIndexHeight;
if (!fullscreen) {
id width = book.bakerIndexWidth;
id height = book.bakerIndexHeight;

if (width != nil) {
indexWidth = (int)[width integerValue];
} else {
indexWidth = [self sizeFromContentOf:webView].width;
}
if (height != nil) {
indexHeight = (int)[height integerValue];
} else {
indexHeight = [self sizeFromContentOf:webView].height;
if (width != nil) {
indexWidth = (int)[width integerValue];
} else {
indexWidth = [self sizeFromContentOf:webView].width;
}
if (height != nil) {
indexHeight = (int)[height integerValue];
} else {
indexHeight = [self sizeFromContentOf:webView].height;
}
}

cachedContentSize = indexScrollView.contentSize;
Expand All @@ -251,6 +264,9 @@ -(void)webViewDidFinishLoad:(UIWebView *)webView {
}

- (BOOL)stickToLeft {
if (fullscreen) {
return NO;
}
return (actualIndexHeight > actualIndexWidth);
}

Expand Down