Tuner
Our <Tuner/>
component comprises two elements: a background image dividing the screen into segments and an indicator which will move according to how well tuned the guitar string played is. To make it user-friendly, we will use animations to move the indicator, similar to the way analog tuners behave:
/*** src/components/Tuner/index ***/ import React, { Component } from 'react'; import { StyleSheet, Image, View, Animated, Easing, Dimensions } from 'react-native'; import { colors } from '../utils/'; var {height, width} = Dimensions.get('window'); export default class Tuner extends Component { state = { xIndicator: new Animated.Value(width/2) } static propTypes = { delta: React.PropTypes.number }componentWillReceiveProps(newProps) { if(this.props.delta !== newProps.delta) { Animated.timing( this.state.xIndicator, { toValue: (width/2) + (newProps.delta*width/2)/100, duration: 500, easing: Easing...