Comments (2)
Hello @dhelbegor,
You can easily do that since you get the data of the pressed body part. Here is a simple example of what you are expecting. Please let me know if this helped you. (Testable Snack : https://snack.expo.dev/@hichamelbsi/authentic-waffle)
import { StyleSheet, Switch, View } from "react-native";
import { useState } from "react";
import Body from "react-native-body-highlighter";
export default function App() {
const [bodyPartSelected, setBodyPartSelected] = useState([]);
const [isBackSideEnabled, setIsBackSideEnabled] = useState(false);
const toggleSwitch = () =>
setIsBackSideEnabled((previousState) => !previousState);
const selectArms = (muscle) => {
if (['forearm', 'hands'].includes(muscle.slug)) {
setBodyPartSelected([{ slug: 'forearm', intensity: 1 }, { slug: 'hands', intensity: 1 }])
} else {
setBodyPartSelected([muscle])
}
}
return (
<View style={styles.container}>
<Body
data={bodyPartSelected}
onBodyPartPress={selectArms}
side={isBackSideEnabled ? "back" : "front"}
scale={1.7}
/>
<Switch onValueChange={toggleSwitch} value={isBackSideEnabled} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
});
from react-native-body-highlighter.
Thank you very much @HichamELBSI . It worked very smoothly :D.
from react-native-body-highlighter.
Related Issues (15)
- Component does not render. HOT 2
- There are no hand palm and foot HOT 2
- Add license HOT 1
- Old react-native-svg version causes crashes
- Updated data doesn't re-render SVG Polygon HOT 1
- Error while toggle the body HOT 3
- The app app crashed with {"rootTag":1} HOT 2
- Invariant Violation HOT 1
- Invariant violation: Tried to register two views with the same name RNSVGRect HOT 3
- Deltoids is listed twice HOT 2
- switch to woman? HOT 2
- how to select only one part of the body. it selects pair. HOT 2
- How to remove stroke outline around the body? HOT 1
- crashes app when including Body HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-body-highlighter.