Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Commit

Permalink
Merge pull request #111 from wearezeta/master
Browse files Browse the repository at this point in the history
Caching, styling per window, load on demand, system font support + tests
  • Loading branch information
mikeger authored Jul 12, 2016
2 parents c319908 + b27bae3 commit a1bcfef
Show file tree
Hide file tree
Showing 42 changed files with 431 additions and 87 deletions.
1 change: 1 addition & 0 deletions Carthage/Build
11 changes: 8 additions & 3 deletions Classy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
1EC7193A1B67AE9D00700A14 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0640;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = "Zeta Project Berlin Gmbh";
TargetAttributes = {
1EC719421B67AE9D00700A14 = {
Expand Down Expand Up @@ -504,6 +504,7 @@
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -573,30 +574,34 @@
1EC7195A1B67AE9D00700A14 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Classy/Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "wearezeta.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Classy;
SKIP_INSTALL = YES;
SKIP_INSTALL = NO;
};
name = Debug;
};
1EC7195B1B67AE9D00700A14 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Classy/Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "wearezeta.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Classy;
SKIP_INSTALL = YES;
SKIP_INSTALL = NO;
};
name = Release;
};
Expand Down
13 changes: 8 additions & 5 deletions Classy.xcodeproj/xcshareddata/xcschemes/Classy.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -23,21 +23,24 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -52,10 +55,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
2 changes: 1 addition & 1 deletion Classy/Additions/UIBarItem+CASAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "CASStyleableItem.h"

@interface UIBarItem (CASAdditions) <CASStyleableItem>

+ (void)bootstrapClassy;
@property (nonatomic, weak, readwrite) id<CASStyleableItem> cas_parent;

@end
2 changes: 1 addition & 1 deletion Classy/Additions/UIBarItem+CASAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @implementation UIBarItem (CASAdditions)
CASSynthesize(weak, id<CASStyleableItem>, cas_parent, setCas_parent);


+ (void)load {
+ (void)bootstrapClassy {
[self cas_swizzleInstanceSelector:@selector(init)
withNewSelector:@selector(cas_init)];
}
Expand Down
2 changes: 1 addition & 1 deletion Classy/Additions/UINavigationItem+CASAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
#import <UIKit/UIKit.h>

@interface UINavigationItem (CASAdditions)

+ (void)bootstrapClassy;
@end
4 changes: 2 additions & 2 deletions Classy/Additions/UINavigationItem+CASAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@implementation UINavigationItem (CASAdditions)

+ (void)load {
+ (void)bootstrapClassy {
[self cas_swizzleInstanceSelector:@selector(setRightBarButtonItem:animated:) withNewSelector:@selector(cas_setRightBarButtonItem:animated:)];
[self cas_swizzleInstanceSelector:@selector(setLeftBarButtonItem:animated:) withNewSelector:@selector(cas_setLeftBarButtonItem:animated:)];

Expand Down Expand Up @@ -45,4 +45,4 @@ - (void)cas_setLeftBarButtonItems:(NSArray *)items animated:(BOOL)animated {
[self cas_setLeftBarButtonItems:items animated:animated];
}

@end
@end
2 changes: 1 addition & 1 deletion Classy/Additions/UITextField+CASAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <UIKit/UIKit.h>

@interface UITextField (CASAdditions)

+ (void)bootstrapClassy;
@property (nonatomic, assign) UIEdgeInsets cas_textEdgeInsets;

@end
2 changes: 1 addition & 1 deletion Classy/Additions/UITextField+CASAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@implementation UITextField (CASAdditions)

+ (void)load {
+ (void)bootstrapClassy {
[self cas_swizzleInstanceSelector:@selector(textRectForBounds:)
withNewSelector:@selector(cas_textRectForBounds:)];

Expand Down
1 change: 1 addition & 0 deletions Classy/Additions/UIView+CASAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "CASStyleableItem.h"

@interface UIView (CASAdditions) <CASStyleableItem>
+ (void)bootstrapClassy;

@property (nonatomic, weak, readwrite) id<CASStyleableItem> cas_alternativeParent;
@property (nonatomic, copy) IBInspectable NSString *cas_styleClass;
Expand Down
2 changes: 1 addition & 1 deletion Classy/Additions/UIView+CASAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ @implementation UIView (CASAdditions)

CASSynthesize(weak, id<CASStyleableItem>, cas_alternativeParent, setCas_alternativeParent);

+ (void)load {
+ (void)bootstrapClassy {
[self cas_swizzleInstanceSelector:@selector(didMoveToWindow)
withNewSelector:@selector(cas_didMoveToWindow)];
}
Expand Down
2 changes: 1 addition & 1 deletion Classy/Additions/UIViewController+CASAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
#import "CASStyleableItem.h"

@interface UIViewController (CASAdditions) <CASStyleableItem>

+ (void)bootstrapClassy;
@end
2 changes: 1 addition & 1 deletion Classy/Additions/UIViewController+CASAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@implementation UIViewController (CASAdditions)

+ (void)load {
+ (void)bootstrapClassy {
[self cas_swizzleInstanceSelector:@selector(setView:)
withNewSelector:@selector(cas_setView:)];
}
Expand Down
2 changes: 2 additions & 0 deletions Classy/Classy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@
#import "UINavigationBar+CASAdditions.h"
#import "UITabBar+CASAdditions.h"
#import "UIToolbar+CASAdditions.h"
#import "UIViewController+CASAdditions.h"
#import "UINavigationItem+CASAdditions.h"
16 changes: 16 additions & 0 deletions Classy/Parser/CASDeviceOSVersionItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@ - (NSString *)stringValue {
return [NSString stringWithFormat:@"(version:%@%@)", [CASDeviceSelector stringFromRelation:self.relation], self.version];
}

#pragma mark - NSCoding

- (id)initWithCoder:(NSCoder *)aDecoder {
self = [self init];
if (nil != self) {
self.relation = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(relation))];
self.version = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(version))];
}
return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeInteger:self.relation forKey:NSStringFromSelector(@selector(relation))];
[aCoder encodeObject:self.version forKey:NSStringFromSelector(@selector(version))];
}

@end
2 changes: 1 addition & 1 deletion Classy/Parser/CASDeviceScreenSizeItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
@property (nonatomic, assign) CASRelation relation;
@property(nonatomic, assign) CASDeviceSelectorScreenDimension dimension;

@end
@end
23 changes: 19 additions & 4 deletions Classy/Parser/CASDeviceScreenSizeItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

#import "CASDeviceScreenSizeItem.h"

@implementation CASDeviceScreenSizeItem {

}
@implementation CASDeviceScreenSizeItem

- (BOOL)isValid {
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
Expand Down Expand Up @@ -41,5 +39,22 @@ - (NSString *)stringValue {
return [NSString stringWithFormat:@"(screen-%@:%@%.0f)", dimensionString, [CASDeviceSelector stringFromRelation:self.relation], self.value];
}

#pragma mark - NSCoding

- (id)initWithCoder:(NSCoder *)aDecoder {
self = [self init];
if (nil != self) {
self.relation = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(relation))];
self.value = [aDecoder decodeFloatForKey:NSStringFromSelector(@selector(value))];
self.dimension = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(dimension))];
}
return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeInteger:self.relation forKey:NSStringFromSelector(@selector(relation))];
[aCoder encodeFloat:self.value forKey:NSStringFromSelector(@selector(value))];
[aCoder encodeInteger:self.dimension forKey:NSStringFromSelector(@selector(dimension))];
}

@end
@end
2 changes: 1 addition & 1 deletion Classy/Parser/CASDeviceSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ typedef NS_ENUM(NSUInteger, CASDeviceSelectorScreenDimension) {
CASDeviceSelectorScreenDimensionHeight,
};

@interface CASDeviceSelector : NSObject
@interface CASDeviceSelector : NSObject <NSCoding>

@property (nonatomic, strong, readonly) NSArray *items;

Expand Down
14 changes: 14 additions & 0 deletions Classy/Parser/CASDeviceSelector.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,18 @@ + (NSString *)stringFromRelation:(CASRelation)relation {
}
}

#pragma mark - NSCoding

- (id)initWithCoder:(NSCoder *)aDecoder {
self = [self init];
if (nil != self) {
_items = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(items))];
}
return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:self.items forKey:NSStringFromSelector(@selector(items))];
}

@end
4 changes: 2 additions & 2 deletions Classy/Parser/CASDeviceSelectorItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ typedef NS_ENUM(NSInteger, CASRelation) {
CASRelationUndefined = NSNotFound,
};

@protocol CASDeviceSelectorItem <NSObject>
@protocol CASDeviceSelectorItem <NSObject, NSCoding>

- (BOOL)isValid;
- (NSString *)stringValue;

@end
@end
14 changes: 14 additions & 0 deletions Classy/Parser/CASDeviceTypeItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@ - (NSString *)stringValue {
return @"pad";
}

#pragma mark - NSCoding

- (id)initWithCoder:(NSCoder *)aDecoder {
self = [self init];
if (nil != self) {
self.deviceType = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(deviceType))];
}
return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeInteger:self.deviceType forKey:NSStringFromSelector(@selector(deviceType))];
}

@end
2 changes: 1 addition & 1 deletion Classy/Parser/CASStyleNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import "CASStyleSelector.h"
#import "CASDeviceSelector.h"

@interface CASStyleNode : NSObject
@interface CASStyleNode : NSObject <NSCoding>

/**
* NSInvocations to apply to appropriate view
Expand Down
19 changes: 19 additions & 0 deletions Classy/Parser/CASStyleNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,23 @@ - (void)addStyleProperty:(CASStyleProperty *)styleProperty {
[_styleProperties addObject:styleProperty];
}

#pragma mark - NSCoding

- (id)initWithCoder:(NSCoder *)aDecoder {
self = [self init];
if (nil != self) {
self.invocations = nil;
_styleProperties = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(styleProperties))];
self.styleSelector = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(styleSelector))];
self.deviceSelector = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(deviceSelector))];
}
return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:self.styleProperties forKey:NSStringFromSelector(@selector(styleProperties))];
[aCoder encodeObject:self.styleSelector forKey:NSStringFromSelector(@selector(styleSelector))];
[aCoder encodeObject:self.deviceSelector forKey:NSStringFromSelector(@selector(deviceSelector))];
}

@end
4 changes: 2 additions & 2 deletions Classy/Parser/CASStyleProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import <UIKit/UIKit.h>
#import "CASToken.h"

@interface CASStyleProperty : NSObject
@interface CASStyleProperty : NSObject <NSCoding>

/**
* Name of the receiver
Expand Down Expand Up @@ -44,7 +44,7 @@
@property (nonatomic, strong) NSDictionary *arguments;

/**
* Creates property with raw data in the form of CATokens
* Creates property with raw data in the form of CASTokens
*/
- (id)initWithNameToken:(CASToken *)nameToken valueTokens:(NSArray *)valueTokens;

Expand Down
Loading

0 comments on commit a1bcfef

Please sign in to comment.