Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better tint support #298

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Demo/NUIDemo.xcworkspace/xcshareddata/NUIDemo.xccheckout
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
<string>NUIDemo</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>EA68DD74-875E-4BED-AA63-9E80568D4D5B</key>
<key>2F95D1B34DFEF3E924668F657F0C00B5BE26A2AC</key>
<string>ssh://github.com/squarefrog/nui.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Demo/NUIDemo.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>EA68DD74-875E-4BED-AA63-9E80568D4D5B</key>
<key>2F95D1B34DFEF3E924668F657F0C00B5BE26A2AC</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/squarefrog/nui.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>EA68DD74-875E-4BED-AA63-9E80568D4D5B</string>
<string>2F95D1B34DFEF3E924668F657F0C00B5BE26A2AC</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>EA68DD74-875E-4BED-AA63-9E80568D4D5B</string>
<string>2F95D1B34DFEF3E924668F657F0C00B5BE26A2AC</string>
<key>IDESourceControlWCCName</key>
<string>nui</string>
</dict>
Expand Down
6 changes: 3 additions & 3 deletions NUI.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = "NUI"
s.version = "0.5.5"
s.version = "0.5.6"
s.summary = "Style iOS apps with a stylesheet, similar to CSS."
s.description = "NUI is a drop-in UI kit for iOS that lets you style UI elements using a stylesheet, similar to CSS. It lets you style an entire app in minutes."
s.homepage = "https://github.com/tombenner/nui"
s.homepage = "https://github.com/Joulebug/nui"
s.license = { :type => 'MIT', :file => 'LICENSE.txt' }
s.author = { "Tom Benner" => "[email protected]" }
s.source = { :git => "https://github.com/tombenner/nui.git", :tag => "v0.5.5" }
s.source = { :git => "https://github.com/Joulebug/nui.git", :tag => "v0.5.6" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need an intermediary release of your own fork, please make such changes on a different branch than you're using to file a pull request.

s.platform = :ios, '5.1'

s.source_files = 'NUI', 'NUI/**/*.{h,m}'
Expand Down
4 changes: 3 additions & 1 deletion NUI/Core/NUIAppearance.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ + (void)initUIBarButtonItem
[[uiClass appearance] setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
}

if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[[uiClass appearance] setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[[uiClass appearance] setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}

Expand Down
7 changes: 5 additions & 2 deletions NUI/Core/Renderers/NUIBarButtonItemRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ + (void)render:(UIBarButtonItem*)item withClass:(NSString*)className

if ([NUISettings hasProperty:@"background-image" withClass:className]) {
[item setBackgroundImage:[NUISettings getImage:@"background-image" withClass:className] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[item setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-color" withClass:className] ||
[NUISettings hasProperty:@"background-color-top" withClass:className]) {
CALayer *layer = [CALayer layer];
Expand Down Expand Up @@ -86,6 +84,11 @@ + (void)render:(UIBarButtonItem*)item withClass:(NSString*)className
[item setBackgroundImage:highlightedImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
}
}
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[item setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[item setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}

NSDictionary *titleTextAttributes = [NUIUtilities titleTextAttributesForClass:className];

Expand Down
5 changes: 5 additions & 0 deletions NUI/Core/Renderers/NUIButtonRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ + (void)render:(UIButton*)button withClass:(NSString*)className
[button setTitleEdgeInsets:[NUISettings getEdgeInsets:@"padding" withClass:className]];
}

// Set tint
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[button setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

// Set background color
if ([NUISettings hasProperty:@"background-color" withClass:className]) {
[button setBackgroundImage:[NUISettings getImageFromColor:@"background-color" withClass:className] forState:UIControlStateNormal];
Expand Down
5 changes: 5 additions & 0 deletions NUI/Core/Renderers/NUIControlRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ + (void)render:(UIControl*)control withClass:(NSString*)className
} else if ([NUISettings hasProperty:@"background-color" withClass:className]) {
[control setBackgroundColor: [NUISettings getColor:@"background-color" withClass: className]];
}

// Set tint
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[control setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

[NUIViewRenderer renderBorder:control withClass:className];
[NUIViewRenderer renderShadow:control withClass:className];
Expand Down
5 changes: 5 additions & 0 deletions NUI/Core/Renderers/NUILabelRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ + (void)render:(UILabel*)label withClass:(NSString*)className withSuffix:(NSStri
}
}

// Set tint
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[label setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

if ([NUISettings hasProperty:@"font-color" withClass:className]) {
label.textColor = [NUISettings getColor:@"font-color" withClass:className];
}
Expand Down
10 changes: 6 additions & 4 deletions NUI/Core/Renderers/NUINavigationBarRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ @implementation NUINavigationBarRenderer

+ (void)render:(UINavigationBar*)bar withClass:(NSString*)className
{
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}

if ([bar respondsToSelector:@selector(setBarTintColor:)]) {
if ([NUISettings hasProperty:@"bar-tint-color" withClass:className]) {
[bar setBarTintColor:[NUISettings getColor:@"bar-tint-color" withClass:className]];
}
}

if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}

if ([NUISettings hasProperty:@"background-image" withClass:className]) {
[bar setBackgroundImage:[NUISettings getImage:@"background-image" withClass:className] forBarMetrics:UIBarMetricsDefault];
}
Expand Down
8 changes: 7 additions & 1 deletion NUI/Core/Renderers/NUISearchBarRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ + (void)render:(UISearchBar*)bar withClass:(NSString*)className
[bar setBackgroundImage:[NUISettings getImageFromColor:@"background-color" withClass:className]];
}

if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}

Expand All @@ -32,6 +34,10 @@ + (void)render:(UISearchBar*)bar withClass:(NSString*)className
[bar setBackgroundImage:[NUISettings getImage:@"background-image" withClass:className]];
}

if ([NUISettings hasProperty:@"bar-tint-color" withClass:className]) {
[bar setBarTintColor:[NUISettings getColor:@"bar-tint-color" withClass:className]];
}

// Render scope bar

if ([NUISettings hasProperty:@"scope-background-color" withClass:className]) {
Expand Down
10 changes: 8 additions & 2 deletions NUI/Core/Renderers/NUISegmentedControlRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ + (void)render:(UISegmentedControl*)control withClass:(NSString*)className
[control setDividerImage:[NUISettings getImageFromColor:@"divider-color" withClass:className] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}

// Set background tint color
if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 70000
// UISegmentedControlStyleBar is necessary for setTintColor to take effect
control.segmentedControlStyle = UISegmentedControlStyleBar;
#endif
[control setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
// Set background tint color
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 70000
// UISegmentedControlStyleBar is necessary for setTintColor to take effect
control.segmentedControlStyle = UISegmentedControlStyleBar;
Expand Down
4 changes: 3 additions & 1 deletion NUI/Core/Renderers/NUITabBarRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ + (void)render:(UITabBar*)bar withClass:(NSString*)className
[bar setBackgroundImage:[NUISettings getImage:@"background-image" withClass:className]];
}

if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}

Expand Down
6 changes: 6 additions & 0 deletions NUI/Core/Renderers/NUITableViewCellRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ + (void)renderSizeDependentProperties:(UITableViewCell*)cell
frame:cell.bounds];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:gradientImage];
}

// Set tint
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[cell setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

}

@end
5 changes: 5 additions & 0 deletions NUI/Core/Renderers/NUITableViewRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ @implementation NUITableViewRenderer

+ (void)render:(UITableView*)tableView withClass:(NSString*)className
{
// Set tint
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[tableView setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

// Set seperator style
if ([NUISettings hasProperty:@"separator-style" withClass:className]) {
[tableView setSeparatorStyle:[NUISettings getSeparatorStyle:@"separator-style" withClass:className]];
Expand Down
5 changes: 5 additions & 0 deletions NUI/Core/Renderers/NUITextFieldRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ @implementation NUITextFieldRenderer

+ (void)render:(UITextField*)textField withClass:(NSString*)className
{
// Set tint
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[textField setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

if ([NUISettings hasFontPropertiesWithClass:className]) {
[textField setFont:[NUISettings getFontWithClass:className baseFont:textField.font]];
}
Expand Down
6 changes: 6 additions & 0 deletions NUI/Core/Renderers/NUITextViewRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ + (void)render:(UITextView*)textView withClass:(NSString*)className
{
NSString *property;

// Set tint
property = @"tint-color";
if ([NUISettings hasProperty:property withClass:className]) {
textView.tintColor = [NUISettings getColor:property withClass:className];
}

property = @"font-color";
if ([NUISettings hasProperty:property withClass:className]) {
textView.textColor = [NUISettings getColor:property withClass:className];
Expand Down
4 changes: 3 additions & 1 deletion NUI/Core/Renderers/NUIToolbarRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ + (void)render:(UIToolbar*)bar withClass:(NSString*)className
[bar setBackgroundImage:[NUISettings getImageFromColor:@"background-color" withClass:className] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
}

if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
} else if ([NUISettings hasProperty:@"background-tint-color" withClass:className]) {
[bar setTintColor:[NUISettings getColor:@"background-tint-color" withClass:className]];
}

Expand Down
3 changes: 3 additions & 0 deletions NUI/Core/Renderers/NUIViewRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ + (void)render:(UIView*)view withClass:(NSString*)className
} else if ([NUISettings hasProperty:@"background-color" withClass:className]) {
[view setBackgroundColor: [NUISettings getColor:@"background-color" withClass: className]];
}
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[view setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

[self renderSize:view withClass:className];
[self renderBorder:view withClass:className];
Expand Down
6 changes: 6 additions & 0 deletions NUI/Core/Renderers/NUIWindowRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ + (void)render:(UIWindow*)window withClass:(NSString*)className
if ([NUISettings hasProperty:@"background-color" withClass:className]) {
[window.rootViewController.view setBackgroundColor:[NUISettings getColor:@"background-color" withClass:className]];
}

// Set tint
if ([NUISettings hasProperty:@"tint-color" withClass:className]) {
[window.rootViewController.view setTintColor:[NUISettings getColor:@"tint-color" withClass:className]];
}

}

@end
Expand Down
Loading