Replace action button footer in remaining symptom views

This commit is contained in:
Julia Friesel
2018-08-20 13:44:05 +02:00
parent d897c3b89f
commit 8629fd5369
10 changed files with 375 additions and 394 deletions
+13 -29
View File
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { View, BackHandler, ScrollView } from 'react-native'
import { View, BackHandler } from 'react-native'
import Header from './components/header'
import Menu from './components/menu'
import Home from './components/home'
@@ -9,11 +9,11 @@ import symptomViews from './components/cycle-day/symptoms'
import Chart from './components/chart/chart'
import Settings from './components/settings'
import Stats from './components/stats'
import styles from './styles'
// this is until react native fixes this bugg, see
// https://github.com/facebook/react-native/issues/18868#issuecomment-382671739
import { YellowBox } from 'react-native'
import ActionButtonFooter from './components/cycle-day/symptoms/action-button-footer';
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated'])
const isSymptomView = name => Object.keys(symptomViews).indexOf(name) > -1
@@ -46,38 +46,22 @@ export default class App extends Component {
this.setState({currentPage: pageName, currentProps: props})
}
setActionButtonState(actionButtonInfo) {
this.setState({actionButtonInfo})
}
unsetActionButtonState() {
this.setState({actionButtonInfo: null})
}
render() {
const page = {
Home, Calendar, CycleDay, Chart, Settings, Stats, ...symptomViews
}[this.state.currentPage]
return (
<View style={{height: '100%', justifyContent: 'space-between' }}>
<View>
{this.state.currentPage != 'CycleDay' && <Header title={this.state.currentPage}/>}
<ScrollView>
{React.createElement(page, {
navigate: this.navigate.bind(this),
setActionButtonState: this.setActionButtonState.bind(this),
unsetActionButtonState: this.unsetActionButtonState.bind(this),
...this.state.currentProps
})}
</ScrollView>
</View>
{isSymptomView(this.state.currentPage) && this.state.actionButtonInfo ?
<ActionButtonFooter
{...this.state.actionButtonInfo}
navigate={this.navigate.bind(this)}
/>
:
<Menu navigate={this.navigate.bind(this)}/>
<View style={styles.menuOnBottom}>
{this.state.currentPage != 'CycleDay' && <Header title={this.state.currentPage} />}
{React.createElement(page, {
navigate: this.navigate.bind(this),
...this.state.currentProps
})}
{!isSymptomView(this.state.currentPage) &&
<Menu navigate={this.navigate.bind(this)} />
}
</View>
)