X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/0470069371352de4f0b448ea31c0984a8cbdc9d7..66abcbb0a2e423cce98c3aeb541b1d609fc8f7fa:/UICaboodle/RVBook.mm diff --git a/UICaboodle/RVBook.mm b/UICaboodle/RVBook.mm index b1bbce67..29e9513b 100644 --- a/UICaboodle/RVBook.mm +++ b/UICaboodle/RVBook.mm @@ -121,6 +121,10 @@ delegate_ = delegate; } +- (void) setHook:(id)hook { + hook_ = hook; +} + - (void) setPage:(RVPage *)page { if ([pages_ count] != 0) [[pages_ lastObject] setPageActive:NO]; @@ -135,10 +139,22 @@ [navbar_ enableAnimation]; } -- (void) pushPage:(RVPage *)page { - if ([pages_ count] != 0) - [[pages_ lastObject] setPageActive:NO]; +- (void) swapPage:(RVPage *)page { + if ([pages_ count] == 0) + return [self pushPage:page]; + + [[pages_ lastObject] setPageActive:NO]; + + [navbar_ disableAnimation]; + resetting_ = true; + [navbar_ popNavigationItem]; + resetting_ = false; + + [self pushPage:page animated:NO]; + [navbar_ enableAnimation]; +} +- (void) pushPage:(RVPage *)page animated:(BOOL)animated { NSString *title = [self getTitleForPage:page]; NSString *backButtonTitle = [page backButtonTitle]; @@ -149,7 +165,6 @@ [navitem setBackButtonTitle:backButtonTitle]; [navbar_ pushNavigationItem:navitem]; - BOOL animated = [pages_ count] == 0 ? NO : YES; [page setFrame:[transition_ bounds]]; [transition_ transition:(animated ? 1 : 0) toView:page]; [page setPageActive:YES]; @@ -160,6 +175,12 @@ [navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO]; } +- (void) pushPage:(RVPage *)page { + if ([pages_ count] != 0) + [[pages_ lastObject] setPageActive:NO]; + [self pushPage:page animated:([pages_ count] == 0 ? NO : YES)]; +} + - (void) pushBook:(RVBook *)book { [delegate_ popUpBook:book]; } @@ -220,15 +241,19 @@ [navitem setTitle:title]; } -- (NSString *) _leftButtonTitleForPage:(RVPage *)page { - return [page leftButtonTitle]; +- (void) _leftButtonTitle:(NSString *&)leftButtonTitle style:(UINavigationButtonStyle &)leftButtonStyle forPage:(RVPage *)page { + leftButtonTitle = [page leftButtonTitle]; + leftButtonStyle = [page leftButtonStyle]; } - (void) reloadButtonsForPage:(RVPage *)page { if ([pages_ count] == 0 || page != [pages_ lastObject]) return; - NSString *leftButtonTitle([self _leftButtonTitleForPage:page]); - UINavigationButtonStyle leftButtonStyle = [page leftButtonStyle]; + + NSString *leftButtonTitle; + UINavigationButtonStyle leftButtonStyle; + [self _leftButtonTitle:leftButtonTitle style:leftButtonStyle forPage:page]; + UINavigationButtonStyle rightButtonStyle = [page rightButtonStyle]; //[navbar_ showButtonsWithLeftTitle:leftButtonTitle rightTitle:[page rightButtonTitle] leftBack:(leftButtonTitle == nil)]; @@ -245,10 +270,16 @@ } - (void) reloadData { - for (int i(0), e([pages_ count]); i != e; ++i) { - RVPage *page([pages_ objectAtIndex:(e - i - 1)]); + size_t count([pages_ count]); + for (size_t i(0); i != count; ++i) { + RVPage *page([pages_ objectAtIndex:(count - i - 1)]); [page reloadData]; } + + if (count != 0) { + RVPage *page([pages_ lastObject]); + [self reloadButtonsForPage:page]; + } } - (CGRect) pageBounds { @@ -256,15 +287,20 @@ } - (void) close { + if (hook_ != nil) + [hook_ didCloseBook:self]; } @end @implementation RVPopUpBook -- (NSString *) _leftButtonTitleForPage:(RVPage *)page { - NSString *title([super _leftButtonTitleForPage:page]); - return (cancel_ = title == nil && [pages_ count] == 1) ? @"Cancel" : title; +- (void) _leftButtonTitle:(NSString *&)leftButtonTitle style:(UINavigationButtonStyle &)leftButtonStyle forPage:(RVPage *)page { + [super _leftButtonTitle:leftButtonTitle style:leftButtonStyle forPage:page]; + if ((cancel_ = leftButtonTitle == nil && [pages_ count] == 1)) { + leftButtonTitle = [[NSBundle mainBundle] localizedStringForKey:@"CANCEL" value:nil table:nil]; + leftButtonStyle = UINavigationButtonStyleNormal; + } } - (void) navigationBar:(UINavigationBar *)navbar buttonClicked:(int)button { @@ -276,6 +312,7 @@ - (void) close { [self popFromSuperviewAnimated:YES]; + [super close]; } @end