summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-02-23 20:30:11 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-07 02:41:13 -0800
commit5cdfcd6ff1223d3200b8f8a051b07f137e353604 (patch)
treec89dc338739d2c28d2f771b1a5ed558ca559c56d
parent3c62d6548fe3f893f4e90bce73b2463cef8faccd (diff)
Export cydia.setHidesNavigationBar() to JavaScript.
-rw-r--r--MobileCydia.mm24
-rw-r--r--UICaboodle/BrowserView.h4
-rw-r--r--UICaboodle/BrowserView.mm36
3 files changed, 44 insertions, 20 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 4751736..10fe44b 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -4122,6 +4122,8 @@ static NSString *Warning_;
return @"setButtonTitle";
else if (selector == @selector(setHidesBackButton:))
return @"setHidesBackButton";
+ else if (selector == @selector(setHidesNavigationBar:))
+ return @"setHidesNavigationBar";
else if (selector == @selector(setNavigationBarStyle:))
return @"setNavigationBarStyle";
else if (selector == @selector(setPopupHook:))
@@ -4292,6 +4294,10 @@ static NSString *Warning_;
[indirect_ performSelectorOnMainThread:@selector(setHidesBackButtonByNumber:) withObject:value waitUntilDone:NO];
}
+- (void) setHidesNavigationBar:(NSString *)value {
+ [indirect_ performSelectorOnMainThread:@selector(setHidesNavigationBarByNumber:) withObject:value waitUntilDone:NO];
+}
+
- (void) setNavigationBarStyle:(NSString *)value {
[indirect_ performSelectorOnMainThread:@selector(setNavigationBarStyle:) withObject:value waitUntilDone:NO];
}
@@ -6414,10 +6420,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
@implementation HomeController
-+ (BOOL) shouldHideNavigationBar {
- return NO;
-}
-
- (id) init {
if ((self = [super init]) != nil) {
[self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/home/", UI_]]];
@@ -6456,20 +6458,6 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
[alert show];
}
-- (void) viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-
- if ([[self class] shouldHideNavigationBar])
- [[self navigationController] setNavigationBarHidden:NO animated:animated];
-}
-
-- (void) viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- if ([[self class] shouldHideNavigationBar])
- [[self navigationController] setNavigationBarHidden:YES animated:animated];
-}
-
- (void) viewDidLoad {
[[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc]
initWithTitle:UCLocalize("ABOUT")
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h
index 32ef3b4..f44e6ba 100644
--- a/UICaboodle/BrowserView.h
+++ b/UICaboodle/BrowserView.h
@@ -90,6 +90,9 @@
UIBarButtonItem *reloaditem_;
UIBarButtonItem *loadingitem_;
+
+ bool visible_;
+ bool hidesNavigationBar_;
}
+ (void) _initialize;
@@ -120,6 +123,7 @@
- (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function;
- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function;
- (void) setPopupHook:(id)function;
+- (void) setHidesNavigationBar:(bool)value;
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button;
- (void) customButtonClicked;
diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm
index b4ca1a1..494dd69 100644
--- a/UICaboodle/BrowserView.mm
+++ b/UICaboodle/BrowserView.mm
@@ -820,6 +820,8 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
function_ = nil;
CYRelease(closer_);
+ [self setHidesNavigationBar:NO];
+
// XXX: do we still need to do this?
[[self navigationItem] setTitle:nil];
}
@@ -1211,24 +1213,54 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se
}
}
+- (bool) hidesNavigationBar {
+ return hidesNavigationBar_;
+}
+
+- (void) _setHidesNavigationBar:(bool)value animated:(bool)animated {
+ if (visible_)
+ [[self navigationController] setNavigationBarHidden:(value && [self hidesNavigationBar]) animated:animated];
+}
+
+- (void) setHidesNavigationBar:(bool)value {
+ if (hidesNavigationBar_ != value) {
+ hidesNavigationBar_ = value;
+ [self _setHidesNavigationBar:YES animated:YES];
+ }
+}
+
+- (void) setHidesNavigationBarByNumber:(NSNumber *)value {
+ [self setHidesNavigationBar:[value boolValue]];
+}
+
- (void) viewWillAppear:(BOOL)animated {
+ visible_ = true;
+
+ if ([self hidesNavigationBar])
+ [self _setHidesNavigationBar:YES animated:animated];
+
[self dispatchEvent:@"CydiaViewWillAppear"];
[super viewWillAppear:animated];
}
- (void) viewDidAppear:(BOOL)animated {
- [self dispatchEvent:@"CydiaViewDidAppear"];
[super viewDidAppear:animated];
+ [self dispatchEvent:@"CydiaViewDidAppear"];
}
- (void) viewWillDisappear:(BOOL)animated {
[self dispatchEvent:@"CydiaViewWillDisappear"];
[super viewWillDisappear:animated];
+
+ if ([self hidesNavigationBar])
+ [self _setHidesNavigationBar:NO animated:animated];
+
+ visible_ = false;
}
- (void) viewDidDisappear:(BOOL)animated {
- [self dispatchEvent:@"CydiaViewDidDisappear"];
[super viewDidDisappear:animated];
+ [self dispatchEvent:@"CydiaViewDidDisappear"];
}
@end