-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStyleSheetSample.swift
81 lines (64 loc) · 2.12 KB
/
StyleSheetSample.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
//
// StyleSheetSample.swift
//
// Generated by StyleSheetGenerator on 13/12/2016.
// Copyright © 2016 Julien Ducret. All rights reserved.
//
import UIKit
// MARK: - CommonColor enum
public enum CommonColor {
case grey
case yellow
case black
case offBlack
var rgba: [CGFloat] {
switch self {
case .grey: return [200.0 / 255.0, 200.0 / 255.0, 200.0 / 255.0, 1.0]
case .yellow: return [245.0 / 255.0, 222.0 / 255.0, 80.0 / 255.0, 1.0]
case .black: return [0.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.0]
case .offBlack: return [20.0 / 255.0, 20.0 / 255.0, 20.0 / 255.0, 1.0]
}
}
var r: CGFloat { return self.rgba[0] }
var g: CGFloat { return self.rgba[1] }
var b: CGFloat { return self.rgba[2] }
var a: CGFloat { return self.rgba[3] }
}
// MARK: - UIColor extension
extension UIColor {
convenience init(commonColor: CommonColor) {
self.init(red: commonColor.r, green: commonColor.g, blue: commonColor.b, alpha: commonColor.a)
}
}
// MARK: - TextStyle enum
public enum TextStyle {
case navigationTitle
case bodyTinyBold
case placeholder
case bodySmall
case bodyTiny
case bodyDemiBold
case body
public var font: UIFont {
switch self {
case .navigationTitle: return UIFont(name: "AvenirNext-DemiBold", size: 16.0)!
case .bodyTinyBold: return UIFont(name: "AvenirNext-DemiBold", size: 9.0)!
case .placeholder: return UIFont(name: "AvenirNext-Medium", size: 14.0)!
case .bodySmall: return UIFont(name: "AvenirNext-Medium", size: 12.0)!
case .bodyTiny: return UIFont(name: "AvenirNext-Medium", size: 9.0)!
case .bodyDemiBold: return UIFont(name: "AvenirNext-DemiBold", size: 14.0)!
case .body: return UIFont(name: "AvenirNext-Medium", size: 14.0)!
}
}
public var color: UIColor {
switch self {
case .navigationTitle: return UIColor(commonColor: .offBlack)
case .bodyTinyBold: return UIColor(commonColor: .offBlack)
case .placeholder: return UIColor(commonColor: .grey)
case .bodySmall: return UIColor(commonColor: .grey)
case .bodyTiny: return UIColor(commonColor: .offBlack)
case .bodyDemiBold: return UIColor(commonColor: .offBlack)
case .body: return UIColor(commonColor: .offBlack)
}
}
}