-
Notifications
You must be signed in to change notification settings - Fork 197
/
Platform.swift
85 lines (77 loc) · 2.87 KB
/
Platform.swift
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
//
// Platform.swift
// BonMot
//
// Created by Brian King on 9/22/16.
// Copyright © 2016 Rightpoint. All rights reserved.
//
#if os(OSX)
import AppKit
public typealias BONColor = NSColor
public typealias BONImage = NSImage
public typealias BONTextField = NSTextField
public typealias BONFont = NSFont
public typealias BONFontDescriptor = NSFontDescriptor
public typealias BONSymbolicTraits = NSFontDescriptor.SymbolicTraits
let BONFontDescriptorFeatureSettingsAttribute = NSFontDescriptor.AttributeName.featureSettings
let BONFontFeatureTypeIdentifierKey = NSFontDescriptor.FeatureKey.typeIdentifier
let BONFontFeatureSelectorIdentifierKey = NSFontDescriptor.FeatureKey.selectorIdentifier
#else
import UIKit
public typealias BONColor = UIColor
public typealias BONImage = UIImage
public typealias BONFont = UIFont
public typealias BONFontDescriptor = UIFontDescriptor
public typealias BONSymbolicTraits = UIFontDescriptor.SymbolicTraits
let BONFontDescriptorFeatureSettingsAttribute = UIFontDescriptor.AttributeName.featureSettings
let BONFontFeatureTypeIdentifierKey = UIFontDescriptor.FeatureKey.featureIdentifier
let BONFontFeatureSelectorIdentifierKey = UIFontDescriptor.FeatureKey.typeIdentifier
#if os(iOS) || os(tvOS)
public typealias BONTextField = UITextField
#endif
#endif
public typealias StyleAttributes = [NSAttributedString.Key: Any]
#if os(iOS) || os(tvOS)
public typealias BonMotTextStyle = UIFont.TextStyle
public typealias BonMotContentSizeCategory = UIContentSizeCategory
#endif
// This key is defined here because it needs to be used in non-adaptive code.
public let BonMotTransformationsAttributeName = NSAttributedString.Key("BonMotTransformations")
extension BONSymbolicTraits {
#if os(iOS) || os(tvOS) || os(watchOS)
static var italic: BONSymbolicTraits {
return .traitItalic
}
static var bold: BONSymbolicTraits {
return .traitBold
}
static var expanded: BONSymbolicTraits {
return .traitExpanded
}
static var condensed: BONSymbolicTraits {
return .traitCondensed
}
static var vertical: BONSymbolicTraits {
return .traitVertical
}
static var uiOptimized: BONSymbolicTraits {
return .traitUIOptimized
}
static var tightLineSpacing: BONSymbolicTraits {
return .traitTightLeading
}
static var looseLineSpacing: BONSymbolicTraits {
return .traitLooseLeading
}
#else
static var uiOptimized: BONSymbolicTraits {
return .UIOptimized
}
static var tightLineSpacing: BONSymbolicTraits {
return .tightLeading
}
static var looseLineSpacing: BONSymbolicTraits {
return .looseLeading
}
#endif
}