Skip to content

Commit

Permalink
Example project is fully functional
Browse files Browse the repository at this point in the history
  • Loading branch information
JARinteractive authored and JARinteractive committed Jul 27, 2013
1 parent 23cc658 commit a10f1af
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 66 deletions.
52 changes: 41 additions & 11 deletions example/ESCColorPicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
objects = {

/* Begin PBXBuildFile section */
4D22504317A39814007CABA0 /* Default-568h.png in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504117A39814007CABA0 /* Default-568h.png */; };
4D22504417A39814007CABA0 /* Default-568h.png in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504117A39814007CABA0 /* Default-568h.png */; };
4D22504517A39814007CABA0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504217A39814007CABA0 /* [email protected] */; };
4D22504617A39814007CABA0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504217A39814007CABA0 /* [email protected] */; };
4D22504917A39875007CABA0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504717A39875007CABA0 /* Default.png */; };
4D22504A17A39875007CABA0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504717A39875007CABA0 /* Default.png */; };
4D22504B17A39875007CABA0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504817A39875007CABA0 /* [email protected] */; };
4D22504C17A39875007CABA0 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4D22504817A39875007CABA0 /* [email protected] */; };
4D8A6E571794F74A00C4335D /* ESCGradientSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D8A6E561794F74A00C4335D /* ESCGradientSlider.m */; };
4D8A6E581794F74A00C4335D /* ESCGradientSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D8A6E561794F74A00C4335D /* ESCGradientSlider.m */; };
4DD5C9D51794EA3200BB1615 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DD5C9D41794EA3200BB1615 /* Foundation.framework */; };
Expand Down Expand Up @@ -70,6 +78,10 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
4D22504117A39814007CABA0 /* Default-568h.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h.png"; sourceTree = "<group>"; };
4D22504217A39814007CABA0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
4D22504717A39875007CABA0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
4D22504817A39875007CABA0 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
4D8A6E551794F74A00C4335D /* ESCGradientSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ESCGradientSlider.h; sourceTree = "<group>"; };
4D8A6E561794F74A00C4335D /* ESCGradientSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ESCGradientSlider.m; sourceTree = "<group>"; };
4DD5C9D11794EA3200BB1615 /* ESCColorPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ESCColorPicker.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -131,6 +143,19 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
4D22504D17A39923007CABA0 /* custom controls */ = {
isa = PBXGroup;
children = (
4D8A6E551794F74A00C4335D /* ESCGradientSlider.h */,
4D8A6E561794F74A00C4335D /* ESCGradientSlider.m */,
4DD84E901798E2F4006B609D /* ESCHueWheel.h */,
4DD84E911798E2F4006B609D /* ESCHueWheel.m */,
4DD84E941798EB25006B609D /* ESCColorControlThumb.h */,
4DD84E951798EB25006B609D /* ESCColorControlThumb.m */,
);
name = "custom controls";
sourceTree = "<group>";
};
4DD5C9C81794EA3200BB1615 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -166,21 +191,16 @@
4DD5C9DA1794EA3200BB1615 /* ESCColorPicker */ = {
isa = PBXGroup;
children = (
4D22504D17A39923007CABA0 /* custom controls */,
4DD5CA1A1794F56000BB1615 /* lifecycle */,
4DD84E4017979B91006B609D /* ESCColorPickerModel.h */,
4DD84E4117979B91006B609D /* ESCColorPickerModel.m */,
4DD84EAB179B72BE006B609D /* ESCColorPickerModelTest.m */,
4DD5CA161794F47F00BB1615 /* ESCColorPickerView.h */,
4DD5CA171794F47F00BB1615 /* ESCColorPickerView.m */,
4D8A6E551794F74A00C4335D /* ESCGradientSlider.h */,
4D8A6E561794F74A00C4335D /* ESCGradientSlider.m */,
4DD84E3A17979B6E006B609D /* ESCColorPickerPresenter.h */,
4DD84E3B17979B6E006B609D /* ESCColorPickerPresenter.m */,
4DD84EB1179B7985006B609D /* ESCColorPickerPresenterTest.m */,
4DD84E4017979B91006B609D /* ESCColorPickerModel.h */,
4DD84E4117979B91006B609D /* ESCColorPickerModel.m */,
4DD84EAB179B72BE006B609D /* ESCColorPickerModelTest.m */,
4DD84E901798E2F4006B609D /* ESCHueWheel.h */,
4DD84E911798E2F4006B609D /* ESCHueWheel.m */,
4DD84E941798EB25006B609D /* ESCColorControlThumb.h */,
4DD84E951798EB25006B609D /* ESCColorControlThumb.m */,
4DD5C9E61794EA3200BB1615 /* Images.xcassets */,
4DD5C9DB1794EA3200BB1615 /* Supporting Files */,
);
Expand All @@ -190,6 +210,10 @@
4DD5C9DB1794EA3200BB1615 /* Supporting Files */ = {
isa = PBXGroup;
children = (
4D22504717A39875007CABA0 /* Default.png */,
4D22504817A39875007CABA0 /* [email protected] */,
4D22504117A39814007CABA0 /* Default-568h.png */,
4D22504217A39814007CABA0 /* [email protected] */,
4DD5C9DC1794EA3200BB1615 /* ESCColorPicker-Info.plist */,
4DD5C9DD1794EA3200BB1615 /* InfoPlist.strings */,
4DD5C9E01794EA3200BB1615 /* main.m */,
Expand Down Expand Up @@ -321,15 +345,23 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4D22504B17A39875007CABA0 /* [email protected] in Resources */,
4D22504317A39814007CABA0 /* Default-568h.png in Resources */,
4DD5C9DF1794EA3200BB1615 /* InfoPlist.strings in Resources */,
4DD5C9E71794EA3200BB1615 /* Images.xcassets in Resources */,
4D22504517A39814007CABA0 /* [email protected] in Resources */,
4D22504917A39875007CABA0 /* Default.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
4DD5C9EA1794EA3200BB1615 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4D22504C17A39875007CABA0 /* [email protected] in Resources */,
4D22504417A39814007CABA0 /* Default-568h.png in Resources */,
4D22504A17A39875007CABA0 /* Default.png in Resources */,
4D22504617A39814007CABA0 /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -476,7 +508,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ESCColorPicker/ESCColorPicker-Prefix.pch";
INFOPLIST_FILE = "ESCColorPicker/ESCColorPicker-Info.plist";
Expand All @@ -490,7 +521,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ESCColorPicker/ESCColorPicker-Prefix.pch";
INFOPLIST_FILE = "ESCColorPicker/ESCColorPicker-Info.plist";
Expand Down
Binary file added example/ESCColorPicker/Default-568h.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/ESCColorPicker/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/ESCColorPicker/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/ESCColorPicker/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions example/ESCColorPicker/ESCAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,4 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
}

- (void)applicationWillTerminate:(UIApplication *)application {
}

@end
39 changes: 38 additions & 1 deletion example/ESCColorPicker/ESCColorPicker-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,53 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchImageFile</key>
<string>Default</string>
<key>UILaunchImages</key>
<array>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>Default</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{320, 480}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>Default</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{320, 568}</string>
</dict>
<dict>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageName</key>
<string>splash-4in-retina</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
<string>{320, 568}</string>
</dict>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<string>UIStatusBarStyleBlackOpaque</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
</dict>
</plist>
7 changes: 7 additions & 0 deletions example/ESCColorPicker/ESCColorPickerModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@

@end

typedef enum {
ESCColorPickerModelDescriptionFormatHSB,
ESCColorPickerModelDescriptionFormatRGB,
ESCColorPickerModelDescriptionFormatRGBHex,
} ESCColorPickerModelDescriptionFormat;

@interface ESCColorPickerModel : NSObject<ESCObservable>

@property (nonatomic) CGFloat hue;
@property (nonatomic) CGFloat saturation;
@property (nonatomic) CGFloat brightness;

@property (nonatomic) ESCColorPickerModelDescriptionFormat descriptionFormat;
@property (nonatomic) NSArray *colorDescriptionKeys;
@property (nonatomic) NSArray *colorDescriptionValues;

Expand Down
40 changes: 35 additions & 5 deletions example/ESCColorPicker/ESCColorPickerModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,42 @@ - (void)setBrightness:(CGFloat)brightness {
[self.escNotifier colorDidChange];
}

- (void)setDescriptionFormat:(ESCColorPickerModelDescriptionFormat)descriptionFormat {
_descriptionFormat = descriptionFormat;
[self updateDescription];
}

- (NSString *)formattedFloat:(CGFloat)floatToFormat {
return [NSString stringWithFormat:@"%.3f", floatToFormat];
}

- (void)updateDescription {
self.colorDescriptionKeys = @[@"H", @"S", @"B"];
NSString *formatString = @"%.3f";
self.colorDescriptionValues = @[[NSString stringWithFormat:formatString, self.hue],
[NSString stringWithFormat:formatString, self.saturation],
[NSString stringWithFormat:formatString, self.brightness]];
if (self.descriptionFormat == ESCColorPickerModelDescriptionFormatHSB) {
self.colorDescriptionKeys = @[@"H", @"S", @"B"];

NSString *formatString = @"%.3f";
self.colorDescriptionValues = @[[NSString stringWithFormat:formatString, self.hue],
[NSString stringWithFormat:formatString, self.saturation],
[NSString stringWithFormat:formatString, self.brightness]];
} else if (self.descriptionFormat == ESCColorPickerModelDescriptionFormatRGB) {
self.colorDescriptionKeys = @[@"R", @"G", @"B"];

NSString *formatString = @"%.3f";
UIColor *hsbColor = [UIColor colorWithHue:self.hue saturation:self.saturation brightness:self.brightness alpha:1.0];
CGFloat red, green, blue;
[hsbColor getRed:&red green:&green blue:&blue alpha:NULL];
self.colorDescriptionValues = @[[NSString stringWithFormat:formatString, red],
[NSString stringWithFormat:formatString, green],
[NSString stringWithFormat:formatString, blue]];
} else if (self.descriptionFormat == ESCColorPickerModelDescriptionFormatRGBHex) {
self.colorDescriptionKeys = @[@"#"];

UIColor *hsbColor = [UIColor colorWithHue:self.hue saturation:self.saturation brightness:self.brightness alpha:1.0];
CGFloat red, green, blue;
[hsbColor getRed:&red green:&green blue:&blue alpha:NULL];
self.colorDescriptionValues = @[[NSString stringWithFormat:@"%02X%02X%02X", (NSUInteger)(red * 255), (NSUInteger)(green * 255), (NSUInteger)(blue * 255)]];
}

[self.escNotifier colorDescriptionDidChangeKeys:self.colorDescriptionKeys values:self.colorDescriptionValues];
}

Expand Down
14 changes: 14 additions & 0 deletions example/ESCColorPicker/ESCColorPickerModelTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,18 @@ - (void)testModelSendsDescriptionEventWhenColorChanges {
[self.mockObserver verify];
}

- (void)testModelSendsDescriptionEventWhenColorFormatChanges {
[[self.mockObserver expect] colorDescriptionDidChangeKeys:@[@"R", @"G", @"B"] values:@[@"0.376", @"0.400", @"0.280"]];
self.testObject.descriptionFormat = ESCColorPickerModelDescriptionFormatRGB;
[self.mockObserver verify];

[[self.mockObserver expect] colorDescriptionDidChangeKeys:@[@"#"] values:@[@"5F6647"]];
self.testObject.descriptionFormat = ESCColorPickerModelDescriptionFormatRGBHex;
[self.mockObserver verify];

[[self.mockObserver expect] colorDescriptionDidChangeKeys:@[@"H", @"S", @"B"] values:@[@"0.200", @"0.300", @"0.400"]];
self.testObject.descriptionFormat = ESCColorPickerModelDescriptionFormatHSB;
[self.mockObserver verify];
}

@end
4 changes: 4 additions & 0 deletions example/ESCColorPicker/ESCColorPickerPresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ - (void)colorDescriptionDidChangeKeys:(NSArray *)keys values:(NSArray *)values {
[self.view setColorDescriptionKeys:keys values:values];
}

- (void)colorDescriptionTapped {
self.model.descriptionFormat = (self.model.descriptionFormat + 1) % 3;
}

@end
22 changes: 22 additions & 0 deletions example/ESCColorPicker/ESCColorPickerPresenterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,26 @@ - (void)testWhenDescriptionChangeEventFiresThenDescriptionKeysAndValuesAreSetOnV
[self.mockView verify];
}

- (void)testWhenColorDescriptionTappedThenDescriptionFormatIsChanged {
[[[self.mockModel expect] andReturnValue:@(0)] descriptionFormat];
[[self.mockModel expect] setDescriptionFormat:ESCColorPickerModelDescriptionFormatRGB];
[[self.mockView escNotifier] colorDescriptionTapped];
[self.mockModel verify];

[[[self.mockModel expect] andReturnValue:@(1)] descriptionFormat];
[[self.mockModel expect] setDescriptionFormat:ESCColorPickerModelDescriptionFormatRGBHex];
[[self.mockView escNotifier] colorDescriptionTapped];
[self.mockModel verify];

[[[self.mockModel expect] andReturnValue:@(2)] descriptionFormat];
[[self.mockModel expect] setDescriptionFormat:ESCColorPickerModelDescriptionFormatHSB];
[[self.mockView escNotifier] colorDescriptionTapped];
[self.mockModel verify];

[[[self.mockModel expect] andReturnValue:@(0)] descriptionFormat];
[[self.mockModel expect] setDescriptionFormat:ESCColorPickerModelDescriptionFormatRGB];
[[self.mockView escNotifier] colorDescriptionTapped];
[self.mockModel verify];
}

@end
1 change: 1 addition & 0 deletions example/ESCColorPicker/ESCColorPickerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- (void)hueDidChange:(CGFloat)hue;
- (void)saturationDidChange:(CGFloat)saturation;
- (void)brightnessDidChange:(CGFloat)brightness;
- (void)colorDescriptionTapped;

@end

Expand Down
Loading

0 comments on commit a10f1af

Please sign in to comment.