-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathPFThemeAssembly.m
98 lines (86 loc) · 3.87 KB
/
PFThemeAssembly.m
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
95
96
97
98
////////////////////////////////////////////////////////////////////////////////
//
// TYPHOON FRAMEWORK
// Copyright 2015, 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 "PFThemeAssembly.h"
#import "PFThemeFactory.h"
#import "PFTheme.h"
#import "NanoFrame.h"
/**
* This assembly illustrates the use of factory-components & collections.
*/
@implementation PFThemeAssembly
/**
* Current-theme is emitted from the theme-factory, which increments the theme on each run of the application.
*/
- (PFTheme *)currentTheme
{
return [TyphoonDefinition withFactory:[self themeFactory] selector:@selector(sequentialTheme)];
}
/**
* 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. (This is particularly useful when using PropertyPlaceholder configs).
*/
- (PFThemeFactory *)themeFactory
{
return [TyphoonDefinition withClass:[PFThemeFactory class] configuration:^(TyphoonDefinition *definition)
{
[definition useInitializer:@selector(initWithThemes:) parameters:^(TyphoonMethod *initializer)
{
[initializer injectParameterWith:@[
[self cloudsOverTheCityTheme],
[self beachTheme],
[self lightsInTheRainTheme],
[self sunsetTheme]
]];
}];
definition.scope = TyphoonScopeSingleton;
}];
}
- (PFTheme *)cloudsOverTheCityTheme
{
return [TyphoonDefinition withClass:[PFTheme class] configuration:^(TyphoonDefinition *definition)
{
[definition injectProperty:@selector(backgroundResourceName) with:@"bg3.png"];
[definition injectProperty:@selector(navigationBarColor) with:[UIColor colorWithHexRGB:0x641d23]];
[definition injectProperty:@selector(forecastTintColor) with:[UIColor colorWithHexRGB:0x641d23]];
[definition injectProperty:@selector(controlTintColor) with:[UIColor colorWithHexRGB:0x7f9588]];
}];
}
- (PFTheme *)lightsInTheRainTheme
{
return [TyphoonDefinition withClass:[PFTheme class] configuration:^(TyphoonDefinition *definition)
{
[definition injectProperty:@selector(backgroundResourceName) with:@"bg4.png"];
[definition injectProperty:@selector(navigationBarColor) with:[UIColor colorWithHexRGB:0xeaa53d]];
[definition injectProperty:@selector(forecastTintColor) with:[UIColor colorWithHexRGB:0x722d49]];
[definition injectProperty:@selector(controlTintColor) with:[UIColor colorWithHexRGB:0x722d49]];
}];
}
- (PFTheme *)beachTheme
{
return [TyphoonDefinition withClass:[PFTheme class] configuration:^(TyphoonDefinition *definition)
{
[definition injectProperty:@selector(backgroundResourceName) with:@"bg5.png"];
[definition injectProperty:@selector(navigationBarColor) with:[UIColor colorWithHexRGB:0x37b1da]];
[definition injectProperty:@selector(forecastTintColor) with:[UIColor colorWithHexRGB:0x37b1da]];
[definition injectProperty:@selector(controlTintColor) with:[UIColor colorWithHexRGB:0x0043a6]];
}];
}
- (PFTheme *)sunsetTheme
{
return [TyphoonDefinition withClass:[PFTheme class] configuration:^(TyphoonDefinition *definition)
{
[definition injectProperty:@selector(backgroundResourceName) with:@"sunset.png"];
[definition injectProperty:@selector(navigationBarColor) with:[UIColor colorWithHexRGB:0x0a1d3b]];
[definition injectProperty:@selector(forecastTintColor) with:[UIColor colorWithHexRGB:0x0a1d3b]];
[definition injectProperty:@selector(controlTintColor) with:[UIColor colorWithHexRGB:0x606970]];
}];
}
@end