This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
SLKUIConstants.h
61 lines (52 loc) · 3.29 KB
/
SLKUIConstants.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
//
// SlackTextViewController
// https://github.com/slackhq/SlackTextViewController
//
// Copyright 2014-2016 Slack Technologies, Inc.
// Licence: MIT-Licence
//
#define SLK_IS_LANDSCAPE ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationLandscapeRight)
#define SLK_IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define SLK_IS_IPHONE ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
#define SLK_IS_IPHONE4 (SLK_IS_IPHONE && SLKKeyWindowBounds().size.height < 568.0)
#define SLK_IS_IPHONE5 (SLK_IS_IPHONE && SLKKeyWindowBounds().size.height == 568.0)
#define SLK_IS_IPHONE6 (SLK_IS_IPHONE && SLKKeyWindowBounds().size.height == 667.0)
#define SLK_IS_IPHONE6PLUS (SLK_IS_IPHONE && SLKKeyWindowBounds().size.height == 736.0 || SLKKeyWindowBounds().size.width == 736.0) // Both orientations
#define SLK_IS_IOS8_AND_HIGHER ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)
#define SLK_IS_IOS9_AND_HIGHER ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0)
#define SLK_KEYBOARD_NOTIFICATION_DEBUG DEBUG && 0 // Logs every keyboard notification being sent
static NSString *SLKTextViewControllerDomain = @"com.slack.TextViewController";
/**
Returns a constant font size difference reflecting the current accessibility settings.
@param category A content size category constant string.
@returns A float constant font size difference.
*/
__unused static CGFloat SLKPointSizeDifferenceForCategory(NSString *category)
{
if ([category isEqualToString:UIContentSizeCategoryExtraSmall]) return -3.0;
if ([category isEqualToString:UIContentSizeCategorySmall]) return -2.0;
if ([category isEqualToString:UIContentSizeCategoryMedium]) return -1.0;
if ([category isEqualToString:UIContentSizeCategoryLarge]) return 0.0;
if ([category isEqualToString:UIContentSizeCategoryExtraLarge]) return 2.0;
if ([category isEqualToString:UIContentSizeCategoryExtraExtraLarge]) return 4.0;
if ([category isEqualToString:UIContentSizeCategoryExtraExtraExtraLarge]) return 6.0;
if ([category isEqualToString:UIContentSizeCategoryAccessibilityMedium]) return 8.0;
if ([category isEqualToString:UIContentSizeCategoryAccessibilityLarge]) return 10.0;
if ([category isEqualToString:UIContentSizeCategoryAccessibilityExtraLarge]) return 11.0;
if ([category isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraLarge]) return 12.0;
if ([category isEqualToString:UIContentSizeCategoryAccessibilityExtraExtraExtraLarge]) return 13.0;
return 0;
}
__unused static CGRect SLKKeyWindowBounds()
{
return [[UIApplication sharedApplication] keyWindow].bounds;
}
__unused static CGRect SLKRectInvert(CGRect rect)
{
CGRect invert = CGRectZero;
invert.origin.x = rect.origin.y;
invert.origin.y = rect.origin.x;
invert.size.width = rect.size.height;
invert.size.height = rect.size.width;
return invert;
}