From ea3fe924bfbd5e17b5f1bfa6068f26aefe49e9a5 Mon Sep 17 00:00:00 2001 From: Pranav Raj Singh Chauhan Date: Thu, 14 Jun 2018 17:08:58 +0530 Subject: [PATCH] - adding support for state selection --- IconicExample/App.js | 28 ++++++++++++++++--- IconicExample/android/.project | 17 +++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ IconicExample/android/app/.classpath | 6 ++++ IconicExample/android/app/.project | 23 +++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ IconicExample/android/build.gradle | 6 ++-- .../gradle/wrapper/gradle-wrapper.properties | 4 +-- README.md | 2 +- android/.classpath | 6 ++++ android/.project | 23 +++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ android/src/main/java/ui/iconic/RNIconic.java | 16 ++++------- 13 files changed, 117 insertions(+), 20 deletions(-) create mode 100644 IconicExample/android/.project create mode 100644 IconicExample/android/.settings/org.eclipse.buildship.core.prefs create mode 100644 IconicExample/android/app/.classpath create mode 100644 IconicExample/android/app/.project create mode 100644 IconicExample/android/app/.settings/org.eclipse.buildship.core.prefs create mode 100644 android/.classpath create mode 100644 android/.project create mode 100644 android/.settings/org.eclipse.buildship.core.prefs diff --git a/IconicExample/App.js b/IconicExample/App.js index ff8cccd..c97ee98 100644 --- a/IconicExample/App.js +++ b/IconicExample/App.js @@ -15,9 +15,10 @@ import { import RNIconic from 'react-native-iconic' export default class App extends Component<{}> { - render() { - let shapes = [] - + constructor (props) { + super(props) + + if (Platform.OS === "ios") { shapes = [ RNIconic.Shapes.Default, @@ -53,8 +54,27 @@ export default class App extends Component<{}> { ] } + let selection = 0 + + this.state = { + shapes: shapes, + selection: selection + } + } + + componentDidMount () { + // setTimeout (() => { + // this.setState({ + // selection: 0 + // }) + // }, 5000) + } + + render() { + let shapes = [] + return - + ; } } diff --git a/IconicExample/android/.project b/IconicExample/android/.project new file mode 100644 index 0000000..e99b07d --- /dev/null +++ b/IconicExample/android/.project @@ -0,0 +1,17 @@ + + + IconicExample + Project IconicExample created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/IconicExample/android/.settings/org.eclipse.buildship.core.prefs b/IconicExample/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/IconicExample/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/IconicExample/android/app/.classpath b/IconicExample/android/app/.classpath new file mode 100644 index 0000000..eb19361 --- /dev/null +++ b/IconicExample/android/app/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/IconicExample/android/app/.project b/IconicExample/android/app/.project new file mode 100644 index 0000000..ac485d7 --- /dev/null +++ b/IconicExample/android/app/.project @@ -0,0 +1,23 @@ + + + app + Project app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/IconicExample/android/app/.settings/org.eclipse.buildship.core.prefs b/IconicExample/android/app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..b1886ad --- /dev/null +++ b/IconicExample/android/app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir=.. +eclipse.preferences.version=1 diff --git a/IconicExample/android/build.gradle b/IconicExample/android/build.gradle index 9622df0..d12dbb0 100644 --- a/IconicExample/android/build.gradle +++ b/IconicExample/android/build.gradle @@ -3,10 +3,10 @@ buildscript { repositories { jcenter() - google() + maven { url "https://maven.google.com" } } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -22,6 +22,6 @@ allprojects { url "$rootDir/../node_modules/react-native/android" } maven { url "https://jitpack.io" } - google() + maven { url "https://maven.google.com" } } } diff --git a/IconicExample/android/gradle/wrapper/gradle-wrapper.properties b/IconicExample/android/gradle/wrapper/gradle-wrapper.properties index 3c94bd0..999cc17 100644 --- a/IconicExample/android/gradle/wrapper/gradle-wrapper.properties +++ b/IconicExample/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jan 21 15:45:34 IST 2018 +#Thu Jun 14 16:31:35 IST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/README.md b/README.md index a9a550d..4297f3a 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ import RNIconic from 'react-native-iconic'; | `color` | `string` | | Specify icon color | | `size` | `int` | | Size of Icon | | | `disabled` | `bool` | | Disabling the Icon Button | | -| `onChange` | `func` | | It is invoke then the value of shine button is change +| `onChange` | `func` | | It is invoke when the value of button is change | `tintColor` | `array` | | Color of background circle | - **iOS** diff --git a/android/.classpath b/android/.classpath new file mode 100644 index 0000000..8d8d85f --- /dev/null +++ b/android/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/android/.project b/android/.project new file mode 100644 index 0000000..3865e0f --- /dev/null +++ b/android/.project @@ -0,0 +1,23 @@ + + + android + Project android created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/android/src/main/java/ui/iconic/RNIconic.java b/android/src/main/java/ui/iconic/RNIconic.java index c99c3c9..8d9d646 100644 --- a/android/src/main/java/ui/iconic/RNIconic.java +++ b/android/src/main/java/ui/iconic/RNIconic.java @@ -132,30 +132,26 @@ public void setSelection(FrameLayout iconicButtonFrame, int selc) { selection = selc; // Animate the icon if the selection changes - MaterialMenuView iconicButton = (MaterialMenuView) iconicButtonFrame.getChildAt(0); - iconicButton.animateIconState(getState(selection)); + setState(iconicButtonFrame, selection); } @ReactProp(name = "shape") public void setShape(FrameLayout iconicButtonFrame, ReadableArray shps) { shapes = shps.toArrayList(); - MaterialMenuView iconicButton = (MaterialMenuView) iconicButtonFrame.getChildAt(0); - iconicButton.setIconState(getState(selection)); + setState(iconicButtonFrame, selection); } - private MaterialMenuDrawable.IconState getState(int selection) { + private void setState(FrameLayout iconicButtonFrame, int selection) { + MaterialMenuView iconicButton = (MaterialMenuView) iconicButtonFrame.getChildAt(0); + ExpandIconView expandIconView = (ExpandIconView) iconicButtonFrame.getChildAt(1); + String state = ""; // Make sure the shapes array is filled and the selection is in range. Otherwise, draw the default state "ARROW" if(!shapes.isEmpty() && shapes.size() > selection) state = (String) shapes.get(selection); - String state = (String) shapes.get(selection); - - MaterialMenuView iconicButton = (MaterialMenuView) iconicButtonFrame.getChildAt(0); - ExpandIconView expandIconView = (ExpandIconView) iconicButtonFrame.getChildAt(1); - if (state.equalsIgnoreCase("BURGER")) { iconicButton.setVisible(true); iconicButton.setIconState(MaterialMenuDrawable.IconState.BURGER);