Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
- adding support for state selection
Browse files Browse the repository at this point in the history
  • Loading branch information
prscms committed Jun 14, 2018
1 parent d2b1089 commit ea3fe92
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 20 deletions.
28 changes: 24 additions & 4 deletions IconicExample/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 <View style={styles.container}>
<RNIconic shape={shapes} tintColor={"#FFFFFF"} color={"#fc4426"} size={200} selection={0} disable={false} lineThickness={5} />
<RNIconic shape={this.state.shapes} tintColor={"#FFFFFF"} color={"#fc4426"} size={200} selection={this.state.selection} disable={false} lineThickness={5} />
</View>;
}
}
Expand Down
17 changes: 17 additions & 0 deletions IconicExample/android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>IconicExample</name>
<comment>Project IconicExample created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
6 changes: 6 additions & 0 deletions IconicExample/android/app/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
23 changes: 23 additions & 0 deletions IconicExample/android/app/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1
6 changes: 3 additions & 3 deletions IconicExample/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,6 +22,6 @@ allprojects {
url "$rootDir/../node_modules/react-native/android"
}
maven { url "https://jitpack.io" }
google()
maven { url "https://maven.google.com" }
}
}
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
6 changes: 6 additions & 0 deletions android/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
</classpath>
23 changes: 23 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
16 changes: 6 additions & 10 deletions android/src/main/java/ui/iconic/RNIconic.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ea3fe92

Please sign in to comment.