]> git.saurik.com Git - cydia.git/commitdiff
Export cydia.setHidesNavigationBar() to JavaScript.
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 24 Feb 2011 04:30:11 +0000 (20:30 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 7 Mar 2011 10:41:13 +0000 (02:41 -0800)
MobileCydia.mm
UICaboodle/BrowserView.h
UICaboodle/BrowserView.mm

index 47517365e7c9a45b49b603478b252f6bb8ae3cdd..10fe44bf6feec8b029b8efbc92f3495fc7b28231 100644 (file)
@@ -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")
index 32ef3b4ac91558b7212ac167aa506c42b7a20b9d..f44e6bac0bb0c2bda0bd06796d5619a1c74ad386 100644 (file)
@@ -90,6 +90,9 @@
 
     UIBarButtonItem *reloaditem_;
     UIBarButtonItem *loadingitem_;
+
+    bool visible_;
+    bool hidesNavigationBar_;
 }
 
 + (void) _initialize;
 - (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;
index b4ca1a12fe6803daade5019c23453d7cfc1b3cf4..494dd695967d81c44d20b11f6c630dee28b601c6 100644 (file)
@@ -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