You can conditionally have a className on the Icon
component called rotated
and have a CSS rule based on the className.
In your toggleExpanded
function, you can set rotated
in component state.
toggleExpanded() {
... (whatever else happens in here)
this.setState({iconRotated: !this.state.iconRotated})
}
<TouchableOpacity onPress={this.toggleExpanded}>
<View style={{ alignItems: "center" }}>
<Icon
iconStyle={{paddingTop:"13%", paddingRight: 50}}
className={this.state.iconRotated ? "icon-rotated" : ""}
name="play-circle"
color="#637182"
type="light"
size={30}
/>
</View>
</TouchableOpacity>
In a CSS file, use
.iconRotated
transform: rotate(90deg);
If you're not using any CSS files, you'll have to conditionally use inline styling.
const rotation = this.state.iconRotated ? 90 : 0
<TouchableOpacity onPress={this.toggleExpanded}>
<View style={{ alignItems: "center" }}>
<Icon
iconStyle={
{
paddingTop:"13%",
paddingRight: 50,
transform: `${rotate(rotation)}`
}
}
name="play-circle"
color="#637182"
type="light"
size={30}
/>
</View>
</TouchableOpacity>