X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/0a7e54786d6b4ee83a954e854825ef1892058b12..85021801a704792e919d95b289260b224ea43404:/UICaboodle/RVBook.mm diff --git a/UICaboodle/RVBook.mm b/UICaboodle/RVBook.mm index b639958b..18de2b6d 100644 --- a/UICaboodle/RVBook.mm +++ b/UICaboodle/RVBook.mm @@ -65,6 +65,9 @@ if (toolbar_ != nil) [toolbar_ setDelegate:nil]; + for (RVPage *page in pages_) + [page setBook:nil]; + [pages_ release]; [navbar_ release]; [transition_ release]; @@ -121,6 +124,10 @@ delegate_ = delegate; } +- (void) setHook:(id)hook { + hook_ = hook; +} + - (void) setPage:(RVPage *)page { if ([pages_ count] != 0) [[pages_ lastObject] setPageActive:NO]; @@ -135,10 +142,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 +168,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]; @@ -157,7 +175,16 @@ [pages_ addObject:page]; [self reloadButtonsForPage:page]; - [navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO]; + if ([navbar_ respondsToSelector:@selector(setAccessoryView:animate:removeOnPop:)]) + [navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO]; + else + [navbar_ setAccessoryView:[page accessoryView] animate:animated]; +} + +- (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 { @@ -202,7 +229,10 @@ [page setPageActive:YES]; [self reloadButtonsForPage:page]; - [navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO]; + if ([navbar_ respondsToSelector:@selector(setAccessoryView:animate:removeOnPop:)]) + [navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO]; + else + [navbar_ setAccessoryView:[page accessoryView] animate:animated]; } - (void) setBackButtonTitle:(NSString *)title forPage:(RVPage *)page { @@ -249,10 +279,24 @@ } - (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]; + } +} + +- (void) reloadButtons { + size_t count([pages_ count]); + if (count != 0) { + RVPage *page([pages_ lastObject]); + [self reloadButtonsForPage:page]; + } } - (CGRect) pageBounds { @@ -260,6 +304,8 @@ } - (void) close { + if (hook_ != nil) + [hook_ didCloseBook:self]; } @end @@ -269,7 +315,7 @@ - (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 = @"Cancel"; + leftButtonTitle = [[NSBundle mainBundle] localizedStringForKey:@"CANCEL" value:nil table:nil]; leftButtonStyle = UINavigationButtonStyleNormal; } } @@ -283,6 +329,7 @@ - (void) close { [self popFromSuperviewAnimated:YES]; + [super close]; } @end