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 all 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
41 changes: 41 additions & 0 deletions Demo/NUIDemo.xcworkspace/xcshareddata/NUIDemo.xccheckout
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>A46DCE8E-2747-4AE8-B2D7-5BEE7F39F863</string>
<key>IDESourceControlProjectName</key>
<string>NUIDemo</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<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>2F95D1B34DFEF3E924668F657F0C00B5BE26A2AC</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/squarefrog/nui.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>2F95D1B34DFEF3E924668F657F0C00B5BE26A2AC</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>2F95D1B34DFEF3E924668F657F0C00B5BE26A2AC</string>
<key>IDESourceControlWCCName</key>
<string>nui</string>
</dict>
</array>
</dict>
</plist>
4 changes: 2 additions & 2 deletions NUI.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Pod::Spec.new do |s|
s.version = "0.5.5"
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 setBackgroundColor:[NUISettings getColor:@"background-color" withClass:className]];
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,6 +12,12 @@ @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]];
Expand All @@ -21,10 +27,6 @@ + (void)render:(UINavigationBar*)bar withClass:(NSString*)className
if ([NUISettings hasProperty:@"background-color" withClass:className]) {
[bar setBackgroundColor:[NUISettings getColor:@"background-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
6 changes: 6 additions & 0 deletions NUI/Core/Renderers/NUITabBarRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ + (void)render:(UITabBar*)bar withClass:(NSString*)className
[bar setBackgroundImage:[NUISettings getImage:property 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]];
}

property = @"selected-image";
if ([NUISettings hasProperty:property withClass:className]) {
[bar setSelectionIndicatorImage:[NUISettings getImage:property 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 @@ -75,6 +75,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 @@ -14,6 +14,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 @@ -8,6 +8,12 @@ + (void)render:(UITextView*)textView withClass:(NSString*)className

[super render:textView withClass: className];

// 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