This repository was archived by the owner on Jan 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathThemeAssembly.swift
94 lines (74 loc) · 3.71 KB
/
ThemeAssembly.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
86
87
88
89
90
91
92
93
94
////////////////////////////////////////////////////////////////////////////////
//
// TYPHOON FRAMEWORK
// Copyright 2013, Typhoon Framework Contributors
// All Rights Reserved.
//
// NOTICE: The authors permit you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
import Foundation
public class ThemeAssembly : TyphoonAssembly {
/**
* Current-theme is emitted from the theme-factory, which increments the theme on each run of the application.
*/
public dynamic func currentTheme() -> AnyObject {
return TyphoonDefinition.withFactory(self.themeFactory(), selector: "sequentialTheme") as AnyObject
}
/**
* The theme factory contains a collection of each theme. Individual themes are using Typhoon's type-converter system to convert the
* string representation of properties to their required runtime type.
*/
public dynamic func themeFactory() -> AnyObject {
return TyphoonDefinition.withClass(ThemeFactory.self) {
definition in
definition!.useInitializer("initWithThemes:") {
initializer in
initializer!.injectParameter(with: [
self.cloudsOverTheCityTheme(),
self.lightsInTheRainTheme(),
self.beachTheme(),
self.sunsetTheme()
])
}
definition!.scope = TyphoonScope.singleton
} as AnyObject
}
public dynamic func cloudsOverTheCityTheme() -> AnyObject {
return TyphoonDefinition.withClass(Theme.self) {
definition in
definition!.injectProperty("backgroundResourceName", with:"bg3.png")
definition!.injectProperty("navigationBarColor", with:UIColor(hexRGB:0x641d23))
definition!.injectProperty("forecastTintColor", with:UIColor(hexRGB:0x641d23))
definition!.injectProperty("controlTintColor", with:UIColor(hexRGB:0x7f9588))
} as AnyObject
}
public dynamic func lightsInTheRainTheme() -> AnyObject {
return TyphoonDefinition.withClass(Theme.self) {
definition in
definition!.injectProperty("backgroundResourceName", with:"bg4.png")
definition!.injectProperty("navigationBarColor", with:UIColor(hexRGB:0xeaa53d))
definition!.injectProperty("forecastTintColor", with:UIColor(hexRGB:0x722d49))
definition!.injectProperty("controlTintColor", with:UIColor(hexRGB:0x722d49))
} as AnyObject
}
public dynamic func beachTheme() -> AnyObject {
return TyphoonDefinition.withClass(Theme.self) {
definition in
definition!.injectProperty("backgroundResourceName", with:"bg5.png")
definition!.injectProperty("navigationBarColor", with:UIColor(hexRGB:0x37b1da))
definition!.injectProperty("forecastTintColor", with:UIColor(hexRGB:0x37b1da))
definition!.injectProperty("controlTintColor", with:UIColor(hexRGB:0x0043a6))
} as AnyObject
}
public dynamic func sunsetTheme() -> AnyObject {
return TyphoonDefinition.withClass(Theme.self) {
definition in
definition!.injectProperty("backgroundResourceName", with:"sunset.png")
definition!.injectProperty("navigationBarColor", with:UIColor(hexRGB:0x0a1d3b))
definition!.injectProperty("forecastTintColor", with:UIColor(hexRGB:0x0a1d3b))
definition!.injectProperty("controlTintColor", with:UIColor(hexRGB:0x606970))
} as AnyObject
}
}