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

Commit a1bcfef

Browse files
authored
Merge pull request #111 from wearezeta/master
Caching, styling per window, load on demand, system font support + tests
2 parents c319908 + b27bae3 commit a1bcfef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+431
-87
lines changed

Carthage/Build

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../Carthage/Build

Classy.xcodeproj/project.pbxproj

+8-3
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@
383383
1EC7193A1B67AE9D00700A14 /* Project object */ = {
384384
isa = PBXProject;
385385
attributes = {
386-
LastUpgradeCheck = 0640;
386+
LastUpgradeCheck = 0710;
387387
ORGANIZATIONNAME = "Zeta Project Berlin Gmbh";
388388
TargetAttributes = {
389389
1EC719421B67AE9D00700A14 = {
@@ -504,6 +504,7 @@
504504
CURRENT_PROJECT_VERSION = 1;
505505
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
506506
ENABLE_STRICT_OBJC_MSGSEND = YES;
507+
ENABLE_TESTABILITY = YES;
507508
GCC_C_LANGUAGE_STANDARD = gnu99;
508509
GCC_DYNAMIC_NO_PIC = NO;
509510
GCC_NO_COMMON_BLOCKS = YES;
@@ -573,30 +574,34 @@
573574
1EC7195A1B67AE9D00700A14 /* Debug */ = {
574575
isa = XCBuildConfiguration;
575576
buildSettings = {
577+
APPLICATION_EXTENSION_API_ONLY = YES;
576578
DEFINES_MODULE = YES;
577579
DYLIB_COMPATIBILITY_VERSION = 1;
578580
DYLIB_CURRENT_VERSION = 1;
579581
DYLIB_INSTALL_NAME_BASE = "@rpath";
580582
INFOPLIST_FILE = "Classy/Supporting Files/Info.plist";
581583
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
582584
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
585+
PRODUCT_BUNDLE_IDENTIFIER = "wearezeta.$(PRODUCT_NAME:rfc1034identifier)";
583586
PRODUCT_NAME = Classy;
584-
SKIP_INSTALL = YES;
587+
SKIP_INSTALL = NO;
585588
};
586589
name = Debug;
587590
};
588591
1EC7195B1B67AE9D00700A14 /* Release */ = {
589592
isa = XCBuildConfiguration;
590593
buildSettings = {
594+
APPLICATION_EXTENSION_API_ONLY = YES;
591595
DEFINES_MODULE = YES;
592596
DYLIB_COMPATIBILITY_VERSION = 1;
593597
DYLIB_CURRENT_VERSION = 1;
594598
DYLIB_INSTALL_NAME_BASE = "@rpath";
595599
INFOPLIST_FILE = "Classy/Supporting Files/Info.plist";
596600
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
597601
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
602+
PRODUCT_BUNDLE_IDENTIFIER = "wearezeta.$(PRODUCT_NAME:rfc1034identifier)";
598603
PRODUCT_NAME = Classy;
599-
SKIP_INSTALL = YES;
604+
SKIP_INSTALL = NO;
600605
};
601606
name = Release;
602607
};

Classy.xcodeproj/xcshareddata/xcschemes/Classy.xcscheme

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0640"
3+
LastUpgradeVersion = "0710"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -23,21 +23,24 @@
2323
</BuildActionEntries>
2424
</BuildAction>
2525
<TestAction
26+
buildConfiguration = "Debug"
2627
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2728
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28-
shouldUseLaunchSchemeArgsEnv = "YES"
29-
buildConfiguration = "Debug">
29+
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
3131
</Testables>
32+
<AdditionalOptions>
33+
</AdditionalOptions>
3234
</TestAction>
3335
<LaunchAction
36+
buildConfiguration = "Debug"
3437
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3538
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3639
launchStyle = "0"
3740
useCustomWorkingDirectory = "NO"
38-
buildConfiguration = "Debug"
3941
ignoresPersistentStateOnLaunch = "NO"
4042
debugDocumentVersioning = "YES"
43+
debugServiceExtension = "internal"
4144
allowLocationSimulation = "YES">
4245
<MacroExpansion>
4346
<BuildableReference
@@ -52,10 +55,10 @@
5255
</AdditionalOptions>
5356
</LaunchAction>
5457
<ProfileAction
58+
buildConfiguration = "Release"
5559
shouldUseLaunchSchemeArgsEnv = "YES"
5660
savedToolIdentifier = ""
5761
useCustomWorkingDirectory = "NO"
58-
buildConfiguration = "Release"
5962
debugDocumentVersioning = "YES">
6063
<MacroExpansion>
6164
<BuildableReference

Classy/Additions/UIBarItem+CASAdditions.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "CASStyleableItem.h"
1111

1212
@interface UIBarItem (CASAdditions) <CASStyleableItem>
13-
13+
+ (void)bootstrapClassy;
1414
@property (nonatomic, weak, readwrite) id<CASStyleableItem> cas_parent;
1515

1616
@end

Classy/Additions/UIBarItem+CASAdditions.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ @implementation UIBarItem (CASAdditions)
1919
CASSynthesize(weak, id<CASStyleableItem>, cas_parent, setCas_parent);
2020

2121

22-
+ (void)load {
22+
+ (void)bootstrapClassy {
2323
[self cas_swizzleInstanceSelector:@selector(init)
2424
withNewSelector:@selector(cas_init)];
2525
}

Classy/Additions/UINavigationItem+CASAdditions.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
#import <UIKit/UIKit.h>
1010

1111
@interface UINavigationItem (CASAdditions)
12-
12+
+ (void)bootstrapClassy;
1313
@end

Classy/Additions/UINavigationItem+CASAdditions.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@implementation UINavigationItem (CASAdditions)
1515

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

@@ -45,4 +45,4 @@ - (void)cas_setLeftBarButtonItems:(NSArray *)items animated:(BOOL)animated {
4545
[self cas_setLeftBarButtonItems:items animated:animated];
4646
}
4747

48-
@end
48+
@end

Classy/Additions/UITextField+CASAdditions.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import <UIKit/UIKit.h>
1010

1111
@interface UITextField (CASAdditions)
12-
12+
+ (void)bootstrapClassy;
1313
@property (nonatomic, assign) UIEdgeInsets cas_textEdgeInsets;
1414

1515
@end

Classy/Additions/UITextField+CASAdditions.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@implementation UITextField (CASAdditions)
1414

15-
+ (void)load {
15+
+ (void)bootstrapClassy {
1616
[self cas_swizzleInstanceSelector:@selector(textRectForBounds:)
1717
withNewSelector:@selector(cas_textRectForBounds:)];
1818

Classy/Additions/UIView+CASAdditions.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import "CASStyleableItem.h"
1111

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

1415
@property (nonatomic, weak, readwrite) id<CASStyleableItem> cas_alternativeParent;
1516
@property (nonatomic, copy) IBInspectable NSString *cas_styleClass;

Classy/Additions/UIView+CASAdditions.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ @implementation UIView (CASAdditions)
2121

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

24-
+ (void)load {
24+
+ (void)bootstrapClassy {
2525
[self cas_swizzleInstanceSelector:@selector(didMoveToWindow)
2626
withNewSelector:@selector(cas_didMoveToWindow)];
2727
}

Classy/Additions/UIViewController+CASAdditions.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
#import "CASStyleableItem.h"
1111

1212
@interface UIViewController (CASAdditions) <CASStyleableItem>
13-
13+
+ (void)bootstrapClassy;
1414
@end

Classy/Additions/UIViewController+CASAdditions.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@implementation UIViewController (CASAdditions)
2121

22-
+ (void)load {
22+
+ (void)bootstrapClassy {
2323
[self cas_swizzleInstanceSelector:@selector(setView:)
2424
withNewSelector:@selector(cas_setView:)];
2525
}

Classy/Classy.h

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@
2222
#import "UINavigationBar+CASAdditions.h"
2323
#import "UITabBar+CASAdditions.h"
2424
#import "UIToolbar+CASAdditions.h"
25+
#import "UIViewController+CASAdditions.h"
26+
#import "UINavigationItem+CASAdditions.h"

Classy/Parser/CASDeviceOSVersionItem.m

+16
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,20 @@ - (NSString *)stringValue {
3434
return [NSString stringWithFormat:@"(version:%@%@)", [CASDeviceSelector stringFromRelation:self.relation], self.version];
3535
}
3636

37+
#pragma mark - NSCoding
38+
39+
- (id)initWithCoder:(NSCoder *)aDecoder {
40+
self = [self init];
41+
if (nil != self) {
42+
self.relation = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(relation))];
43+
self.version = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(version))];
44+
}
45+
return self;
46+
}
47+
48+
- (void)encodeWithCoder:(NSCoder *)aCoder {
49+
[aCoder encodeInteger:self.relation forKey:NSStringFromSelector(@selector(relation))];
50+
[aCoder encodeObject:self.version forKey:NSStringFromSelector(@selector(version))];
51+
}
52+
3753
@end

Classy/Parser/CASDeviceScreenSizeItem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
@property (nonatomic, assign) CASRelation relation;
1515
@property(nonatomic, assign) CASDeviceSelectorScreenDimension dimension;
1616

17-
@end
17+
@end

Classy/Parser/CASDeviceScreenSizeItem.m

+19-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
#import "CASDeviceScreenSizeItem.h"
77

8-
@implementation CASDeviceScreenSizeItem {
9-
10-
}
8+
@implementation CASDeviceScreenSizeItem
119

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

42+
#pragma mark - NSCoding
43+
44+
- (id)initWithCoder:(NSCoder *)aDecoder {
45+
self = [self init];
46+
if (nil != self) {
47+
self.relation = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(relation))];
48+
self.value = [aDecoder decodeFloatForKey:NSStringFromSelector(@selector(value))];
49+
self.dimension = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(dimension))];
50+
}
51+
return self;
52+
}
53+
54+
- (void)encodeWithCoder:(NSCoder *)aCoder {
55+
[aCoder encodeInteger:self.relation forKey:NSStringFromSelector(@selector(relation))];
56+
[aCoder encodeFloat:self.value forKey:NSStringFromSelector(@selector(value))];
57+
[aCoder encodeInteger:self.dimension forKey:NSStringFromSelector(@selector(dimension))];
58+
}
4459

45-
@end
60+
@end

Classy/Parser/CASDeviceSelector.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef NS_ENUM(NSUInteger, CASDeviceSelectorScreenDimension) {
1515
CASDeviceSelectorScreenDimensionHeight,
1616
};
1717

18-
@interface CASDeviceSelector : NSObject
18+
@interface CASDeviceSelector : NSObject <NSCoding>
1919

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

Classy/Parser/CASDeviceSelector.m

+14
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,18 @@ + (NSString *)stringFromRelation:(CASRelation)relation {
135135
}
136136
}
137137

138+
#pragma mark - NSCoding
139+
140+
- (id)initWithCoder:(NSCoder *)aDecoder {
141+
self = [self init];
142+
if (nil != self) {
143+
_items = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(items))];
144+
}
145+
return self;
146+
}
147+
148+
- (void)encodeWithCoder:(NSCoder *)aCoder {
149+
[aCoder encodeObject:self.items forKey:NSStringFromSelector(@selector(items))];
150+
}
151+
138152
@end

Classy/Parser/CASDeviceSelectorItem.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ typedef NS_ENUM(NSInteger, CASRelation) {
1717
CASRelationUndefined = NSNotFound,
1818
};
1919

20-
@protocol CASDeviceSelectorItem <NSObject>
20+
@protocol CASDeviceSelectorItem <NSObject, NSCoding>
2121

2222
- (BOOL)isValid;
2323
- (NSString *)stringValue;
2424

25-
@end
25+
@end

Classy/Parser/CASDeviceTypeItem.m

+14
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,18 @@ - (NSString *)stringValue {
2525
return @"pad";
2626
}
2727

28+
#pragma mark - NSCoding
29+
30+
- (id)initWithCoder:(NSCoder *)aDecoder {
31+
self = [self init];
32+
if (nil != self) {
33+
self.deviceType = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(deviceType))];
34+
}
35+
return self;
36+
}
37+
38+
- (void)encodeWithCoder:(NSCoder *)aCoder {
39+
[aCoder encodeInteger:self.deviceType forKey:NSStringFromSelector(@selector(deviceType))];
40+
}
41+
2842
@end

Classy/Parser/CASStyleNode.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import "CASStyleSelector.h"
1212
#import "CASDeviceSelector.h"
1313

14-
@interface CASStyleNode : NSObject
14+
@interface CASStyleNode : NSObject <NSCoding>
1515

1616
/**
1717
* NSInvocations to apply to appropriate view

Classy/Parser/CASStyleNode.m

+19
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,23 @@ - (void)addStyleProperty:(CASStyleProperty *)styleProperty {
2727
[_styleProperties addObject:styleProperty];
2828
}
2929

30+
#pragma mark - NSCoding
31+
32+
- (id)initWithCoder:(NSCoder *)aDecoder {
33+
self = [self init];
34+
if (nil != self) {
35+
self.invocations = nil;
36+
_styleProperties = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(styleProperties))];
37+
self.styleSelector = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(styleSelector))];
38+
self.deviceSelector = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(deviceSelector))];
39+
}
40+
return self;
41+
}
42+
43+
- (void)encodeWithCoder:(NSCoder *)aCoder {
44+
[aCoder encodeObject:self.styleProperties forKey:NSStringFromSelector(@selector(styleProperties))];
45+
[aCoder encodeObject:self.styleSelector forKey:NSStringFromSelector(@selector(styleSelector))];
46+
[aCoder encodeObject:self.deviceSelector forKey:NSStringFromSelector(@selector(deviceSelector))];
47+
}
48+
3049
@end

Classy/Parser/CASStyleProperty.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import <UIKit/UIKit.h>
1111
#import "CASToken.h"
1212

13-
@interface CASStyleProperty : NSObject
13+
@interface CASStyleProperty : NSObject <NSCoding>
1414

1515
/**
1616
* Name of the receiver
@@ -44,7 +44,7 @@
4444
@property (nonatomic, strong) NSDictionary *arguments;
4545

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

0 commit comments

Comments
 (0)