This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
/
TTGlobalUICommon.h
202 lines (164 loc) · 5.56 KB
/
TTGlobalUICommon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//
// Copyright 2009-2011 Facebook
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/**
* @return the current runtime version of the iPhone OS.
*/
float TTOSVersion();
/**
* Checks if the link-time version of the OS is at least a certain version.
*/
BOOL TTOSVersionIsAtLeast(float version);
/**
* @return TRUE if the keyboard is visible.
*/
BOOL TTIsKeyboardVisible();
/**
* @return TRUE if the device has phone capabilities.
*/
BOOL TTIsPhoneSupported();
/**
* @return TRUE if the device is iPad.
*/
BOOL TTIsPad();
/**
* @return the current device orientation.
*/
UIDeviceOrientation TTDeviceOrientation();
/**
* On iPhone/iPod touch
* Checks if the orientation is portrait, landscape left, or landscape right.
* This helps to ignore upside down and flat orientations.
*
* On iPad:
* Always returns Yes.
*/
BOOL TTIsSupportedOrientation(UIInterfaceOrientation orientation);
/**
* @return the rotation transform for a given orientation.
*/
CGAffineTransform TTRotateTransformForOrientation(UIInterfaceOrientation orientation);
/**
* @return the application frame with no offset.
*
* From the Apple docs:
* Frame of application screen area in points (i.e. entire screen minus status bar if visible)
*/
CGRect TTApplicationFrame();
/**
* @return the toolbar height for a given orientation.
*
* The toolbar is slightly shorter in landscape.
*/
CGFloat TTToolbarHeightForOrientation(UIInterfaceOrientation orientation);
/**
* @return the height of the keyboard for a given orientation.
*/
CGFloat TTKeyboardHeightForOrientation(UIInterfaceOrientation orientation);
/**
* @return the space between the edge of the screen and a grouped table cell. Larger on iPad.
*/
CGFloat TTGroupedTableCellInset();
/**
* A convenient way to show a UIAlertView with a message.
*/
void TTAlert(NSString* message);
/**
* Same as TTAlert but the alert view has no title.
*/
void TTAlertNoTitle(NSString* message);
///////////////////////////////////////////////////////////////////////////////////////////////////
// Debug logging helpers
#define TTLOGRECT(rect) \
TTDINFO(@"%s x=%f, y=%f, w=%f, h=%f", #rect, rect.origin.x, rect.origin.y, \
rect.size.width, rect.size.height)
#define TTLOGPOINT(pt) \
TTDINFO(@"%s x=%f, y=%f", #pt, pt.x, pt.y)
#define TTLOGSIZE(size) \
TTDINFO(@"%s w=%f, h=%f", #size, size.width, size.height)
#define TTLOGEDGES(edges) \
TTDINFO(@"%s left=%f, right=%f, top=%f, bottom=%f", #edges, edges.left, edges.right, \
edges.top, edges.bottom)
#define TTLOGHSV(_COLOR) \
TTDINFO(@"%s h=%f, s=%f, v=%f", #_COLOR, _COLOR.hue, _COLOR.saturation, _COLOR.value)
#define TTLOGVIEWS(_VIEW) \
{ for (UIView* view = _VIEW; view; view = view.superview) { TTDINFO(@"%@", view); } }
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dimensions of common iPhone OS Views
/**
* The standard height of a row in a table view controller.
* @const 44 pixels
*/
extern const CGFloat ttkDefaultRowHeight;
/**
* The standard height of a toolbar in portrait orientation.
* @const 44 pixels
*/
extern const CGFloat ttkDefaultPortraitToolbarHeight;
/**
* The standard height of a toolbar in landscape orientation.
* @const 33 pixels
*/
extern const CGFloat ttkDefaultLandscapeToolbarHeight;
/**
* The standard height of the keyboard in portrait orientation.
* @const 216 pixels
*/
extern const CGFloat ttkDefaultPortraitKeyboardHeight;
/**
* The standard height of the keyboard in landscape orientation.
* @const 160 pixels
*/
extern const CGFloat ttkDefaultLandscapeKeyboardHeight;
/**
* The space between the edge of the screen and the cell edge in grouped table views.
* @const 10 pixels
*/
extern const CGFloat ttkGroupedTableCellInset;
/**
* Deprecated macros for common constants.
*/
#define TT_ROW_HEIGHT ttkDefaultRowHeight
#define TT_TOOLBAR_HEIGHT ttkDefaultPortraitToolbarHeight
#define TT_LANDSCAPE_TOOLBAR_HEIGHT ttkDefaultLandscapeToolbarHeight
#define TT_KEYBOARD_HEIGHT ttkDefaultPortraitKeyboardHeight
#define TT_LANDSCAPE_KEYBOARD_HEIGHT ttkDefaultLandscapeKeyboardHeight
#define TT_IPAD_KEYBOARD_HEIGHT ttkDefaultPadPortraitKeyboardHeight
#define TT_IPAD_LANDSCAPE_KEYBOARD_HEIGHT ttkDefaultPadLandscapeKeyboardHeight
///////////////////////////////////////////////////////////////////////////////////////////////////
// Animation
/**
* The standard duration length for a transition.
* @const 0.3 seconds
*/
extern const CGFloat ttkDefaultTransitionDuration;
/**
* The standard duration length for a fast transition.
* @const 0.2 seconds
*/
extern const CGFloat ttkDefaultFastTransitionDuration;
/**
* The standard duration length for a flip transition.
* @const 0.7 seconds
*/
extern const CGFloat ttkDefaultFlipTransitionDuration;
/**
* Deprecated macros for common constants.
*/
#define TT_TRANSITION_DURATION ttkDefaultTransitionDuration
#define TT_FAST_TRANSITION_DURATION ttkDefaultFastTransitionDuration
#define TT_FLIP_TRANSITION_DURATION ttkDefaultFlipTransitionDuration