From 599b2785114af6472310a0cbda98a88165d4e8d8 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Tue, 31 Mar 2015 10:44:16 -0700 Subject: [PATCH] Initial commit --- .gitignore | 3 + BVLinearGradient.h | 5 + BVLinearGradient.m | 34 +++ BVLinearGradient.xcodeproj/project.pbxproj | 258 +++++++++++++++++++++ BVLinearGradientManager.h | 5 + BVLinearGradientManager.m | 22 ++ LinearGradient.android.js | 11 + LinearGradient.ios.js | 44 ++++ README.md | 3 + package.json | 13 ++ 10 files changed, 398 insertions(+) create mode 100644 .gitignore create mode 100644 BVLinearGradient.h create mode 100644 BVLinearGradient.m create mode 100644 BVLinearGradient.xcodeproj/project.pbxproj create mode 100644 BVLinearGradientManager.h create mode 100644 BVLinearGradientManager.m create mode 100644 LinearGradient.android.js create mode 100644 LinearGradient.ios.js create mode 100644 README.md create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4382bbd --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/**/* +BVLinearGradient.xcodeproj/xcuserdata/**/* +BVLinearGradient.xcodeproj/project.xcworkspace/**/* diff --git a/BVLinearGradient.h b/BVLinearGradient.h new file mode 100644 index 0000000..d8edf4d --- /dev/null +++ b/BVLinearGradient.h @@ -0,0 +1,5 @@ +#import + +@interface BVLinearGradient : UIView + +@end diff --git a/BVLinearGradient.m b/BVLinearGradient.m new file mode 100644 index 0000000..a028aea --- /dev/null +++ b/BVLinearGradient.m @@ -0,0 +1,34 @@ +#import "BVLinearGradient.h" + +@implementation BVLinearGradient +{ + CAGradientLayer *_layer; +} + +- (id)init +{ + if ((self = [super init])) { + NSArray *colors = [NSArray arrayWithObjects: + (id)[UIColor whiteColor].CGColor, + (id)[UIColor redColor].CGColor, + nil]; + *_layer = [CAGradientLayer _layer]; + [_layer setColors:colors]; + [layer setFrame:self.bounds]; + [self.layer insertSublayer:_layer atIndex:0]; + self.clipToBounds = YES; + } + return self; +} + +- (void)setColors:(NSArray *)colors +{ +} + +- (void)layoutSubviews +{ + [super layoutSubviews]; + [layer setFrame:self.bounds]; +} + +@end diff --git a/BVLinearGradient.xcodeproj/project.pbxproj b/BVLinearGradient.xcodeproj/project.pbxproj new file mode 100644 index 0000000..89f34dc --- /dev/null +++ b/BVLinearGradient.xcodeproj/project.pbxproj @@ -0,0 +1,258 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + BBD49E3F1AC8DEF000610F8E /* BVLinearGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */; }; + BBD49E401AC8DEF000610F8E /* BVLinearGradientManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 58B511D91A9E6C8500147676 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBVLinearGradient.a; sourceTree = BUILT_PRODUCTS_DIR; }; + BBD49E391AC8DEF000610F8E /* BVLinearGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVLinearGradient.h; sourceTree = ""; }; + BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVLinearGradient.m; sourceTree = ""; }; + BBD49E3B1AC8DEF000610F8E /* BVLinearGradientManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVLinearGradientManager.h; sourceTree = ""; }; + BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVLinearGradientManager.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 58B511D81A9E6C8500147676 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 134814211AA4EA7D00B7C361 /* Products */ = { + isa = PBXGroup; + children = ( + 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */, + ); + name = Products; + sourceTree = ""; + }; + 58B511D21A9E6C8500147676 = { + isa = PBXGroup; + children = ( + BBD49E391AC8DEF000610F8E /* BVLinearGradient.h */, + BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */, + BBD49E3B1AC8DEF000610F8E /* BVLinearGradientManager.h */, + BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */, + 134814211AA4EA7D00B7C361 /* Products */, + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 58B511DA1A9E6C8500147676 /* BVLinearGradient */ = { + isa = PBXNativeTarget; + buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "BVLinearGradient" */; + buildPhases = ( + 58B511D71A9E6C8500147676 /* Sources */, + 58B511D81A9E6C8500147676 /* Frameworks */, + 58B511D91A9E6C8500147676 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BVLinearGradient; + productName = RCTDataManager; + productReference = 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 58B511D31A9E6C8500147676 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = Facebook; + TargetAttributes = { + 58B511DA1A9E6C8500147676 = { + CreatedOnToolsVersion = 6.1.1; + }; + }; + }; + buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "BVLinearGradient" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 58B511D21A9E6C8500147676; + productRefGroup = 58B511D21A9E6C8500147676; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 58B511DA1A9E6C8500147676 /* BVLinearGradient */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 58B511D71A9E6C8500147676 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BBD49E3F1AC8DEF000610F8E /* BVLinearGradient.m in Sources */, + BBD49E401AC8DEF000610F8E /* BVLinearGradientManager.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 58B511ED1A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 58B511EE1A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 58B511F01A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + "$(SRCROOT)/../react-native/React/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = BVLinearGradient; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 58B511F11A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../React/**", + "$(SRCROOT)/../react-native/React/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = BVLinearGradient; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "BVLinearGradient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511ED1A9E6C8500147676 /* Debug */, + 58B511EE1A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "BVLinearGradient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511F01A9E6C8500147676 /* Debug */, + 58B511F11A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 58B511D31A9E6C8500147676 /* Project object */; +} diff --git a/BVLinearGradientManager.h b/BVLinearGradientManager.h new file mode 100644 index 0000000..be3e918 --- /dev/null +++ b/BVLinearGradientManager.h @@ -0,0 +1,5 @@ +#import "RCTViewManager.h" + +@interface BVLinearGradientManager : RCTViewManager + +@end diff --git a/BVLinearGradientManager.m b/BVLinearGradientManager.m new file mode 100644 index 0000000..d897030 --- /dev/null +++ b/BVLinearGradientManager.m @@ -0,0 +1,22 @@ +#import "BVLinearGradientManager.h" +#import "BVLinearGradient.h" +#import "RCTBridge.h" + +@implementation BVLinearGradientManager + +@synthesize bridge = _bridge; + +- (UIView *)view +{ + return [[BVLinearGradient alloc] init]; +} + +RCT_EXPORT_VIEW_PROPERTY(colors, NSArray); +// Start point, end point, type + +- (NSDictionary *)constantsToExport +{ + return @{}; +} + +@end diff --git a/LinearGradient.android.js b/LinearGradient.android.js new file mode 100644 index 0000000..23e8086 --- /dev/null +++ b/LinearGradient.android.js @@ -0,0 +1,11 @@ +'use strict'; + +var warning = require('warning'); + +var LinearGradient = { + test: function() { + warning("Not yet implemented for Android."); + } +}; + +module.exports = LinearGradient; diff --git a/LinearGradient.ios.js b/LinearGradient.ios.js new file mode 100644 index 0000000..2e6bb5b --- /dev/null +++ b/LinearGradient.ios.js @@ -0,0 +1,44 @@ +var React = require('React'); +var NativeModules = require('NativeModules'); +var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); +var StyleSheet = require('StyleSheet'); +var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass'); +var PropTypes = require('ReactPropTypes'); +var NativeMethodsMixin = require('NativeMethodsMixin'); +var flattenStyle = require('flattenStyle'); +var merge = require('merge'); + +var LinearGradient = React.createClass({ + propTypes: { + colors: PropTypes.array, + }, + + mixins: [NativeMethodsMixin], + + viewConfig: { + uiViewClassName: 'UIView', + validAttributes: ReactIOSViewAttributes.UIView + }, + + render: function() { + var style = flattenStyle([styles.base, this.props.style]); + var colors = this.props.colors; + + var nativeProps = merge(this.props, { + style, + }); + + return + }, +}); + +var BVLinearGradient = createReactIOSNativeComponentClass({ + validAttributes: merge(ReactIOSViewAttributes.UIView, {colors: true}), + uiViewClassName: 'BVLinearGradient', +}); + +var styles = StyleSheet.create({ + base: { }, +}); + +module.exports = LinearGradient; diff --git a/README.md b/README.md new file mode 100644 index 0000000..44822e7 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +## react-native-linear-gradient + +A component for react-native, WIP, not yet ready for use. diff --git a/package.json b/package.json new file mode 100644 index 0000000..56d8e7e --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "react-native-linear-gradient", + "version": "0.1.0", + "description": "A element for react-native", + "main": "LinearGradient.ios.js", + "author": "Brent Vatne (https://github.com/brentvatne)", + "dependencies": { + "react-native": "^0.3.1" + }, + "devDependencies": { + "jest-cli": "0.2.1" + } +}