2020-06-02 17:19:09 +02:00
|
|
|
import React from 'react';
|
2020-06-02 22:43:48 +02:00
|
|
|
import { StyleSheet } from 'react-native';
|
|
|
|
import { Button, Content, Text } from 'native-base';
|
2020-06-02 17:19:09 +02:00
|
|
|
import { LinearGradient } from 'expo-linear-gradient';
|
|
|
|
import IconCard from './IconCard';
|
|
|
|
import Graph from './Graph';
|
2020-06-02 22:43:48 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { stopSession } from '../state/ActionCreators';
|
|
|
|
import backgroundColors from './Themes';
|
2020-06-02 17:19:09 +02:00
|
|
|
|
|
|
|
|
2020-06-02 22:43:48 +02:00
|
|
|
function LiveTrainingView(props)
|
|
|
|
{
|
|
|
|
const analysis = props.session.analysis;
|
|
|
|
const onStopClick = () => {
|
|
|
|
props.dispatch(stopSession());
|
|
|
|
props.navigation.navigate('Home');
|
2020-06-02 17:19:09 +02:00
|
|
|
};
|
2020-06-02 22:43:48 +02:00
|
|
|
const laps = (analysis.peaks.size / props.peaksPerLap).toFixed(1);
|
|
|
|
const totalMomentum = Math.trunc(analysis.totalMomentum / 10000);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<LinearGradient
|
|
|
|
colors={backgroundColors[props.theme]}
|
|
|
|
start={[0, 0]}
|
|
|
|
end={[0.5, 1]}
|
|
|
|
style={{ flex: 1 }}
|
|
|
|
>
|
|
|
|
<Content padder contentContainerStyle={{ justifyContent: 'space-around', flex: 1, paddingTop: 60 }}>
|
|
|
|
<IconCard label="BAHNEN" value={laps} iconName="retweet" iconType="AntDesign" />
|
|
|
|
<IconCard label="ZÜGE" value={analysis.peaks.size} iconName="dashboard" iconType="AntDesign" />
|
|
|
|
<IconCard label="KRAFT" value={totalMomentum} iconName="ruler" iconType="Entypo" />
|
2020-06-02 17:19:09 +02:00
|
|
|
{/*
|
2020-06-02 22:43:48 +02:00
|
|
|
<IconCard label="ZÜGE" value={this.state.numPeaks} iconName="dashboard" iconType="AntDesign" />
|
|
|
|
<IconCard label="BAHNEN" value={this.state.numLaps} iconName="retweet" iconType="AntDesign" />
|
2020-06-02 17:19:09 +02:00
|
|
|
|
2020-06-02 22:43:48 +02:00
|
|
|
<IconCard label="KRAFT" value="120" iconName="ruler" iconType="Entypo" />
|
2020-06-02 17:19:09 +02:00
|
|
|
*/}
|
2020-06-02 22:43:48 +02:00
|
|
|
<Button block secondary onPress={onStopClick}><Text>Stop</Text></Button>
|
2020-06-02 17:19:09 +02:00
|
|
|
</Content>
|
2020-06-02 22:43:48 +02:00
|
|
|
</LinearGradient>
|
|
|
|
);
|
2020-06-02 17:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
card: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
backgroundColor: 'rgba(0, 0, 0, 0.2)',
|
|
|
|
margin: 5,
|
|
|
|
padding: 5,
|
|
|
|
borderRadius: 3,
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
/*
|
|
|
|
shadowColor: "#000",
|
|
|
|
shadowOffset: {
|
|
|
|
width: 0,
|
|
|
|
height: 1,
|
|
|
|
},
|
|
|
|
shadowOpacity: 0.18,
|
|
|
|
shadowRadius: 1.00,
|
|
|
|
|
|
|
|
elevation: 1,*/
|
|
|
|
}
|
|
|
|
});
|
2020-06-02 22:43:48 +02:00
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
return {
|
|
|
|
session: state.session,
|
|
|
|
peaksPerLap: state.settings.peaksPerLap,
|
|
|
|
theme: state.settings.theme,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(LiveTrainingView);
|
|
|
|
|