diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..f6b961f
Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..7f09697
--- /dev/null
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Feb 19 09:30:32 GMT 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
diff --git a/android/gradlew b/android/gradlew
new file mode 100644
index 0000000..cccdd3d
--- /dev/null
+++ b/android/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/android/gradlew.bat b/android/gradlew.bat
new file mode 100644
index 0000000..e95643d
--- /dev/null
+++ b/android/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 41a92ab..13118a7 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
+ package="com.ato.reactlibrary">
\ No newline at end of file
diff --git a/android/src/main/java/com/ato/reactlibrary/ColorHueSatView.java b/android/src/main/java/com/ato/reactlibrary/ColorHueSatView.java
new file mode 100755
index 0000000..b97144b
--- /dev/null
+++ b/android/src/main/java/com/ato/reactlibrary/ColorHueSatView.java
@@ -0,0 +1,184 @@
+package com.ato.reactlibrary;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Paint.Join;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+
+public class ColorHueSatView extends View {
+ public static final int TILE_DEFAULT_COUNT = 20;
+ public static final int TILE_GAP = 2;
+ public static final int MARGIN = 10;
+ public static final int STROKE_WIDTH = 4;
+
+ private float tileWidth = 0;
+ private float tileHeight = 0;
+ private int tileHCount = TILE_DEFAULT_COUNT;
+ private int tileVCount = TILE_DEFAULT_COUNT;
+
+ private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private Paint selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private Rect tileRect = new Rect();
+ private RectF borderRect = new RectF();
+
+ private int selX = 0;
+ private int selY = 0;
+
+ private RNColorPanel mainColorPanel;
+
+ public ColorHueSatView(Context context) {
+ this(context, null);
+ }
+
+ public ColorHueSatView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ColorHueSatView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ selectedPaint.setStyle(Paint.Style.STROKE);
+ selectedPaint.setColor(0xFFFCFCFC);
+ selectedPaint.setStrokeWidth(STROKE_WIDTH);
+ selectedPaint.setStrokeJoin(Join.ROUND);
+ selectedPaint.setShadowLayer(2, 1, 1, 0xC0000000);
+ }
+
+ public void setMainPanel(RNColorPanel panel) {
+ mainColorPanel = panel;
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ tileWidth = (float)(w - MARGIN * 2 - TILE_GAP * (TILE_DEFAULT_COUNT - 1)) / TILE_DEFAULT_COUNT;
+ tileHeight = (float)(h - MARGIN * 2 - TILE_GAP * (TILE_DEFAULT_COUNT - 1)) / TILE_DEFAULT_COUNT;
+ if(tileHeight > tileWidth) {
+ tileHCount = TILE_DEFAULT_COUNT;
+ tileHeight = tileWidth;
+ tileVCount = (int)((float)(h - MARGIN * 2 + TILE_GAP) / (tileHeight + TILE_GAP));
+ } else {
+ tileVCount = TILE_DEFAULT_COUNT;
+ tileWidth = tileHeight;
+ tileHCount = (int)((float)(w - MARGIN * 2 + TILE_GAP) / (tileWidth + TILE_GAP));
+ }
+ setSelectedTile(selX, selY);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ float[] colorHSV = new float[3];
+ colorHSV[2] = 1.0f;
+ for(int y = 0; y < tileVCount; y ++) {
+ for(int x = 0; x < tileHCount; x ++) {
+ int rgb = getTileColor(x, y);
+ paint.setColor(rgb);
+ setTileRect(x, y);
+ canvas.drawRect(tileRect, paint);
+ }
+ }
+
+ drawSelectedTile(canvas);
+ }
+
+ private void drawSelectedTile(Canvas canvas) {
+ int rgb = getTileColor(selX, selY);
+ paint.setColor(rgb);
+ setSelectedTileRect();
+ canvas.drawRect(tileRect, paint);
+
+ setSelectedTileBorderRect();
+ canvas.drawRoundRect(borderRect, 1, 1, selectedPaint);
+ }
+
+ private void setTileRect(int x, int y) {
+ tileRect.set((int)(MARGIN + x * (tileWidth + TILE_GAP)), (int)(MARGIN + y * (tileHeight + TILE_GAP)), (int)(MARGIN + x * (tileWidth + TILE_GAP) + tileWidth - 1), (int)(MARGIN + y * (tileHeight + TILE_GAP) + tileHeight - 1));
+ }
+
+ private void setSelectedTileRect() {
+ tileRect.set((int)(MARGIN + selX * (tileWidth + TILE_GAP) - TILE_GAP), (int)(MARGIN + selY * (tileHeight + TILE_GAP) - TILE_GAP), (int)(MARGIN + selX * (tileWidth + TILE_GAP) + tileWidth + TILE_GAP - 1), (int)(MARGIN + selY * (tileHeight + TILE_GAP) + tileHeight + TILE_GAP - 1));
+ }
+
+ private void setSelectedTileBorderRect() {
+ borderRect.set(MARGIN + selX * (tileWidth + TILE_GAP) - TILE_GAP - STROKE_WIDTH / 2, MARGIN + selY * (tileHeight + TILE_GAP) - TILE_GAP - STROKE_WIDTH / 2, MARGIN + selX * (tileWidth + TILE_GAP) + tileWidth + TILE_GAP + STROKE_WIDTH / 2 - 1, MARGIN + selY * (tileHeight + TILE_GAP) + tileHeight + TILE_GAP + STROKE_WIDTH / 2 - 1);
+ }
+
+ private int getTileColor(int x, int y) {
+ float[] hsv = new float[3];
+ hsv[0] = 360.0f / tileHCount * x;
+ hsv[1] = 1.0f - 0.9f / (tileVCount - 1) * y;
+ hsv[2] = 1.0f;
+ return Color.HSVToColor(hsv);
+ }
+
+ public void setSelectedTile(int selX, int selY) {
+ this.selX = selX;
+ this.selY = selY;
+ invalidate();
+ mainColorPanel.valView.colorHueSatChanged(getHue(), getSat());
+ }
+
+ public float getHue() {
+ return 360.0f / tileHCount * selX;
+ }
+
+ public float getSat() {
+ return 1.0f - 0.9f / (tileVCount - 1) * selY;
+ }
+
+ public void setHue(float h) {
+ int tileX = (int)(tileHCount / 360f * h);
+ tileX = tileX >= tileHCount? tileHCount - 1: tileX;
+ setSelectedTile(tileX, selY);
+ }
+
+ public void setSat(float s) {
+ if(s < 0.1f)
+ s = 0.1f;
+ int tileY = (int)((1 - s) / 0.9f * (tileVCount - 1));
+ tileY = tileY >= tileVCount? tileVCount - 1: tileY;
+ setSelectedTile(selX, tileY);
+ }
+
+ public void setHueSat(float h, float s) {
+ int tileX = (int)(tileHCount / 360f * h);
+ int tileY = (int)((1 - s) / 0.9f * (tileVCount - 1));
+ tileX = tileX >= tileHCount? tileHCount - 1: tileX;
+ tileY = tileY >= tileVCount? tileVCount - 1: tileY;
+ setSelectedTile(tileX, tileY);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ case MotionEvent.ACTION_MOVE:
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+ int tileX = (int)((x - MARGIN) / (tileWidth + TILE_GAP));
+ int tileY = (int)((y - MARGIN) / (tileHeight + TILE_GAP));
+ if(tileX < 0 || tileX >= tileHCount
+ || tileY < 0 || tileY >= tileVCount)
+ break;
+
+ setSelectedTile(tileX, tileY);
+ break;
+
+ case MotionEvent.ACTION_UP:
+ break;
+
+ default:
+ break;
+ }
+ return true;
+
+ }
+}
diff --git a/android/src/main/java/com/ato/reactlibrary/ColorValView.java b/android/src/main/java/com/ato/reactlibrary/ColorValView.java
new file mode 100755
index 0000000..3227097
--- /dev/null
+++ b/android/src/main/java/com/ato/reactlibrary/ColorValView.java
@@ -0,0 +1,129 @@
+package com.ato.reactlibrary;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.LinearGradient;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.graphics.Shader.TileMode;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+
+public class ColorValView extends View {
+ public static final int MARGIN_TOP = 5;
+ public static final int MARGIN_BOTTOM = 5;
+ public static final int MARGIN_LEFT = 15;
+ public static final int MARGIN_RIGHT = 15;
+ public static final int THUMB_SIZE = 20;
+
+ private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private Paint thumbPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private RectF contentRect = new RectF();
+ private RectF thumbRect = new RectF();
+
+ private float hsv[] = new float[3];
+
+ private RNColorPanel mainColorPanel;
+
+ public ColorValView(Context context) {
+ this(context, null);
+ }
+
+ public ColorValView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ColorValView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ hsv[0] = 0.f;
+ hsv[1] = 1.f;
+ hsv[2] = 1.f;
+ int rgb = Color.HSVToColor(hsv);
+ Shader shader = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, rgb, 0xff000000, TileMode.CLAMP);
+ paint.setShader(shader);
+ thumbPaint.setStyle(Paint.Style.FILL);
+ thumbPaint.setColor(0xFFF2F2F2);
+ thumbPaint.setShadowLayer(2, 1, 1, 0xC0000000);
+ }
+
+ public void setMainPanel(RNColorPanel panel) {
+ mainColorPanel = panel;
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ contentRect.set(MARGIN_LEFT, MARGIN_TOP, w - MARGIN_RIGHT, h - MARGIN_BOTTOM);
+ }
+
+ public void colorHueSatChanged(float hue, float sat) {
+ hsv[0] = hue;
+ hsv[1] = sat;
+ hsv[2] = 1.0f;
+
+ mainColorPanel.selectedColorView.setHSV(hsv[0], hsv[1], hsv[2]);
+
+ int rgb = Color.HSVToColor(hsv);
+ Shader shader = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, rgb, 0xff000000, TileMode.CLAMP);
+ paint.setShader(shader);
+ invalidate();
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ canvas.drawRoundRect(contentRect, 8.f, 8.f, paint);
+ drawThumb(canvas);
+ }
+
+ private void drawThumb(Canvas canvas) {
+ int thumbX = (int)((1 - hsv[2]) * (getMeasuredWidth() - MARGIN_LEFT - MARGIN_RIGHT) + MARGIN_LEFT);
+ int thumbY = getMeasuredHeight() / 2;
+ thumbRect.set(thumbX - THUMB_SIZE / 2, thumbY - THUMB_SIZE / 2, thumbX + THUMB_SIZE / 2, thumbY + THUMB_SIZE / 2);
+ canvas.drawRoundRect(thumbRect, 4.f, 4.f, thumbPaint);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+
+ float val = 1.f;
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ if(x < MARGIN_LEFT || x >= getMeasuredWidth() - MARGIN_RIGHT
+ || y < MARGIN_TOP || y >= getMeasuredHeight() - MARGIN_BOTTOM)
+ return true;
+ val = 1.f - (float)(x - MARGIN_LEFT) / (getMeasuredWidth() - MARGIN_LEFT - MARGIN_RIGHT);
+ setVal(val);
+ break;
+
+ case MotionEvent.ACTION_MOVE:
+ if(x < MARGIN_LEFT)
+ x = MARGIN_LEFT;
+ if(x >= getMeasuredWidth() - MARGIN_RIGHT)
+ x = getMeasuredWidth() - MARGIN_RIGHT;
+ val = 1.f - (float)(x - MARGIN_LEFT) / (getMeasuredWidth() - MARGIN_LEFT - MARGIN_RIGHT);
+ setVal(val);
+
+ break;
+
+ case MotionEvent.ACTION_UP:
+ break;
+
+ default:
+ break;
+ }
+ return true;
+
+ }
+
+ public void setVal(float val) {
+ hsv[2] = val;
+ mainColorPanel.selectedColorView.setVal(hsv[2]);
+ invalidate();
+ }
+}
diff --git a/android/src/main/java/com/ato/reactlibrary/RNColorPanel.java b/android/src/main/java/com/ato/reactlibrary/RNColorPanel.java
new file mode 100644
index 0000000..ce94d7f
--- /dev/null
+++ b/android/src/main/java/com/ato/reactlibrary/RNColorPanel.java
@@ -0,0 +1,75 @@
+package com.ato.reactlibrary;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.facebook.react.bridge.Arguments;
+import com.facebook.react.bridge.ReactContext;
+import com.facebook.react.bridge.WritableMap;
+import com.facebook.react.uimanager.events.RCTEventEmitter;
+
+public class RNColorPanel extends LinearLayout {
+
+ public ColorHueSatView hueSatView;
+ public ColorValView valView;
+ public SelectedColorView selectedColorView;
+ public TextView rvalueTxt;
+ public TextView gvalueTxt;
+ public TextView bvalueTxt;
+
+ public RNColorPanel(Context context)
+ {
+ super(context);
+
+ LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View mainContentView = inflater.inflate(R.layout.color_select_layout, null);
+ addView(mainContentView);
+
+ hueSatView = (ColorHueSatView)mainContentView.findViewById(R.id.color_huesat_view);
+ hueSatView.setMainPanel(this);
+
+ valView = (ColorValView)mainContentView.findViewById(R.id.color_val_view);
+ valView.setMainPanel(this);
+
+ selectedColorView = (SelectedColorView)mainContentView.findViewById(R.id.selected_color_view);
+ selectedColorView.setMainPanel(this);
+
+ rvalueTxt = (TextView)mainContentView.findViewById(R.id.rvalue_txt);
+ gvalueTxt = (TextView)mainContentView.findViewById(R.id.gvalue_txt);
+ bvalueTxt = (TextView)mainContentView.findViewById(R.id.bvalue_txt);
+ rvalueTxt.setText("R:");
+ gvalueTxt.setText("G:");
+ bvalueTxt.setText("B:");
+
+ setColor(Color.BLACK);
+ }
+
+ public void setColor(int rgb) {
+ if (rgb == selectedColorView.getColor()) {
+ return;
+ }
+
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = rgb & 0xFF;
+ float hsv[] = new float[3];
+ Color.RGBToHSV(r, g, b, hsv);
+
+ hueSatView.setHueSat(hsv[0], hsv[1]);
+ valView.setVal(hsv[2]);
+ }
+
+ public void onColorChanged() {
+ WritableMap event = Arguments.createMap();
+ event.putString("color", String.format("#%06X", (0xFFFFFF & selectedColorView.getColor())));
+ ReactContext reactContext = (ReactContext)getContext();
+ reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
+ getId(),
+ "colorDidChange",
+ event);
+ }
+}
diff --git a/android/src/main/java/com/ato/reactlibrary/RNColorPanelManager.java b/android/src/main/java/com/ato/reactlibrary/RNColorPanelManager.java
new file mode 100644
index 0000000..bb0e6f4
--- /dev/null
+++ b/android/src/main/java/com/ato/reactlibrary/RNColorPanelManager.java
@@ -0,0 +1,44 @@
+
+package com.ato.reactlibrary;
+
+import com.facebook.react.common.MapBuilder;
+import com.facebook.react.uimanager.SimpleViewManager;
+import com.facebook.react.uimanager.ThemedReactContext;
+import com.facebook.react.uimanager.annotations.ReactProp;
+
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+public class RNColorPanelManager extends SimpleViewManager {
+
+ public static final String REACT_CLASS = "RNColorPanel";
+ public static final String PROP_COLOR = "color";
+
+ @Override
+ public RNColorPanel createViewInstance(ThemedReactContext context) {
+ return new RNColorPanel(context);
+ }
+
+ @Override
+ public String getName() {
+ return REACT_CLASS;
+ }
+
+ @ReactProp(name = PROP_COLOR)
+ public void setColor(RNColorPanel view, @Nullable int color) {
+// view.setColor(color);
+ }
+
+ @Nullable
+ @Override
+ public Map getExportedCustomBubblingEventTypeConstants() {
+ return MapBuilder.builder()
+ .put(
+ "colorDidChange",
+ MapBuilder.of(
+ "phasedRegistrationNames",
+ MapBuilder.of("bubbled", "onColorChange")))
+ .build();
+ }
+}
\ No newline at end of file
diff --git a/android/src/main/java/com/reactlibrary/RNColorPanelPackage.java b/android/src/main/java/com/ato/reactlibrary/RNColorPanelPackage.java
similarity index 82%
rename from android/src/main/java/com/reactlibrary/RNColorPanelPackage.java
rename to android/src/main/java/com/ato/reactlibrary/RNColorPanelPackage.java
index 5443b22..457a98d 100644
--- a/android/src/main/java/com/reactlibrary/RNColorPanelPackage.java
+++ b/android/src/main/java/com/ato/reactlibrary/RNColorPanelPackage.java
@@ -1,5 +1,5 @@
-package com.reactlibrary;
+package com.ato.reactlibrary;
import java.util.Arrays;
import java.util.Collections;
@@ -10,10 +10,12 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
+
public class RNColorPanelPackage implements ReactPackage {
+
@Override
public List createNativeModules(ReactApplicationContext reactContext) {
- return Arrays.asList(new RNColorPanelModule(reactContext));
+ return Collections.emptyList();
}
// Deprecated from RN 0.47
@@ -23,6 +25,7 @@ public List> createJSModules() {
@Override
public List createViewManagers(ReactApplicationContext reactContext) {
- return Collections.emptyList();
+ return Arrays.asList(
+ new RNColorPanelManager());
}
}
\ No newline at end of file
diff --git a/android/src/main/java/com/ato/reactlibrary/SelectedColorView.java b/android/src/main/java/com/ato/reactlibrary/SelectedColorView.java
new file mode 100755
index 0000000..5910f14
--- /dev/null
+++ b/android/src/main/java/com/ato/reactlibrary/SelectedColorView.java
@@ -0,0 +1,92 @@
+package com.ato.reactlibrary;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class SelectedColorView extends View {
+ public static final int MARGIN = 5;
+
+ private float[] hsv = {0.f, 1.f, 1.f};
+ private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private RectF contentRect = new RectF();
+
+ private RNColorPanel mainColorPanel;
+
+ public SelectedColorView(Context context) {
+ this(context, null);
+ }
+
+ public SelectedColorView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SelectedColorView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ paint.setStyle(Paint.Style.FILL);
+ paint.setColor(Color.HSVToColor(hsv));
+ paint.setShadowLayer(2, 1, 1, 0xC0000000);
+ }
+
+ public void setMainPanel(RNColorPanel panel) {
+ mainColorPanel = panel;
+ }
+
+ public void setHue(float hue) {
+ hsv[0] = hue;
+ colorChanged();
+ }
+
+ public void setSat(float sat) {
+ hsv[1] = sat;
+ colorChanged();
+ }
+
+ public void setVal(float val) {
+ hsv[2] = val;
+ colorChanged();
+ }
+
+ public void setHSV(float hue, float sat, float val) {
+ hsv[0] = hue;
+ hsv[1] = sat;
+ hsv[2] = val;
+ colorChanged();
+ }
+
+ private void colorChanged() {
+
+ paint.setColor(Color.HSVToColor(hsv));
+ int rgb = getColor();
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = rgb & 0xFF;
+
+ mainColorPanel.rvalueTxt.setText(String.format("R: %3d", r * 100 / 255) + "%");
+ mainColorPanel.gvalueTxt.setText(String.format("G: %3d", g * 100 / 255) + "%");
+ mainColorPanel.bvalueTxt.setText(String.format("B: %3d", b * 100 / 255) + "%");
+
+ mainColorPanel.onColorChanged();
+
+ invalidate();
+ }
+
+ public int getColor() {
+ return Color.HSVToColor(hsv);
+ }
+
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ contentRect.set(MARGIN, MARGIN, w - MARGIN, h - MARGIN);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ canvas.drawRoundRect(contentRect, 8.f, 8.f, paint);
+ }
+}
diff --git a/android/src/main/java/com/reactlibrary/RNColorPanelModule.java b/android/src/main/java/com/reactlibrary/RNColorPanelModule.java
deleted file mode 100644
index 5a68d02..0000000
--- a/android/src/main/java/com/reactlibrary/RNColorPanelModule.java
+++ /dev/null
@@ -1,22 +0,0 @@
-
-package com.reactlibrary;
-
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.Callback;
-
-public class RNColorPanelModule extends ReactContextBaseJavaModule {
-
- private final ReactApplicationContext reactContext;
-
- public RNColorPanelModule(ReactApplicationContext reactContext) {
- super(reactContext);
- this.reactContext = reactContext;
- }
-
- @Override
- public String getName() {
- return "RNColorPanel";
- }
-}
\ No newline at end of file
diff --git a/android/src/main/res/layout/color_select_layout.xml b/android/src/main/res/layout/color_select_layout.xml
new file mode 100755
index 0000000..ffdb14c
--- /dev/null
+++ b/android/src/main/res/layout/color_select_layout.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/index.js b/index.js
index 9805fd8..0d597ff 100644
--- a/index.js
+++ b/index.js
@@ -9,7 +9,6 @@ class ColorPanel extends React.Component {
return;
}
- // process raw event...
this.props.onColorChange(event.nativeEvent.color);
}