Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into color
Browse files Browse the repository at this point in the history
  • Loading branch information
sgl0v committed Aug 16, 2015
2 parents 6e6fca5 + a895274 commit 4b87bf8
Show file tree
Hide file tree
Showing 36 changed files with 1,555 additions and 274 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: objective-c
script: xctool test -project FBTweak.xcodeproj -scheme FBTweak -sdk iphonesimulator8.1 -destination "platform=iOS Simulator,OS=8.1,name=iPhone 6"

20 changes: 20 additions & 0 deletions FBTweak.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
18EFE528189F19B300DA6A5D /* FBTweakCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 18EFE526189F19B300DA6A5D /* FBTweakCategory.m */; };
18EFE52D189F250700DA6A5D /* FBTweakInlineTestsMRR.m in Sources */ = {isa = PBXBuildFile; fileRef = 18EFE52C189F250700DA6A5D /* FBTweakInlineTestsMRR.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
18EFE536189F38D500DA6A5D /* FBTweakEnabled.h in Headers */ = {isa = PBXBuildFile; fileRef = 18EFE535189F38D500DA6A5D /* FBTweakEnabled.h */; settings = {ATTRIBUTES = (Public, ); }; };
29E9F17B18E35C9C001EAF7D /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29E9F17A18E35C9C001EAF7D /* MessageUI.framework */; };
5BACB31E1A12813C00C4F79D /* _FBTweakArrayViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5BACB31C1A12813C00C4F79D /* _FBTweakArrayViewController.h */; };
5BACB31F1A12813C00C4F79D /* _FBTweakArrayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5BACB31D1A12813C00C4F79D /* _FBTweakArrayViewController.m */; };
5BE25A521A0AA9D500C97C3E /* _FBTweakDictionaryViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5BE25A501A0AA9D500C97C3E /* _FBTweakDictionaryViewController.h */; };
5BE25A531A0AA9D500C97C3E /* _FBTweakDictionaryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5BE25A511A0AA9D500C97C3E /* _FBTweakDictionaryViewController.m */; };
5E1708C91905B89800402135 /* _FBSliderView.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E1708C31905B89800402135 /* _FBSliderView.h */; };
5E1708CA1905B89800402135 /* _FBSliderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E1708C41905B89800402135 /* _FBSliderView.m */; };
5E1708CD1905CBF800402135 /* _FBRGBView.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E1708CB1905CBF800402135 /* _FBRGBView.h */; };
Expand Down Expand Up @@ -104,6 +109,11 @@
18EFE526189F19B300DA6A5D /* FBTweakCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBTweakCategory.m; sourceTree = "<group>"; };
18EFE52C189F250700DA6A5D /* FBTweakInlineTestsMRR.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBTweakInlineTestsMRR.m; sourceTree = "<group>"; };
18EFE535189F38D500DA6A5D /* FBTweakEnabled.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBTweakEnabled.h; sourceTree = "<group>"; };
29E9F17A18E35C9C001EAF7D /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; };
5BACB31C1A12813C00C4F79D /* _FBTweakArrayViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _FBTweakArrayViewController.h; sourceTree = "<group>"; };
5BACB31D1A12813C00C4F79D /* _FBTweakArrayViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _FBTweakArrayViewController.m; sourceTree = "<group>"; };
5BE25A501A0AA9D500C97C3E /* _FBTweakDictionaryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _FBTweakDictionaryViewController.h; sourceTree = "<group>"; };
5BE25A511A0AA9D500C97C3E /* _FBTweakDictionaryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = _FBTweakDictionaryViewController.m; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
5E1708C31905B89800402135 /* _FBSliderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _FBSliderView.h; sourceTree = "<group>"; };
5E1708C41905B89800402135 /* _FBSliderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _FBSliderView.m; sourceTree = "<group>"; };
5E1708CB1905CBF800402135 /* _FBRGBView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _FBRGBView.h; sourceTree = "<group>"; };
Expand All @@ -130,6 +140,7 @@
buildActionMask = 2147483647;
files = (
5EB0EA4018F5EFF3009481A6 /* CoreGraphics.framework in Frameworks */,
29E9F17B18E35C9C001EAF7D /* MessageUI.framework in Frameworks */,
18EFE472189EBA4900DA6A5D /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -171,6 +182,7 @@
isa = PBXGroup;
children = (
5EB0EA3F18F5EFF3009481A6 /* CoreGraphics.framework */,
29E9F17A18E35C9C001EAF7D /* MessageUI.framework */,
18EFE471189EBA4900DA6A5D /* Foundation.framework */,
18EFE47F189EBA4900DA6A5D /* XCTest.framework */,
18EFE482189EBA4900DA6A5D /* UIKit.framework */,
Expand Down Expand Up @@ -262,6 +274,10 @@
5E1708D8190866C400402135 /* _FBHSBView.m */,
5E1708DB190B147000402135 /* _FBKeyboardManager.h */,
5E1708DC190B147000402135 /* _FBKeyboardManager.m */,
5BE25A501A0AA9D500C97C3E /* _FBTweakDictionaryViewController.h */,
5BE25A511A0AA9D500C97C3E /* _FBTweakDictionaryViewController.m */,
5BACB31C1A12813C00C4F79D /* _FBTweakArrayViewController.h */,
5BACB31D1A12813C00C4F79D /* _FBTweakArrayViewController.m */,
);
name = UI;
sourceTree = "<group>";
Expand Down Expand Up @@ -302,10 +318,12 @@
18EFE4D0189EC70300DA6A5D /* FBTweakInlineInternal.h in Headers */,
18EFE527189F19B300DA6A5D /* FBTweakCategory.h in Headers */,
18EFE4BC189EBC4B00DA6A5D /* FBTweakCollection.h in Headers */,
5BE25A521A0AA9D500C97C3E /* _FBTweakDictionaryViewController.h in Headers */,
18EFE4DD189EF75800DA6A5D /* _FBTweakTableViewCell.h in Headers */,
5EADAAE018FB3C2D00D06EAB /* _FBColorComponentView.h in Headers */,
184A94F018D26871005F2774 /* _FBTweakBindObserver.h in Headers */,
5E1708C91905B89800402135 /* _FBSliderView.h in Headers */,
5BACB31E1A12813C00C4F79D /* _FBTweakArrayViewController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -391,6 +409,7 @@
buildActionMask = 2147483647;
files = (
5E1708CA1905B89800402135 /* _FBSliderView.m in Sources */,
5BE25A531A0AA9D500C97C3E /* _FBTweakDictionaryViewController.m in Sources */,
18EFE4A7189EBA9E00DA6A5D /* FBTweakViewController.m in Sources */,
18EFE4BD189EBC4B00DA6A5D /* FBTweakCollection.m in Sources */,
18EFE4C2189EBEAD00DA6A5D /* FBTweakStore.m in Sources */,
Expand All @@ -406,6 +425,7 @@
18EFE4D6189EEBC500DA6A5D /* _FBTweakCategoryViewController.m in Sources */,
5E1708D419070F5600402135 /* _FBColorWheelView.m in Sources */,
18EFE4AF189EBABA00DA6A5D /* FBTweakShakeWindow.m in Sources */,
5BACB31F1A12813C00C4F79D /* _FBTweakArrayViewController.m in Sources */,
18EFE4DA189EEED800DA6A5D /* _FBTweakCollectionViewController.m in Sources */,
5EA9A2EA1911968D0071AB23 /* _FBTweakColorViewController.m in Sources */,
184A94F118D26871005F2774 /* _FBTweakBindObserver.m in Sources */,
Expand Down
110 changes: 110 additions & 0 deletions FBTweak.xcodeproj/xcshareddata/xcschemes/FBTweak.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "18EFE46D189EBA4900DA6A5D"
BuildableName = "libFBTweak.a"
BlueprintName = "FBTweak"
ReferencedContainer = "container:FBTweak.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "18EFE47D189EBA4900DA6A5D"
BuildableName = "FBTweakTests.xctest"
BlueprintName = "FBTweakTests"
ReferencedContainer = "container:FBTweak.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "18EFE47D189EBA4900DA6A5D"
BuildableName = "FBTweakTests.xctest"
BlueprintName = "FBTweakTests"
ReferencedContainer = "container:FBTweak.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "18EFE46D189EBA4900DA6A5D"
BuildableName = "libFBTweak.a"
BlueprintName = "FBTweak"
ReferencedContainer = "container:FBTweak.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "18EFE46D189EBA4900DA6A5D"
BuildableName = "libFBTweak.a"
BlueprintName = "FBTweak"
ReferencedContainer = "container:FBTweak.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "18EFE46D189EBA4900DA6A5D"
BuildableName = "libFBTweak.a"
BlueprintName = "FBTweak"
ReferencedContainer = "container:FBTweak.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
10 changes: 5 additions & 5 deletions FBTweak/FBColorUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ extern RGB FBRGBColorComponents(UIColor* color)
blue = components[2];
alpha = components[3];
}
NSString *hexColorString = [NSString stringWithFormat:@"#%02X%02X%02X%02X",
(NSUInteger)(red * FBRGBColorComponentMaxValue),
(NSUInteger)(green * FBRGBColorComponentMaxValue),
(NSUInteger)(blue * FBRGBColorComponentMaxValue),
(NSUInteger)(alpha * FBRGBColorComponentMaxValue)];
NSString *hexColorString = [NSString stringWithFormat:@"#%02lX%02lX%02lX%02lX",
(unsigned long)(red * FBRGBColorComponentMaxValue),
(unsigned long)(green * FBRGBColorComponentMaxValue),
(unsigned long)(blue * FBRGBColorComponentMaxValue),
(unsigned long)(alpha * FBRGBColorComponentMaxValue)];
return hexColorString;
}

Expand Down
80 changes: 72 additions & 8 deletions FBTweak/FBTweak.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,50 @@

/**
@abstract Represents a possible value of a tweak.
@discussion Should be able to be persisted in user defaults.
@discussion Should be able to be persisted in user defaults,
except actions (represented as blocks without a currentValue).
For minimum and maximum values, should implement -compare:.
*/
typedef id FBTweakValue;

/**
@abstract Represents a unqie, named tweak.
@abstract Represents a range of values for a numeric tweak.
@discussion Use this for the -possibleValues on a tweak.
*/
@interface FBTweakNumericRange : NSObject <NSCoding>

/**
@abstract Creates a new numeric range.
@discussion This is the designated initializer.
@param minimumValue The minimum value of the range.
@param maximumValue The maximum value of the range.
*/
- (instancetype)initWithMinimumValue:(FBTweakValue)minimumValue maximumValue:(FBTweakValue)maximumValue;

/**
@abstract The minimum value of the range.
@discussion Will always have a value.
*/
@property (nonatomic, strong, readwrite) FBTweakValue minimumValue;

/**
@abstract The maximum value of the range.
@discussion Will always have a value.
*/
@property (nonatomic, strong, readwrite) FBTweakValue maximumValue;

@end

/**
@abstract Represents a unique, named tweak.
@discussion A tweak contains a persistent, editable value.
*/
@interface FBTweak : NSObject
@interface FBTweak : NSObject <NSCoding>

/**
@abstract Creates a new tweak model.
@discussion This is the designated initializer.
@param identifier The identifier for the tweak. Required.
*/
- (instancetype)initWithIdentifier:(NSString *)identifier;

Expand All @@ -43,29 +73,63 @@ typedef id FBTweakValue;
@property (nonatomic, copy, readwrite) NSString *name;

/**
@abstract The default value of the tweak.
@discussion Use this when the current value is unset.
@abstract If this tweak is an action, with a block value.
@param If YES, {@ref currentValue} should not be set and
{@ref defaultValue} is a block rather than a value object.
*/
@property (nonatomic, readonly, assign, getter = isAction) BOOL action;

/**
@abstract The default value of the tweak.
@discussion Use this when the current value is unset.
For actions, set this property to a block instead.
*/
@property (nonatomic, strong, readwrite) FBTweakValue defaultValue;

/**
@abstract The current value of the tweak. Can be nil.
@discussion Changes to this property will be propagated to disk.
@discussion Changes will be propagated to disk. Enforces within
possible values when changed. Must not be set on actions.
*/
@property (nonatomic, strong, readwrite) FBTweakValue currentValue;

/**
@abstract The possible values of the tweak.
@discussion Optional. If nil, any value is allowed. If an
FBTweakNumericRange, represents a range of numeric values.
If an array or dictionary, contains all of the allowed values.
Should not be set on tweaks representing actions.
*/
@property (nonatomic, strong, readwrite) id possibleValues;

/**
@abstract The minimum value of the tweak.
@discussion Optional. If nil, there is no minimum.
@discussion Optional. If nil, there is no minimum. Numeric only.
Should not be set on tweaks representing actions.
*/
@property (nonatomic, strong, readwrite) FBTweakValue minimumValue;

/**
@abstract The maximum value of the tweak.
@discussion Optional. If nil, there is no maximum.
@discussion Optional. If nil, there is no maximum. Numeric only.
Should not be set on tweaks representing actions.
*/
@property (nonatomic, strong, readwrite) FBTweakValue maximumValue;

/**
@abstract The step value of the tweak.
@discussion Optional. If nil, the step value is calculated from
the miniumum and maxium values. Only used for numeric tweaks.
*/
@property (nonatomic, strong, readwrite) FBTweakValue stepValue;

/**
@abstract The decimal precision value of the tweak.
@discussion Optional. If nil, the precision value is calculated from
the step value. Only used for numeric tweaks.
*/
@property (nonatomic, strong, readwrite) FBTweakValue precisionValue;

/**
@abstract Adds an observer to the tweak.
@param object The observer. Must not be nil.
Expand Down
Loading

0 comments on commit 4b87bf8

Please sign in to comment.