summaryrefslogtreecommitdiff
path: root/CyteKit
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2017-03-04 20:18:40 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2017-03-04 20:18:40 -0800
commit217e22f0f4f84e74a3649d5e292c283b0c468b7f (patch)
tree829acf2e2906067ced0604f8d77aeb72cda285eb /CyteKit
parent60bd32466fcc4830ee8ff1774cd2e8d5bf390f4a (diff)
Move some code of Window/TabBarController to Cyte.
Diffstat (limited to 'CyteKit')
-rw-r--r--CyteKit/CyteKit.h1
-rw-r--r--CyteKit/TabBarController.h4
-rw-r--r--CyteKit/TabBarController.mm33
-rw-r--r--CyteKit/ViewController.h1
-rw-r--r--CyteKit/ViewController.mm7
-rw-r--r--CyteKit/Window.h33
-rw-r--r--CyteKit/Window.mm49
7 files changed, 121 insertions, 7 deletions
diff --git a/CyteKit/CyteKit.h b/CyteKit/CyteKit.h
index c25bc3f..53cef3c 100644
--- a/CyteKit/CyteKit.h
+++ b/CyteKit/CyteKit.h
@@ -29,6 +29,7 @@
#include "CyteKit/URLCache.h"
#include "CyteKit/WebViewController.h"
#include "CyteKit/WebViewTableViewCell.h"
+#include "CyteKit/Window.h"
#include "CyteKit/countByEnumeratingWithState.h"
#include "CyteKit/extern.h"
diff --git a/CyteKit/TabBarController.h b/CyteKit/TabBarController.h
index 2aa403c..220609c 100644
--- a/CyteKit/TabBarController.h
+++ b/CyteKit/TabBarController.h
@@ -26,12 +26,10 @@
#include <UIKit/UIKit.h>
-@interface UITabBarController (Cydia)
-@end
-
@interface CyteTabBarController : UITabBarController
- (NSArray *) navigationURLCollection;
+- (void) addViewControllers:(id)no, ...;
- (UIViewController *) unselectedViewController;
- (void) setUnselectedViewController:(UIViewController *)transient;
diff --git a/CyteKit/TabBarController.mm b/CyteKit/TabBarController.mm
index 35a2bd0..a6cd088 100644
--- a/CyteKit/TabBarController.mm
+++ b/CyteKit/TabBarController.mm
@@ -26,10 +26,6 @@
#include "iPhonePrivate.h"
#include <Menes/ObjectHandle.h>
-@implementation UITabBarController (Cydia)
-
-@end
-
@implementation CyteTabBarController {
_transient UIViewController *transient_;
_H<UIViewController> remembered_;
@@ -48,6 +44,35 @@
return items;
}
+- (void) addViewControllers:(id)no, ... {
+ va_list args;
+ va_start(args, no);
+
+ NSMutableArray *controllers([NSMutableArray array]);
+
+ for (;;) {
+ auto title(va_arg(args, NSString *));
+ if (title == nil)
+ break;
+
+ UINavigationController *controller([[[UINavigationController alloc] init] autorelease]);
+ [controllers addObject:controller];
+
+ auto legacy(va_arg(args, NSString *));
+ auto normal(va_arg(args, NSString *));
+ auto select(va_arg(args, NSString *));
+
+ if (kCFCoreFoundationVersionNumber < 800)
+ [controller setTabBarItem:[[[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:legacy] tag:0] autorelease]];
+ else
+ [controller setTabBarItem:[[[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:normal] selectedImage:[UIImage imageNamed:select]] autorelease]];
+ }
+
+ va_end(args);
+
+ [self setViewControllers:controllers];
+}
+
- (void) didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
diff --git a/CyteKit/ViewController.h b/CyteKit/ViewController.h
index 156f3cb..da4a33b 100644
--- a/CyteKit/ViewController.h
+++ b/CyteKit/ViewController.h
@@ -36,6 +36,7 @@
- (void) unloadData;
- (UIViewController *) parentOrPresentingViewController;
+- (UIViewController *) rootViewController;
// This URL is used to save the state of the view controller. Return
// nil if you cannot or should not save the URL for this page.
diff --git a/CyteKit/ViewController.mm b/CyteKit/ViewController.mm
index 28c7c43..41e7ea9 100644
--- a/CyteKit/ViewController.mm
+++ b/CyteKit/ViewController.mm
@@ -52,6 +52,13 @@
return nil;
}
+- (UIViewController *) rootViewController {
+ UIViewController *base(self);
+ while ([base parentOrPresentingViewController] != nil)
+ base = [base parentOrPresentingViewController];
+ return base;
+}
+
- (NSURL *) navigationURL {
return nil;
}
diff --git a/CyteKit/Window.h b/CyteKit/Window.h
new file mode 100644
index 0000000..c7224f7
--- /dev/null
+++ b/CyteKit/Window.h
@@ -0,0 +1,33 @@
+/* Cydia - iPhone UIKit Front-End for Debian APT
+ * Copyright (C) 2008-2015 Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cydia is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cydia is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#ifndef CyteKit_Window_H
+#define CyteKit_Window_H
+
+#include <UIKit/UIKit.h>
+
+@interface CyteWindow : UIWindow
+
+- (void) unloadData;
+
+@end
+
+#endif//CyteKit_Window_H
diff --git a/CyteKit/Window.mm b/CyteKit/Window.mm
new file mode 100644
index 0000000..4746e7c
--- /dev/null
+++ b/CyteKit/Window.mm
@@ -0,0 +1,49 @@
+/* Cydia - iPhone UIKit Front-End for Debian APT
+ * Copyright (C) 2008-2015 Jay Freeman (saurik)
+*/
+
+/* GNU General Public License, Version 3 {{{ */
+/*
+ * Cydia is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Cydia is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
+**/
+/* }}} */
+
+#include "CyteKit/UCPlatform.h"
+
+#include "CyteKit/ViewController.h"
+#include "CyteKit/Window.h"
+
+#include "iPhonePrivate.h"
+#include <Menes/ObjectHandle.h>
+
+@implementation CyteWindow {
+ _transient UIViewController *root_;
+}
+
+- (void) setRootViewController:(UIViewController *)controller {
+ if ([super respondsToSelector:@selector(setRootViewController:)])
+ [super setRootViewController:controller];
+ else {
+ [self addSubview:[controller view]];
+ [[root_ view] removeFromSuperview];
+ }
+
+ root_ = controller;
+}
+
+- (void) unloadData {
+ [root_ unloadData];
+}
+
+@end