From 60a60dd4d727ce28fc6df71023db4d55c9c01190 Mon Sep 17 00:00:00 2001 From: Marin Usalj Date: Thu, 6 Dec 2012 18:56:39 -0800 Subject: [PATCH] refactored all the class methods to be on a singleton object --- NUI/Core/NUIAppearance.m | 38 ++++++++--------- NUI/Core/NUISettings.h | 26 ++++++------ NUI/Core/NUISettings.m | 38 ++++++++--------- NUI/Core/NUIUtilities.m | 16 +++---- NUI/Core/Renderers/NUIBarButtonItemRenderer.m | 12 +++--- NUI/Core/Renderers/NUIButtonRenderer.m | 42 +++++++++---------- NUI/Core/Renderers/NUILabelRenderer.m | 28 ++++++------- NUI/Core/Renderers/NUINavigationBarRenderer.m | 8 ++-- .../Renderers/NUISegmentedControlRenderer.m | 8 ++-- NUI/Core/Renderers/NUITabBarRenderer.m | 12 +++--- NUI/Core/Renderers/NUITableViewCellRenderer.m | 10 ++--- NUI/Core/Renderers/NUITextFieldRenderer.m | 12 +++--- NUI/Core/Renderers/NUIViewRenderer.m | 8 ++-- NUI/UI/Core/NUINavigationBar.m | 10 ++--- NUI/UI/Core/NUITabBar.m | 10 ++--- 15 files changed, 140 insertions(+), 138 deletions(-) diff --git a/NUI/Core/NUIAppearance.m b/NUI/Core/NUIAppearance.m index e05f8d3c..a2abb9bd 100644 --- a/NUI/Core/NUIAppearance.m +++ b/NUI/Core/NUIAppearance.m @@ -12,7 +12,7 @@ @implementation NUIAppearance + (void)initializeWithStylesheet:(NSString *)stylesheet { - [NUISettings loadStylesheet:stylesheet]; + [STYLESHEET loadStylesheet:stylesheet]; [self initUINavigationBar]; [self initUIBarButtonItem]; @@ -29,16 +29,16 @@ + (void)initUINavigationBar [[UINavigationBar appearance] setTitleTextAttributes:titleTextAttributes]; } - if ([NUISettings hasProperty:@"background-image" withClass:ui_class_name]) { - [[UINavigationBar appearance] setBackgroundImage:[NUISettings getImage:@"background-image" withClass:ui_class_name] forBarMetrics:UIBarMetricsDefault]; + if ([STYLESHEET hasProperty:@"background-image" withClass:ui_class_name]) { + [[UINavigationBar appearance] setBackgroundImage:[STYLESHEET getImage:@"background-image" withClass:ui_class_name] forBarMetrics:UIBarMetricsDefault]; } - if ([NUISettings hasProperty:@"background-tint-color" withClass:ui_class_name]) { - [[UINavigationBar appearance] setTintColor:[NUISettings getColor:@"background-tint-color" withClass:ui_class_name]]; + if ([STYLESHEET hasProperty:@"background-tint-color" withClass:ui_class_name]) { + [[UINavigationBar appearance] setTintColor:[STYLESHEET getColor:@"background-tint-color" withClass:ui_class_name]]; } - if ([NUISettings hasProperty:@"background-color" withClass:ui_class_name]) { - [[UINavigationBar appearance] setBackgroundImage:[NUISettings getImageFromColor:@"background-color" withClass:ui_class_name] forBarMetrics:UIBarMetricsDefault]; + if ([STYLESHEET hasProperty:@"background-color" withClass:ui_class_name]) { + [[UINavigationBar appearance] setBackgroundImage:[STYLESHEET getImageFromColor:@"background-color" withClass:ui_class_name] forBarMetrics:UIBarMetricsDefault]; } } @@ -55,31 +55,31 @@ + (void)initUIBarButtonItem [[ui_class appearance] setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal]; } - if ([NUISettings hasProperty:@"background-color" withClass:ui_class_name]) { - UIImage *backgroundColorImage = [NUIGraphics barButtonWithColor:[NUISettings getColor:@"background-color" withClass:ui_class_name]]; + if ([STYLESHEET hasProperty:@"background-color" withClass:ui_class_name]) { + UIImage *backgroundColorImage = [NUIGraphics barButtonWithColor:[STYLESHEET getColor:@"background-color" withClass:ui_class_name]]; [[UIBarButtonItem appearance] setBackgroundImage:backgroundColorImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } - if ([NUISettings hasProperty:@"background-tint-color" withClass:ui_class_name]) { - [[ui_class appearance] setTintColor:[NUISettings getColor:@"background-tint-color" withClass:ui_class_name]]; + if ([STYLESHEET hasProperty:@"background-tint-color" withClass:ui_class_name]) { + [[ui_class appearance] setTintColor:[STYLESHEET getColor:@"background-tint-color" withClass:ui_class_name]]; } - if ([NUISettings hasProperty:@"background-image" withClass:ui_class_name]) { - [[ui_class appearance] setBackgroundImage:[NUISettings getImage:@"background-image" withClass:ui_class_name] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; + if ([STYLESHEET hasProperty:@"background-image" withClass:ui_class_name]) { + [[ui_class appearance] setBackgroundImage:[STYLESHEET getImage:@"background-image" withClass:ui_class_name] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } NSString *ui_back_class_name = @"UIBackBarButtonItem"; - if ([NUISettings hasProperty:@"background-color" withClass:ui_back_class_name]) { - UIImage *backBackgroundColorImage = [NUIGraphics backButtonWithColor:[NUISettings getColor:@"background-color" withClass:ui_back_class_name]]; + if ([STYLESHEET hasProperty:@"background-color" withClass:ui_back_class_name]) { + UIImage *backBackgroundColorImage = [NUIGraphics backButtonWithColor:[STYLESHEET getColor:@"background-color" withClass:ui_back_class_name]]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backBackgroundColorImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; - } else if ([NUISettings hasProperty:@"background-color" withClass:ui_class_name]) { - UIImage *backBackgroundColorImage = [NUIGraphics backButtonWithColor:[NUISettings getColor:@"background-color" withClass:ui_class_name]]; + } else if ([STYLESHEET hasProperty:@"background-color" withClass:ui_class_name]) { + UIImage *backBackgroundColorImage = [NUIGraphics backButtonWithColor:[STYLESHEET getColor:@"background-color" withClass:ui_class_name]]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backBackgroundColorImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } - if ([NUISettings hasProperty:@"background-image" withClass:ui_back_class_name]) { - [[ui_class appearance] setBackButtonBackgroundImage:[NUISettings getImage:@"background-image" withClass:ui_back_class_name] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; + if ([STYLESHEET hasProperty:@"background-image" withClass:ui_back_class_name]) { + [[ui_class appearance] setBackButtonBackgroundImage:[STYLESHEET getImage:@"background-image" withClass:ui_back_class_name] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } } diff --git a/NUI/Core/NUISettings.h b/NUI/Core/NUISettings.h index b831a8d1..f58add4f 100644 --- a/NUI/Core/NUISettings.h +++ b/NUI/Core/NUISettings.h @@ -10,23 +10,25 @@ #import "NUIConverter.h" #import "NUIStyleParser.h" +#define STYLESHEET [NUISettings instance] + @interface NUISettings : NSObject #pragma mark - Initialization -+ (void)loadStylesheet:(NSString*)name; + (NUISettings*)instance; +- (void)loadStylesheet:(NSString*)name; #pragma mark - Public -+ (BOOL)hasProperty:(NSString*)property withClass:(NSString*)class_name; -+ (id)get:(NSString*)property withClass:(NSString*)class_name; -+ (BOOL)getBoolean:(NSString*)property withClass:(NSString*)class_name; -+ (float)getFloat:(NSString*)property withClass:(NSString*)class_name; -+ (CGSize)getSize:(NSString*)property withClass:(NSString*)class_name; -+ (UIOffset)getOffset:(NSString*)property withClass:(NSString*)class_name; -+ (UITextBorderStyle)getBorderStyle:(NSString*)property withClass:(NSString*)class_name; -+ (UIColor*)getColor:(NSString*)property withClass:(NSString*)class_name; -+ (UIColor*)getColorFromImage:(NSString*)property withClass:(NSString*)class_name; -+ (UIImage*)getImage:(NSString*)property withClass:(NSString*)class_name; -+ (UIImage*)getImageFromColor:(NSString*)property withClass:(NSString*)class_name; +- (BOOL)hasProperty:(NSString*)property withClass:(NSString*)class_name; +- (id)get:(NSString*)property withClass:(NSString*)class_name; +- (BOOL)getBoolean:(NSString*)property withClass:(NSString*)class_name; +- (float)getFloat:(NSString*)property withClass:(NSString*)class_name; +- (CGSize)getSize:(NSString*)property withClass:(NSString*)class_name; +- (UIOffset)getOffset:(NSString*)property withClass:(NSString*)class_name; +- (UITextBorderStyle)getBorderStyle:(NSString*)property withClass:(NSString*)class_name; +- (UIColor*)getColor:(NSString*)property withClass:(NSString*)class_name; +- (UIColor*)getColorFromImage:(NSString*)property withClass:(NSString*)class_name; +- (UIImage*)getImage:(NSString*)property withClass:(NSString*)class_name; +- (UIImage*)getImageFromColor:(NSString*)property withClass:(NSString*)class_name; @end \ No newline at end of file diff --git a/NUI/Core/NUISettings.m b/NUI/Core/NUISettings.m index ff354df1..87f6bd33 100644 --- a/NUI/Core/NUISettings.m +++ b/NUI/Core/NUISettings.m @@ -17,21 +17,21 @@ @implementation NUISettings static NUISettings *singleton; -+ (void)loadStylesheet:(NSString *)name +- (void)loadStylesheet:(NSString *)name { - self.instance.stylesheet = [[NUIStyleParser new] getStylesFromFile:name]; + self.stylesheet = [[NUIStyleParser new] getStylesFromFile:name]; } -+ (BOOL)hasProperty:(NSString*)property withExplicitClass:(NSString*)class_name +- (BOOL)hasProperty:(NSString*)property withExplicitClass:(NSString*)class_name { - NSDictionary *ruleSet = self.instance.stylesheet[class_name]; + NSDictionary *ruleSet = self.stylesheet[class_name]; if (ruleSet == nil || ruleSet[property] == nil) { return NO; } return YES; } -+ (BOOL)hasProperty:(NSString*)property withClass:(NSString*)class_name +- (BOOL)hasProperty:(NSString*)property withClass:(NSString*)class_name { NSArray *classes = [self getClasses:class_name]; for (NSString *inherited_class in classes) { @@ -42,13 +42,13 @@ + (BOOL)hasProperty:(NSString*)property withClass:(NSString*)class_name return NO; } -+ (id)get:(NSString*)property withExplicitClass:(NSString*)class_name +- (id)get:(NSString*)property withExplicitClass:(NSString*)class_name { - NSDictionary *ruleSet = self.instance.stylesheet[class_name]; + NSDictionary *ruleSet = self.stylesheet[class_name]; return ruleSet[property]; } -+ (id)get:(NSString*)property withClass:(NSString*)class_name +- (id)get:(NSString*)property withClass:(NSString*)class_name { NSArray *classes = [self getClasses:class_name]; for (NSString *inherited_class in classes) { @@ -59,52 +59,52 @@ + (id)get:(NSString*)property withClass:(NSString*)class_name return nil; } -+ (BOOL)getBoolean:(NSString*)property withClass:(NSString*)class_name +- (BOOL)getBoolean:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toBoolean:[self get:property withClass:class_name]]; } -+ (float)getFloat:(NSString*)property withClass:(NSString*)class_name -{ +- (float)getFloat:(NSString*)property withClass:(NSString*)class_name +{ return [NUIConverter toFloat:[self get:property withClass:class_name]]; } -+ (CGSize)getSize:(NSString*)property withClass:(NSString*)class_name +- (CGSize)getSize:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toSize:[self get:property withClass:class_name]]; } -+ (UIOffset)getOffset:(NSString*)property withClass:(NSString*)class_name +- (UIOffset)getOffset:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toOffset:[self get:property withClass:class_name]]; } -+ (UITextBorderStyle)getBorderStyle:(NSString*)property withClass:(NSString*)class_name +- (UITextBorderStyle)getBorderStyle:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toBorderStyle:[self get:property withClass:class_name]]; } -+ (UIColor*)getColor:(NSString*)property withClass:(NSString*)class_name +- (UIColor*)getColor:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toColor:[self get:property withClass:class_name]]; } -+ (UIColor*)getColorFromImage:(NSString*)property withClass:(NSString*)class_name +- (UIColor*)getColorFromImage:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toColorFromImageName:[self get:property withClass:class_name]]; } -+ (UIImage*)getImageFromColor:(NSString*)property withClass:(NSString*)class_name +- (UIImage*)getImageFromColor:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toImageFromColorName:[self get:property withClass:class_name]]; } -+ (UIImage*)getImage:(NSString*)property withClass:(NSString*)class_name +- (UIImage*)getImage:(NSString*)property withClass:(NSString*)class_name { return [NUIConverter toImageFromImageName:[self get:property withClass:class_name]]; } -+ (NSArray*)getClasses:(NSString*)class_name +- (NSArray*)getClasses:(NSString*)class_name { NSArray *classes = [[[class_name componentsSeparatedByString: @":"] reverseObjectEnumerator] allObjects]; return classes; diff --git a/NUI/Core/NUIUtilities.m b/NUI/Core/NUIUtilities.m index 9570540f..cd7ceb59 100644 --- a/NUI/Core/NUIUtilities.m +++ b/NUI/Core/NUIUtilities.m @@ -14,20 +14,20 @@ + (NSDictionary*)titleTextAttributesForClass:(NSString*)class_name { NSMutableDictionary *titleTextAttributes = [NSMutableDictionary dictionary]; - if ([NUISettings hasProperty:@"font-name" withClass:class_name]) { - [titleTextAttributes setObject:[UIFont fontWithName:[NUISettings get:@"font-name" withClass:class_name] size:[NUISettings getFloat:@"font-size" withClass:class_name]] forKey:UITextAttributeFont]; + if ([STYLESHEET hasProperty:@"font-name" withClass:class_name]) { + [titleTextAttributes setObject:[UIFont fontWithName:[STYLESHEET get:@"font-name" withClass:class_name] size:[STYLESHEET getFloat:@"font-size" withClass:class_name]] forKey:UITextAttributeFont]; } - if ([NUISettings hasProperty:@"font-color" withClass:class_name]) { - [titleTextAttributes setObject:[NUISettings getColor:@"font-color" withClass:class_name] forKey:UITextAttributeTextColor]; + if ([STYLESHEET hasProperty:@"font-color" withClass:class_name]) { + [titleTextAttributes setObject:[STYLESHEET getColor:@"font-color" withClass:class_name] forKey:UITextAttributeTextColor]; } - if ([NUISettings hasProperty:@"text-shadow-color" withClass:class_name]) { - [titleTextAttributes setObject:[NUISettings getColor:@"text-shadow-color" withClass:class_name] forKey:UITextAttributeTextShadowColor]; + if ([STYLESHEET hasProperty:@"text-shadow-color" withClass:class_name]) { + [titleTextAttributes setObject:[STYLESHEET getColor:@"text-shadow-color" withClass:class_name] forKey:UITextAttributeTextShadowColor]; } - if ([NUISettings hasProperty:@"text-shadow-offset" withClass:class_name]) { - [titleTextAttributes setObject:[NSValue valueWithUIOffset:[NUISettings getOffset:@"text-shadow-offset" withClass:class_name]] forKey:UITextAttributeTextShadowOffset]; + if ([STYLESHEET hasProperty:@"text-shadow-offset" withClass:class_name]) { + [titleTextAttributes setObject:[NSValue valueWithUIOffset:[STYLESHEET getOffset:@"text-shadow-offset" withClass:class_name]] forKey:UITextAttributeTextShadowOffset]; } return titleTextAttributes; diff --git a/NUI/Core/Renderers/NUIBarButtonItemRenderer.m b/NUI/Core/Renderers/NUIBarButtonItemRenderer.m index 5f6ebbb2..cad61b6d 100644 --- a/NUI/Core/Renderers/NUIBarButtonItemRenderer.m +++ b/NUI/Core/Renderers/NUIBarButtonItemRenderer.m @@ -13,15 +13,15 @@ @implementation NUIBarButtonItemRenderer + (void)render:(UIBarButtonItem*)item withClass:(NSString*)class_name { - if ([NUISettings hasProperty:@"background-image" withClass:class_name]) { - [item setBackgroundImage:[NUISettings getImage:@"background-image" withClass:class_name] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; + if ([STYLESHEET hasProperty:@"background-image" withClass:class_name]) { + [item setBackgroundImage:[STYLESHEET getImage:@"background-image" withClass:class_name] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } - if ([NUISettings hasProperty:@"background-tint-color" withClass:class_name]) { - [item setTintColor:[NUISettings getColor:@"background-tint-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-tint-color" withClass:class_name]) { + [item setTintColor:[STYLESHEET getColor:@"background-tint-color" withClass:class_name]]; } - if ([NUISettings hasProperty:@"background-color" withClass:class_name]) { - UIImage *backgroundColorImage = [NUIGraphics barButtonWithColor:[NUISettings getColor:@"background-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-color" withClass:class_name]) { + UIImage *backgroundColorImage = [NUIGraphics barButtonWithColor:[STYLESHEET getColor:@"background-color" withClass:class_name]]; [item setBackgroundImage:backgroundColorImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; } diff --git a/NUI/Core/Renderers/NUIButtonRenderer.m b/NUI/Core/Renderers/NUIButtonRenderer.m index fb9d9523..e022e716 100644 --- a/NUI/Core/Renderers/NUIButtonRenderer.m +++ b/NUI/Core/Renderers/NUIButtonRenderer.m @@ -13,61 +13,61 @@ @implementation NUIButtonRenderer + (void)render:(UIButton*)button withClass:(NSString*)class_name { // Set height - if ([NUISettings hasProperty:@"height" withClass:class_name]) { + if ([STYLESHEET hasProperty:@"height" withClass:class_name]) { CGRect frame = button.frame; CGSize originalSize = frame.size; - frame.size = CGSizeMake(originalSize.width, [NUISettings getFloat:@"height" withClass:class_name]); + frame.size = CGSizeMake(originalSize.width, [STYLESHEET getFloat:@"height" withClass:class_name]); button.frame = frame; } // Set background color - if ([NUISettings hasProperty:@"background-color" withClass:class_name]) { - [button setBackgroundColor:[NUISettings getColor:@"background-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-color" withClass:class_name]) { + [button setBackgroundColor:[STYLESHEET getColor:@"background-color" withClass:class_name]]; } // Set background gradient - if ([NUISettings hasProperty:@"background-color-top" withClass:class_name]) { + if ([STYLESHEET hasProperty:@"background-color-top" withClass:class_name]) { CAGradientLayer *gradient = [NUIGraphics - gradientLayerWithTop:[NUISettings getColor:@"background-color-top" withClass:class_name] - withBottom:[NUISettings getColor:@"background-color-bottom" withClass:class_name] + gradientLayerWithTop:[STYLESHEET getColor:@"background-color-top" withClass:class_name] + withBottom:[STYLESHEET getColor:@"background-color-bottom" withClass:class_name] withFrame:button.bounds]; [button.layer insertSublayer:gradient atIndex:0]; } // Set background image - if ([NUISettings hasProperty:@"background-image" withClass:class_name]) { - [button setBackgroundImage:[NUISettings getImage:@"background-image" withClass:class_name] forState:UIControlStateNormal]; + if ([STYLESHEET hasProperty:@"background-image" withClass:class_name]) { + [button setBackgroundImage:[STYLESHEET getImage:@"background-image" withClass:class_name] forState:UIControlStateNormal]; } - if ([NUISettings hasProperty:@"background-image-highlighted" withClass:class_name]) { - [button setBackgroundImage:[NUISettings getImage:@"background-image-highlighted" withClass:class_name] forState:UIControlStateHighlighted]; + if ([STYLESHEET hasProperty:@"background-image-highlighted" withClass:class_name]) { + [button setBackgroundImage:[STYLESHEET getImage:@"background-image-highlighted" withClass:class_name] forState:UIControlStateHighlighted]; } [NUIRenderer renderLabel:button.titleLabel withClass:class_name]; // Set font color - if ([NUISettings hasProperty:@"font-color" withClass:class_name]) { - [button setTitleColor:[NUISettings getColor:@"font-color" withClass:class_name] forState:UIControlStateNormal]; + if ([STYLESHEET hasProperty:@"font-color" withClass:class_name]) { + [button setTitleColor:[STYLESHEET getColor:@"font-color" withClass:class_name] forState:UIControlStateNormal]; } - if ([NUISettings hasProperty:@"font-color-highlighted" withClass:class_name]) { - [button setTitleColor:[NUISettings getColor:@"font-color-highlighted" withClass:class_name] forState:UIControlStateHighlighted]; + if ([STYLESHEET hasProperty:@"font-color-highlighted" withClass:class_name]) { + [button setTitleColor:[STYLESHEET getColor:@"font-color-highlighted" withClass:class_name] forState:UIControlStateHighlighted]; } CALayer *layer = [button layer]; // Set corners - if ([NUISettings hasProperty:@"corner-radius" withClass:class_name]) { + if ([STYLESHEET hasProperty:@"corner-radius" withClass:class_name]) { [layer setMasksToBounds:YES]; - [layer setCornerRadius:[NUISettings getFloat:@"corner-radius" withClass:class_name]]; + [layer setCornerRadius:[STYLESHEET getFloat:@"corner-radius" withClass:class_name]]; } // Set border color - if ([NUISettings hasProperty:@"border-color" withClass:class_name]) { - [layer setBorderColor:[[NUISettings getColor:@"border-color" withClass:class_name] CGColor]]; + if ([STYLESHEET hasProperty:@"border-color" withClass:class_name]) { + [layer setBorderColor:[[STYLESHEET getColor:@"border-color" withClass:class_name] CGColor]]; } // Set border width - if ([NUISettings hasProperty:@"border-width" withClass:class_name]) { - [layer setBorderWidth:[NUISettings getFloat:@"border-width" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"border-width" withClass:class_name]) { + [layer setBorderWidth:[STYLESHEET getFloat:@"border-width" withClass:class_name]]; } } diff --git a/NUI/Core/Renderers/NUILabelRenderer.m b/NUI/Core/Renderers/NUILabelRenderer.m index 6886773e..54ee8950 100644 --- a/NUI/Core/Renderers/NUILabelRenderer.m +++ b/NUI/Core/Renderers/NUILabelRenderer.m @@ -24,39 +24,39 @@ + (void)render:(UILabel*)label withClass:(NSString*)class_name withSuffix:(NSStr } property = @"font-color"; - if ([NUISettings hasProperty:property withClass:class_name]) { - label.textColor = [NUISettings getColor:property withClass:class_name]; + if ([STYLESHEET hasProperty:property withClass:class_name]) { + label.textColor = [STYLESHEET getColor:property withClass:class_name]; } property = @"font-color-highlighted"; - if ([NUISettings hasProperty:property withClass:class_name]) { - label.highlightedTextColor = [NUISettings getColor:property withClass:class_name]; + if ([STYLESHEET hasProperty:property withClass:class_name]) { + label.highlightedTextColor = [STYLESHEET getColor:property withClass:class_name]; } property = @"font-name"; NSString *size_property = @"font-size"; - if ([NUISettings hasProperty:property withClass:class_name]) { - label.font = [UIFont fontWithName:[NUISettings get:property withClass:class_name] size:[NUISettings getFloat:size_property withClass:class_name]]; + if ([STYLESHEET hasProperty:property withClass:class_name]) { + label.font = [UIFont fontWithName:[STYLESHEET get:property withClass:class_name] size:[STYLESHEET getFloat:size_property withClass:class_name]]; } property = @"text-alpha"; - if ([NUISettings hasProperty:property withClass:class_name]) { - label.alpha = [NUISettings getFloat:property withClass:class_name]; + if ([STYLESHEET hasProperty:property withClass:class_name]) { + label.alpha = [STYLESHEET getFloat:property withClass:class_name]; } property = @"text-auto-fit"; - if ([NUISettings hasProperty:property withClass:class_name]) { - [label setAdjustsFontSizeToFitWidth:[NUISettings getBoolean:property withClass:class_name]]; + if ([STYLESHEET hasProperty:property withClass:class_name]) { + [label setAdjustsFontSizeToFitWidth:[STYLESHEET getBoolean:property withClass:class_name]]; } property = @"text-shadow-color"; - if ([NUISettings hasProperty:property withClass:class_name]) { - label.shadowColor = [NUISettings getColor:property withClass:class_name]; + if ([STYLESHEET hasProperty:property withClass:class_name]) { + label.shadowColor = [STYLESHEET getColor:property withClass:class_name]; } property = @"text-shadow-offset"; - if ([NUISettings hasProperty:property withClass:class_name]) { - label.shadowOffset = [NUISettings getSize:property withClass:class_name]; + if ([STYLESHEET hasProperty:property withClass:class_name]) { + label.shadowOffset = [STYLESHEET getSize:property withClass:class_name]; } } diff --git a/NUI/Core/Renderers/NUINavigationBarRenderer.m b/NUI/Core/Renderers/NUINavigationBarRenderer.m index 9ae3e759..187e2a6b 100644 --- a/NUI/Core/Renderers/NUINavigationBarRenderer.m +++ b/NUI/Core/Renderers/NUINavigationBarRenderer.m @@ -12,12 +12,12 @@ @implementation NUINavigationBarRenderer + (void)render:(UINavigationBar*)bar withClass:(NSString*)class_name { - if ([NUISettings hasProperty:@"background-tint-color" withClass:class_name]) { - [bar setTintColor:[NUISettings getColor:@"background-tint-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-tint-color" withClass:class_name]) { + [bar setTintColor:[STYLESHEET getColor:@"background-tint-color" withClass:class_name]]; } - if ([NUISettings hasProperty:@"background-image" withClass:class_name]) { - [bar setBackgroundImage:[NUISettings getImage:@"background-image" withClass:class_name] forBarMetrics:UIBarMetricsDefault]; + if ([STYLESHEET hasProperty:@"background-image" withClass:class_name]) { + [bar setBackgroundImage:[STYLESHEET getImage:@"background-image" withClass:class_name] forBarMetrics:UIBarMetricsDefault]; } NSDictionary *titleTextAttributes = [NUIUtilities titleTextAttributesForClass:class_name]; diff --git a/NUI/Core/Renderers/NUISegmentedControlRenderer.m b/NUI/Core/Renderers/NUISegmentedControlRenderer.m index e52c4b01..3f4cf877 100644 --- a/NUI/Core/Renderers/NUISegmentedControlRenderer.m +++ b/NUI/Core/Renderers/NUISegmentedControlRenderer.m @@ -16,12 +16,12 @@ + (void)render:(UISegmentedControl*)control withClass:(NSString*)class_name control.segmentedControlStyle = UISegmentedControlStyleBar; // Set background color - if ([NUISettings hasProperty:@"background-color" withClass:class_name]) { - [control setBackgroundColor:[NUISettings getColor:@"background-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-color" withClass:class_name]) { + [control setBackgroundColor:[STYLESHEET getColor:@"background-color" withClass:class_name]]; } // Set background tint color - if ([NUISettings hasProperty:@"background-tint-color" withClass:class_name]) { - [control setTintColor:[NUISettings getColor:@"background-tint-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-tint-color" withClass:class_name]) { + [control setTintColor:[STYLESHEET getColor:@"background-tint-color" withClass:class_name]]; } NSDictionary *titleTextAttributes = [NUIUtilities titleTextAttributesForClass:class_name]; diff --git a/NUI/Core/Renderers/NUITabBarRenderer.m b/NUI/Core/Renderers/NUITabBarRenderer.m index 0b2c72f6..1d248b5e 100644 --- a/NUI/Core/Renderers/NUITabBarRenderer.m +++ b/NUI/Core/Renderers/NUITabBarRenderer.m @@ -12,12 +12,12 @@ @implementation NUITabBarRenderer + (void)render:(UITabBar*)bar withClass:(NSString*)class_name { - if ([NUISettings hasProperty:@"background-tint-color" withClass:class_name]) { - [bar setTintColor:[NUISettings getColor:@"background-tint-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-tint-color" withClass:class_name]) { + [bar setTintColor:[STYLESHEET getColor:@"background-tint-color" withClass:class_name]]; } - if ([NUISettings hasProperty:@"background-image" withClass:class_name]) { - [bar setBackgroundImage:[NUISettings getImage:@"background-image" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"background-image" withClass:class_name]) { + [bar setBackgroundImage:[STYLESHEET getImage:@"background-image" withClass:class_name]]; } NSDictionary *titleTextAttributes = [NUIUtilities titleTextAttributesForClass:class_name]; @@ -26,8 +26,8 @@ + (void)render:(UITabBar*)bar withClass:(NSString*)class_name if ([[titleTextAttributes allKeys] count] > 0) { [item setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal]; } - if ([NUISettings hasProperty:@"text-offset" withClass:class_name]) { - [item setTitlePositionAdjustment:[NUISettings getOffset:@"text-offset" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"text-offset" withClass:class_name]) { + [item setTitlePositionAdjustment:[STYLESHEET getOffset:@"text-offset" withClass:class_name]]; } } } diff --git a/NUI/Core/Renderers/NUITableViewCellRenderer.m b/NUI/Core/Renderers/NUITableViewCellRenderer.m index 4b82cbc4..238c31ad 100644 --- a/NUI/Core/Renderers/NUITableViewCellRenderer.m +++ b/NUI/Core/Renderers/NUITableViewCellRenderer.m @@ -13,19 +13,19 @@ @implementation NUITableViewCellRenderer + (void)render:(UITableViewCell*)cell withClass:(NSString*)class_name { // Set background color - if ([NUISettings hasProperty:@"background-color" withClass:class_name]) { + if ([STYLESHEET hasProperty:@"background-color" withClass:class_name]) { UIView *background = [[UIView alloc] initWithFrame:cell.frame]; - background.backgroundColor = [NUISettings getColor:@"background-color" withClass:class_name]; + background.backgroundColor = [STYLESHEET getColor:@"background-color" withClass:class_name]; cell.backgroundView = background; } // Set background gradient - if ([NUISettings hasProperty:@"background-color-top" withClass:class_name]) { + if ([STYLESHEET hasProperty:@"background-color-top" withClass:class_name]) { CGRect backgroundViewFrame = cell.contentView.frame; cell.backgroundView = [[UIView alloc] initWithFrame:backgroundViewFrame]; CAGradientLayer *gradient = [NUIGraphics - gradientLayerWithTop:[NUISettings getColor:@"background-color-top" withClass:class_name] - withBottom:[NUISettings getColor:@"background-color-bottom" withClass:class_name] + gradientLayerWithTop:[STYLESHEET getColor:@"background-color-top" withClass:class_name] + withBottom:[STYLESHEET getColor:@"background-color-bottom" withClass:class_name] withFrame:cell.bounds]; [cell.backgroundView.layer addSublayer:gradient]; } diff --git a/NUI/Core/Renderers/NUITextFieldRenderer.m b/NUI/Core/Renderers/NUITextFieldRenderer.m index 21ffd388..f37b3365 100644 --- a/NUI/Core/Renderers/NUITextFieldRenderer.m +++ b/NUI/Core/Renderers/NUITextFieldRenderer.m @@ -13,20 +13,20 @@ @implementation NUITextFieldRenderer + (void)render:(UITextField*)text_field withClass:(NSString*)class_name { // Set font - if ([NUISettings hasProperty:@"font-name" withClass:class_name]) { - [text_field setFont:[UIFont fontWithName:[NUISettings get:@"font-name" withClass:class_name] size:[NUISettings getFloat:@"font-size" withClass:class_name]]]; + if ([STYLESHEET hasProperty:@"font-name" withClass:class_name]) { + [text_field setFont:[UIFont fontWithName:[STYLESHEET get:@"font-name" withClass:class_name] size:[STYLESHEET getFloat:@"font-size" withClass:class_name]]]; } // Set border style - if ([NUISettings hasProperty:@"border-color" withClass:class_name]) { - [text_field setBorderStyle:[NUISettings getBorderStyle:@"border-color" withClass:class_name]]; + if ([STYLESHEET hasProperty:@"border-color" withClass:class_name]) { + [text_field setBorderStyle:[STYLESHEET getBorderStyle:@"border-color" withClass:class_name]]; } // Set height - if ([NUISettings hasProperty:@"height" withClass:class_name]) { + if ([STYLESHEET hasProperty:@"height" withClass:class_name]) { CGRect buttonFrame = text_field.frame; CGSize originalSize = buttonFrame.size; - buttonFrame.size = CGSizeMake(originalSize.width, [NUISettings getFloat:@"height" withClass: class_name]); + buttonFrame.size = CGSizeMake(originalSize.width, [STYLESHEET getFloat:@"height" withClass: class_name]); text_field.frame = buttonFrame; } } diff --git a/NUI/Core/Renderers/NUIViewRenderer.m b/NUI/Core/Renderers/NUIViewRenderer.m index f50c1b6e..2f0a0a70 100644 --- a/NUI/Core/Renderers/NUIViewRenderer.m +++ b/NUI/Core/Renderers/NUIViewRenderer.m @@ -12,10 +12,10 @@ @implementation NUIViewRenderer + (void)render:(UIView*)view withClass:(NSString*)class_name { - if ([NUISettings hasProperty:@"background-image" withClass:class_name]) { - [view setBackgroundColor: [NUISettings getColorFromImage:@"background-image" withClass: class_name]]; - } else if ([NUISettings hasProperty:@"background-color" withClass:class_name]) { - [view setBackgroundColor: [NUISettings getColor:@"background-color" withClass: class_name]]; + if ([STYLESHEET hasProperty:@"background-image" withClass:class_name]) { + [view setBackgroundColor: [STYLESHEET getColorFromImage:@"background-image" withClass: class_name]]; + } else if ([STYLESHEET hasProperty:@"background-color" withClass:class_name]) { + [view setBackgroundColor: [STYLESHEET getColor:@"background-color" withClass: class_name]]; } } diff --git a/NUI/UI/Core/NUINavigationBar.m b/NUI/UI/Core/NUINavigationBar.m index 0269a7e5..19e521f6 100644 --- a/NUI/UI/Core/NUINavigationBar.m +++ b/NUI/UI/Core/NUINavigationBar.m @@ -40,15 +40,15 @@ - (void)drawRectNUI:(CGRect)rect { [self initNUI]; - if ([NUISettings hasProperty:@"background-color-top" withClass:_nuiClass]) { + if ([STYLESHEET hasProperty:@"background-color-top" withClass:_nuiClass]) { CAGradientLayer *gradient = [NUIGraphics - gradientLayerWithTop:[NUISettings getColor:@"background-color-top" withClass:_nuiClass] - withBottom:[NUISettings getColor:@"background-color-bottom" withClass:_nuiClass] + gradientLayerWithTop:[STYLESHEET getColor:@"background-color-top" withClass:_nuiClass] + withBottom:[STYLESHEET getColor:@"background-color-bottom" withClass:_nuiClass] withFrame:self.frame]; [gradient renderInContext:UIGraphicsGetCurrentContext()]; - } else if ([NUISettings hasProperty:@"background-color" withClass:_nuiClass]) { + } else if ([STYLESHEET hasProperty:@"background-color" withClass:_nuiClass]) { CGContextRef context = UIGraphicsGetCurrentContext(); - CGContextSetFillColor(context, CGColorGetComponents([[NUISettings getColor:@"background-color" withClass:_nuiClass] CGColor])); + CGContextSetFillColor(context, CGColorGetComponents([[STYLESHEET getColor:@"background-color" withClass:_nuiClass] CGColor])); CGContextFillRect(context, rect); } } diff --git a/NUI/UI/Core/NUITabBar.m b/NUI/UI/Core/NUITabBar.m index 5bcfca2c..a7ddedfb 100644 --- a/NUI/UI/Core/NUITabBar.m +++ b/NUI/UI/Core/NUITabBar.m @@ -40,15 +40,15 @@ - (void)drawRectNUI:(CGRect)rect { [self initNUI]; - if ([NUISettings hasProperty:@"background-color-top" withClass:_nuiClass]) { + if ([STYLESHEET hasProperty:@"background-color-top" withClass:_nuiClass]) { CAGradientLayer *gradient = [NUIGraphics - gradientLayerWithTop:[NUISettings getColor:@"background-color-top" withClass:_nuiClass] - withBottom:[NUISettings getColor:@"background-color-bottom" withClass:_nuiClass] + gradientLayerWithTop:[STYLESHEET getColor:@"background-color-top" withClass:_nuiClass] + withBottom:[STYLESHEET getColor:@"background-color-bottom" withClass:_nuiClass] withFrame:self.frame]; [gradient renderInContext:UIGraphicsGetCurrentContext()]; - } else if ([NUISettings hasProperty:@"background-color" withClass:_nuiClass]) { + } else if ([STYLESHEET hasProperty:@"background-color" withClass:_nuiClass]) { CGContextRef context = UIGraphicsGetCurrentContext(); - CGContextSetFillColor(context, CGColorGetComponents([[NUISettings getColor:@"background-color" withClass:_nuiClass] CGColor])); + CGContextSetFillColor(context, CGColorGetComponents([[STYLESHEET getColor:@"background-color" withClass:_nuiClass] CGColor])); CGContextFillRect(context, rect); } }