Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 155 lines (126 sloc) 5.625 kB
180bc04 @ettore rename categories to a more standard naming convention, and CLCGTVVC …
authored
1 // Copyright (c) 2012, Ettore Pasquini
2 // Copyright (c) 2012, Cubelogic
3 // All rights reserved.
489dc7f @ettore a base vc that handles spinny wheel
authored
4 //
180bc04 @ettore rename categories to a more standard naming convention, and CLCGTVVC …
authored
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // - Redistributions of source code must retain the above copyright notice, this
9 // list of conditions and the following disclaimer.
10 // - Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
489dc7f @ettore a base vc that handles spinny wheel
authored
25 //
26 // Created by Ettore Pasquini on 5/4/11.
27 //
28
29 #import <UIKit/UIKit.h>
30
31
1df740a @ettore moved loadState to CLCGVC
authored
32 enum CLCGLoadingState {
33 CLCG_NOT_LOADED,
34 CLCG_LOADING,
35 CLCG_LOADED,
36 CLCG_OUTDATED,
37 CLCG_LOAD_ERROR,
38 };
39
40
ba58bec @ettore add showErrorMessage method
authored
41 /*!
bd607f4 @ettore Centered spinner and added fixes for usage as popover.
authored
42 * If your CLCGVC view controller is presented as content inside of a
43 * UIPopoverController, and you want to be notified when the user
44 * performs an action inside your content view controller (such as hitting a
45 * button that should close the popover programmatically), then you can use
46 * this delegate to let (e.g.) the parent object that opened the popover
47 * know that it is now time to dismiss it. This is because when you close
48 * a popover programmatically (UIPopoverController::dismissPopoverAnimated:)
49 * the UIPopoverControllerDelegate::popoverControllerDidDismissPopover:
50 * method is not called.
51 *
52 * TODO: perhaps it'd be cleaner to extend UIPopoverController and have a new
53 * method to UIPopoverControllerDelegate. (It might be dangerous to change the
54 * behavior of UIPopoverController::dismissPopoverAnimated: and call
55 * popoverControllerDidDismissPopover: on the delegate.)
56 */
57 @protocol CLCGPopoverContentDelegate
58 -(void)didInvokeDismissAction:(UIViewController*)vc_in_popover;
ad18ddc @ettore add popoverContentSizeDidChange: to CLCGPopoverContentDelegate protocol
authored
59 -(void)popoverContentSizeDidChange:(CGSize)size;
bd607f4 @ettore Centered spinner and added fixes for usage as popover.
authored
60 @end
61
62
489dc7f @ettore a base vc that handles spinny wheel
authored
63 @interface CLCGVC : UIViewController
3b546c6 @ettore added way of displaying empty (or error) message in the middle of the…
authored
64
d5e5b23 @ettore add ability to show some text in loading view
authored
65 //------------------------------------------------------------------------------
66 #pragma mark - Loading logic
67
9328ea2 @ettore convert all files to ARC
authored
68 /*!
871ec71 @ettore comments
authored
69 Subclasses should set the loading state accordingly, before/during/after
70 loading content, depending what loading means in each VC. E.g. it should be
71 set to CLCG_LOADED even if there was no api call being performed.
72 */
1df740a @ettore moved loadState to CLCGVC
authored
73 @property(nonatomic,assign) enum CLCGLoadingState loadState;
871ec71 @ettore comments
authored
74
d5e5b23 @ettore add ability to show some text in loading view
authored
75 /*!
76 @discussion Subclasses should override this method and initiate here any
77 asynchronous server side call. The default implementation does nothing.
78 */
79 -(void)loadFromServerIfNeeded;
80
81
82 /*! Forces a reload from the server. */
83 -(void)reload;
84
85 //------------------------------------------------------------------------------
86 #pragma mark - Loading view / Spinner
87
180bc04 @ettore rename categories to a more standard naming convention, and CLCGTVVC …
authored
88 @property(nonatomic,strong) IBOutlet UIView *spinnerContainer;
89 @property(nonatomic,strong) IBOutlet UIActivityIndicatorView *spinner;
58c5d7e @ettore Refactored CLCGVC to create its own activity indicator, with some con…
authored
90 @property(nonatomic) UIActivityIndicatorViewStyle spinnerStyle;
180bc04 @ettore rename categories to a more standard naming convention, and CLCGTVVC …
authored
91 @property(nonatomic,strong) UIColor *spinnerBackgroundColor;
92 @property(nonatomic,strong) IBOutlet UILabel *spinnerLabel1;
93 @property(nonatomic,strong) IBOutlet UILabel *spinnerLabel2;
d5e5b23 @ettore add ability to show some text in loading view
authored
94
ba58bec @ettore add showErrorMessage method
authored
95 /*!
d5e5b23 @ettore add ability to show some text in loading view
authored
96 * If show == YES, shows and aligns the spinny indicator to the center
97 * of the screen.
98 * If show == NO, removes the spinny indicator if it was displayed, or do
99 * nothing otherwise.
100 */
101 -(void)showLoadingView:(BOOL)show;
102
103 //------------------------------------------------------------------------------
a97af1b @ettore clean up previous error/empty states when when (re)loading
authored
104 #pragma mark - Displaying empty or error states
d5e5b23 @ettore add ability to show some text in loading view
authored
105
ba58bec @ettore add showErrorMessage method
authored
106 /*!
107 The container that contains the empty or error messages, as well as the
108 Tap to Reload label in the latter case. This view spans the whole screen.
109 */
180bc04 @ettore rename categories to a more standard naming convention, and CLCGTVVC …
authored
110 @property(nonatomic,strong) IBOutlet UIView *emptyContainer;
ba58bec @ettore add showErrorMessage method
authored
111
112 /*!
113 Label that displays the message for empty case (no data or error).
114 */
180bc04 @ettore rename categories to a more standard naming convention, and CLCGTVVC …
authored
115 @property(nonatomic,strong) IBOutlet UILabel *emptyLabel;
3b546c6 @ettore added way of displaying empty (or error) message in the middle of the…
authored
116
ba58bec @ettore add showErrorMessage method
authored
117 /*!
3b546c6 @ettore added way of displaying empty (or error) message in the middle of the…
authored
118 * If msg is non-nil, this method shows and aligns the given message to the
119 * center of the screen. Otherwise, it removes the message if it was displayed.
120 */
121 -(void)showEmptyMessage:(NSString*)msg;
122
ba58bec @ettore add showErrorMessage method
authored
123 /*!
124 * If msg is non-nil, this method shows and aligns the given message to the
125 * center of the screen. Otherwise, it removes the message if it was displayed.
126 * It also displays a Tap to Reload label.
127 */
128 -(void)showErrorMessage:(NSString*)msg;
129
130 /*!
131 This method creates the view to render the message for no data/error case.
132 */
133 -(void)createEmptyView;
134
135 /*!
136 Aligns the empty label to the center of the emptyContainer.
137 */
138 -(void)centerEmptyView;
139
d5e5b23 @ettore add ability to show some text in loading view
authored
140 //------------------------------------------------------------------------------
141 #pragma mark - Misc
3b546c6 @ettore added way of displaying empty (or error) message in the middle of the…
authored
142
d5e5b23 @ettore add ability to show some text in loading view
authored
143 @property(nonatomic,weak) id<CLCGPopoverContentDelegate> popoverContentDelegate;
49ef5b2 @ettore add explicit method to reload from server
authored
144
ba58bec @ettore add showErrorMessage method
authored
145 /*!
9458c25 @ettore added releaseRetainedSubviews method, called in dealloc and viewDidUn…
authored
146 * Releases all the retained subviews of this view controller. This is called
147 * by dealloc and viewDidUnload.
148 * Subclasses should override this method and release their subviews here.
149 */
150 -(void)releaseRetainedSubviews;
151
a13675f @ettore `some comments
authored
152
489dc7f @ettore a base vc that handles spinny wheel
authored
153 @end
a13675f @ettore `some comments
authored
154
Something went wrong with that request. Please try again.