-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThemeManager.swift
79 lines (64 loc) · 2.28 KB
/
ThemeManager.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
//
// ThemeManager.swift
// Breezer
//
// Created by Admin on 17.04.17.
// Copyright © 2017 grapes-studio. All rights reserved.
//
import Foundation
import UIKit
enum Theme {
case Dark, Red, Cyan, Gray, Violet
/// Цвет бэкграунда UINavigationController
var navigationBarColor: UIColor{
switch self {
case .Dark:
return UIColor(red: 102.0/255.0, green: 102.0/255.0, blue: 102.0/255.0, alpha: 1.0)
case .Red:
return UIColor.red
case .Cyan:
return UIColor(red: 86.0/255.0, green: 213.0/255.0, blue: 243.0/255.0, alpha: 1.0)
case .Gray:
return UIColor.gray
case .Violet:
return UIColor.purple
}
}
/// Цвет бэкграунда UINavigationController
var navigationBarTextColor: UIColor{
switch self {
case .Dark:
return UIColor.white
case .Red:
return UIColor.white
case .Cyan:
return UIColor.white
case .Gray:
return UIColor.white
case .Violet:
return UIColor.white
}
}
/// Цвет бэкграунда экранов
var screenBackgroundColor: UIColor{
return UIColor(red: 242.0/255.0, green: 242.0/255.0, blue: 242.0/255.0, alpha: 1.0)
}
var navigationBarTitleFont: UIFont {
return UIFont(name: "Roboto-Medium", size: 20)!
}
}
struct ThemeManager{
static func red() -> Theme {
return .Red
}
static func dark() -> Theme {
return .Dark
}
static func applyTheme(_ theme: Theme, forViewController vc: UIViewController) {
vc.navigationController?.navigationBar.barTintColor = theme.navigationBarColor
vc.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : theme.navigationBarTextColor,
NSFontAttributeName : theme.navigationBarTitleFont]
vc.navigationController?.navigationBar.tintColor = theme.navigationBarTextColor
UIScrollView.appearance().backgroundColor = theme.screenBackgroundColor
}
}