From 55ed6a83bfcf7a73766a74543dc0162988bd35f4 Mon Sep 17 00:00:00 2001 From: Jennis Date: Sat, 29 Jun 2013 14:09:24 +0530 Subject: [PATCH 1/3] Added singleton support so that no need to create property in application delegate. --- Source/VSThemeLoader.h | 1 + Source/VSThemeLoader.m | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Source/VSThemeLoader.h b/Source/VSThemeLoader.h index 4c2d2be..272d595 100644 --- a/Source/VSThemeLoader.h +++ b/Source/VSThemeLoader.h @@ -16,6 +16,7 @@ @property (nonatomic, strong, readonly) VSTheme *defaultTheme; @property (nonatomic, strong, readonly) NSArray *themes; ++ (VSThemeLoader*)sharedInstance; - (VSTheme *)themeNamed:(NSString *)themeName; @end diff --git a/Source/VSThemeLoader.m b/Source/VSThemeLoader.m index bbbe4c6..fd8435a 100644 --- a/Source/VSThemeLoader.m +++ b/Source/VSThemeLoader.m @@ -17,8 +17,17 @@ @interface VSThemeLoader () @end +static VSThemeLoader *singletonManager = nil; + @implementation VSThemeLoader ++ (VSThemeLoader*)sharedInstance{ + + if(singletonManager == nil) + singletonManager = [[super allocWithZone:NULL] init]; + + return singletonManager; +} - (id)init { From 110d87447060b4ca8c7209d3a824b83cb2031d3c Mon Sep 17 00:00:00 2001 From: Jennis Date: Sat, 29 Jun 2013 14:09:55 +0530 Subject: [PATCH 2/3] Added singleton support so that no need to create property in application delegate. --- Demo/DB5Demo/DB5AppDelegate.m | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Demo/DB5Demo/DB5AppDelegate.m b/Demo/DB5Demo/DB5AppDelegate.m index fe0e919..812b74f 100644 --- a/Demo/DB5Demo/DB5AppDelegate.m +++ b/Demo/DB5Demo/DB5AppDelegate.m @@ -14,8 +14,6 @@ @interface DB5AppDelegate () -@property (nonatomic, strong) VSThemeLoader *themeLoader; -@property (nonatomic, strong) VSTheme *theme; @end @@ -23,11 +21,10 @@ @implementation DB5AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.themeLoader = [VSThemeLoader new]; - self.theme = self.themeLoader.defaultTheme; + VSTheme *theme = [VSThemeLoader sharedInstance].defaultTheme; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.viewController = [[DB5ViewController alloc] initWithNibName:@"DB5ViewController" bundle:nil theme:self.theme]; + self.viewController = [[DB5ViewController alloc] initWithNibName:@"DB5ViewController" bundle:nil theme:theme]; self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; From 74210e8417a2965e9031c2187390993da2dea47f Mon Sep 17 00:00:00 2001 From: Jennis Date: Sat, 29 Jun 2013 14:57:15 +0530 Subject: [PATCH 3/3] Added customize alpha option read from plist. --- Source/VSTheme.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/VSTheme.m b/Source/VSTheme.m index ca8056e..668d32e 100644 --- a/Source/VSTheme.m +++ b/Source/VSTheme.m @@ -276,11 +276,13 @@ static BOOL stringIsEmpty(NSString *s) { NSString *redString = [s substringToIndex:2]; NSString *greenString = [s substringWithRange:NSMakeRange(2, 2)]; NSString *blueString = [s substringWithRange:NSMakeRange(4, 2)]; + NSString *alphaString = [s substringWithRange:NSMakeRange(6, 2)]; - unsigned int red = 0, green = 0, blue = 0; + unsigned int red = 0, green = 0, blue = 0, alpha = 0; [[NSScanner scannerWithString:redString] scanHexInt:&red]; [[NSScanner scannerWithString:greenString] scanHexInt:&green]; [[NSScanner scannerWithString:blueString] scanHexInt:&blue]; + [[NSScanner scannerWithString:alphaString] scanHexInt:&alpha]; - return [UIColor colorWithRed:(CGFloat)red/255.0f green:(CGFloat)green/255.0f blue:(CGFloat)blue/255.0f alpha:1.0f]; + return [UIColor colorWithRed:(CGFloat)red/255.0f green:(CGFloat)green/255.0f blue:(CGFloat)blue/255.0f alpha:(CGFloat)alpha/255.0f]; }