]>
Commit | Line | Data |
---|---|---|
819a0ab1 | 1 | /* Cydia - iPhone UIKit Front-End for Debian APT |
4c66fad9 | 2 | * Copyright (C) 2008-2015 Jay Freeman (saurik) |
819a0ab1 JF |
3 | */ |
4 | ||
6d9696a5 | 5 | /* GNU General Public License, Version 3 {{{ */ |
819a0ab1 | 6 | /* |
6d9696a5 JF |
7 | * Cydia is free software: you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published | |
9 | * by the Free Software Foundation, either version 3 of the License, | |
10 | * or (at your option) any later version. | |
819a0ab1 | 11 | * |
6d9696a5 JF |
12 | * Cydia is distributed in the hope that it will be useful, but |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
819a0ab1 | 16 | * |
6d9696a5 JF |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with Cydia. If not, see <http://www.gnu.org/licenses/>. | |
19 | **/ | |
819a0ab1 JF |
20 | /* }}} */ |
21 | ||
63755c48 | 22 | #include "CyteKit/UCPlatform.h" |
819a0ab1 JF |
23 | |
24 | #include <Foundation/Foundation.h> | |
25 | #include <UIKit/UIKit.h> | |
26 | ||
63755c48 JF |
27 | #include "CyteKit/ViewController.h" |
28 | ||
d32f96be | 29 | #include "iPhonePrivate.h" |
f8c9fd4c | 30 | #include <Menes/ObjectHandle.h> |
d32f96be | 31 | |
819a0ab1 JF |
32 | @implementation UIViewController (Cydia) |
33 | ||
34 | - (BOOL) hasLoaded { | |
35 | return YES; | |
36 | } | |
37 | ||
38 | - (void) reloadData { | |
ca629930 | 39 | [self view]; |
819a0ab1 JF |
40 | } |
41 | ||
42 | - (void) unloadData { | |
43 | if (UIViewController *modal = [self modalViewController]) | |
44 | [modal unloadData]; | |
45 | } | |
46 | ||
19f2d77f JF |
47 | - (UIViewController *) parentOrPresentingViewController { |
48 | if (UIViewController *parent = [self parentViewController]) | |
49 | return parent; | |
50 | if ([self respondsToSelector:@selector(presentingViewController)]) | |
51 | return [self presentingViewController]; | |
52 | return nil; | |
53 | } | |
54 | ||
7ccc1484 JF |
55 | - (NSURL *) navigationURL { |
56 | return nil; | |
57 | } | |
58 | ||
819a0ab1 JF |
59 | @end |
60 | ||
f8c9fd4c JF |
61 | @implementation CyteViewController { |
62 | _transient id delegate_; | |
63 | BOOL loaded_; | |
64 | _H<UIColor> color_; | |
65 | } | |
819a0ab1 JF |
66 | |
67 | - (void) setDelegate:(id)delegate { | |
68 | delegate_ = delegate; | |
69 | } | |
70 | ||
71 | - (id) delegate { | |
72 | return delegate_; | |
73 | } | |
74 | ||
75 | - (void) viewWillAppear:(BOOL)animated { | |
76 | [super viewWillAppear:animated]; | |
77 | ||
78 | // Load on first appearance. We don't need to set the loaded flag here | |
79 | // because it is set for us the first time -reloadData is called. | |
80 | if (![self hasLoaded]) | |
81 | [self reloadData]; | |
82 | } | |
83 | ||
84 | - (BOOL) hasLoaded { | |
85 | return loaded_; | |
86 | } | |
87 | ||
88 | - (void) releaseSubviews { | |
47a40da6 | 89 | loaded_ = NO; |
819a0ab1 JF |
90 | } |
91 | ||
92 | - (void) setView:(UIView *)view { | |
93 | // Nasty hack for 2.x-compatibility. In 3.0+, we can and | |
94 | // should just override -viewDidUnload instead. | |
95 | if (view == nil) | |
96 | [self releaseSubviews]; | |
97 | ||
98 | [super setView:view]; | |
99 | } | |
100 | ||
101 | - (void) reloadData { | |
102 | [super reloadData]; | |
103 | ||
104 | // This is called automatically on the first appearance of a controller, | |
105 | // or any other time it needs to reload the information shown. However (!), | |
106 | // this is not called by any tab bar or navigation controller's -reloadData | |
107 | // method unless this controller returns YES from -hadLoaded. | |
108 | loaded_ = YES; | |
109 | } | |
110 | ||
111 | - (void) unloadData { | |
112 | loaded_ = NO; | |
113 | [super unloadData]; | |
114 | } | |
115 | ||
d32f96be | 116 | - (void) setPageColor:(UIColor *)color { |
494216be | 117 | if (color == nil) |
d32f96be | 118 | color = [UIColor groupTableViewBackgroundColor]; |
494216be | 119 | color_ = color; |
d32f96be JF |
120 | } |
121 | ||
f8c9fd4c JF |
122 | - (UIColor *) pageColor { |
123 | return color_; | |
124 | } | |
125 | ||
3da96c86 JF |
126 | #include "InterfaceOrientation.h" |
127 | ||
819a0ab1 | 128 | @end |