Permalink
Browse files

added addStyleClass, removeStyleClass and styleClassed methods, updat…

…ed UITableViewTest
  • Loading branch information...
nuthinking committed Jun 23, 2014
1 parent 4e247ed commit 1c54d9c86e6de94c512e7f874a01cef09a359675
@@ -55,6 +55,10 @@
@property (nonatomic, copy) NSString *styleCSS;
@property (nonatomic) PXStylingMode styleMode UI_APPEARANCE_SELECTOR;
- (void)addStyleClass:(NSString *)styleClass;
- (void)removeStyleClass:(NSString *)styleClass;
- (void)styleClassed:(NSString *)styleClass enabled:(bool)enabled;
+ (void)updateStyles:(id<PXStyleable>)styleable recursively:(bool)recurse;
@end
@@ -584,6 +584,40 @@ - (id)valueForUndefinedKey:(NSString *)key
return (value != nil) ? value : [super valueForUndefinedKey:key];
}
- (void)addStyleClass:(NSString *)styleClass
{
if (self.styleClass){
self.styleClass = [NSString stringWithFormat:@"%@ %@", self.styleClass, [styleClass description]];
} else {
self.styleClass = [styleClass description];
}
}
- (void)removeStyleClass:(NSString *)styleClass
{
styleClass = [styleClass description];
NSMutableSet *mutSet = [NSMutableSet new];
[mutSet addObjectsFromArray:[styleClass componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
[mutSet removeObject:@""];
NSArray *classesToRemove = [mutSet allObjects];
NSArray *currentClasses = objc_getAssociatedObject(self, &STYLE_CLASSES_KEY);
mutSet = [[NSMutableSet alloc] initWithArray:currentClasses];
for (NSString *classToRemove in classesToRemove){
[mutSet removeObject:classToRemove];
}
NSArray *classes = [mutSet allObjects];
self.styleClass = [classes componentsJoinedByString:@" "];
}
- (void)styleClassed:(NSString *)styleClass enabled:(bool)enabled
{
if(enabled){
[self addStyleClass:styleClass];
}else{
[self removeStyleClass:styleClass];
}
}
@end
#pragma mark - Static Functions
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="f0k-Wg-Vhg">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13D65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="f0k-Wg-Vhg">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
@@ -99,6 +99,9 @@
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="view.styleClass" value="main"/>
</userDefinedRuntimeAttributes>
<connections>
<segue destination="K4c-iK-f2J" kind="relationship" relationship="rootViewController" id="Tro-h2-sOV"/>
</connections>
@@ -7,6 +7,7 @@
//
#import "ViewController.h"
#import "UIView+PXStyling.h"
@interface ViewController ()
@end
@@ -49,4 +50,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.parentViewController.view styleClassed:@"correct" enabled:(indexPath.row == 0)];
[self.parentViewController.view styleClassed:@"error" enabled:(indexPath.row != 0)];
}
@end
@@ -7,6 +7,7 @@
//
#import "ViewController2.h"
#import "UIView+PXStyling.h"
@interface ViewController2 ()
@@ -22,6 +23,7 @@ - (void)viewDidLoad
[super viewDidLoad];
_data = @[ @"Sally", @"Jane", @"Marry", @"Shannon" ];
NSLog(@"Parent style class: %@", self.navigationController.view.styleClass);
}
#pragma mark - Table view data source
@@ -1,25 +1,33 @@
pixate-config {
cache-styles: all;
}
table-view-cell:selected{
background-color: #4078BB;
}
table-view-cell {
.main table-view {
row-height: 60px;
}
#t1 table-view-cell {
background-color: yellow;
}
#t1 table-view-headerfooter-view label {
color: blue;
.correct table-view-cell {
background-color: green;
}
.error table-view-cell {
background-color: red;
}
table-view-headerfooter-view label {
font-size: 14;
font-family: "Gill Sans";
}
#t1 table-view-headerfooter-view label {
color: blue;
}
#t2 table-view-headerfooter-view label {
color: red;
font-size: 14;
font-family: "Gill Sans";
}

0 comments on commit 1c54d9c

Please sign in to comment.