Merge branch 'chore/batch-prettify-rest' into 'main'
Prettify rest of the components files except stats See merge request bloodyhealth/drip!507
This commit is contained in:
@@ -75,7 +75,7 @@ class CalendarView extends Component {
|
|||||||
firstDay={1}
|
firstDay={1}
|
||||||
onDayPress={this.passDateToDayView.bind(this)}
|
onDayPress={this.passDateToDayView.bind(this)}
|
||||||
markedDates={markedDates}
|
markedDates={markedDates}
|
||||||
markingType='custom'
|
markingType="custom"
|
||||||
theme={calendarTheme}
|
theme={calendarTheme}
|
||||||
// Max amount of months allowed to scroll to the past.
|
// Max amount of months allowed to scroll to the past.
|
||||||
pastScrollRange={120}
|
pastScrollRange={120}
|
||||||
|
|||||||
+64
-63
@@ -6,7 +6,7 @@ import {
|
|||||||
FlatList,
|
FlatList,
|
||||||
PixelRatio,
|
PixelRatio,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
View
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
|
||||||
import AppLoadingView from '../common/app-loading'
|
import AppLoadingView from '../common/app-loading'
|
||||||
@@ -24,7 +24,11 @@ import { navigate } from '../../slices/navigation'
|
|||||||
|
|
||||||
import { getCycleDaysSortedByDate } from '../../db'
|
import { getCycleDaysSortedByDate } from '../../db'
|
||||||
import nothingChanged from '../../db/db-unchanged'
|
import nothingChanged from '../../db/db-unchanged'
|
||||||
import { getChartFlag, scaleObservable, setChartFlag } from '../../local-storage'
|
import {
|
||||||
|
getChartFlag,
|
||||||
|
scaleObservable,
|
||||||
|
setChartFlag,
|
||||||
|
} from '../../local-storage'
|
||||||
import { makeColumnInfo, nfpLines } from '../helpers/chart'
|
import { makeColumnInfo, nfpLines } from '../helpers/chart'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -32,7 +36,7 @@ import {
|
|||||||
CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
CHART_GRID_LINE_HORIZONTAL_WIDTH,
|
||||||
CHART_SYMPTOM_HEIGHT_RATIO,
|
CHART_SYMPTOM_HEIGHT_RATIO,
|
||||||
CHART_XAXIS_HEIGHT_RATIO,
|
CHART_XAXIS_HEIGHT_RATIO,
|
||||||
SYMPTOMS
|
SYMPTOMS,
|
||||||
} from '../../config'
|
} from '../../config'
|
||||||
import { shared } from '../../i18n/en/labels'
|
import { shared } from '../../i18n/en/labels'
|
||||||
import { Colors, Spacing } from '../../styles'
|
import { Colors, Spacing } from '../../styles'
|
||||||
@@ -40,7 +44,7 @@ import { Colors, Spacing } from '../../styles'
|
|||||||
class CycleChart extends Component {
|
class CycleChart extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigate: PropTypes.func,
|
navigate: PropTypes.func,
|
||||||
end: PropTypes.bool
|
end: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -80,12 +84,12 @@ class CycleChart extends Component {
|
|||||||
|
|
||||||
prepareSymptomData = () => {
|
prepareSymptomData = () => {
|
||||||
this.symptomRowSymptoms = SYMPTOMS.filter((symptomName) => {
|
this.symptomRowSymptoms = SYMPTOMS.filter((symptomName) => {
|
||||||
return this.cycleDaysSortedByDate.some(cycleDay => {
|
return this.cycleDaysSortedByDate.some((cycleDay) => {
|
||||||
return (symptomName !== 'temperature') && cycleDay[symptomName]
|
return symptomName !== 'temperature' && cycleDay[symptomName]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.chartSymptoms = [...this.symptomRowSymptoms]
|
this.chartSymptoms = [...this.symptomRowSymptoms]
|
||||||
if (this.cycleDaysSortedByDate.some(day => day.temperature)) {
|
if (this.cycleDaysSortedByDate.some((day) => day.temperature)) {
|
||||||
this.chartSymptoms.push('temperature')
|
this.chartSymptoms.push('temperature')
|
||||||
this.shouldShowTemperatureColumn = true
|
this.shouldShowTemperatureColumn = true
|
||||||
}
|
}
|
||||||
@@ -114,15 +118,16 @@ class CycleChart extends Component {
|
|||||||
this.xAxisHeight = height * 0.7 * CHART_XAXIS_HEIGHT_RATIO
|
this.xAxisHeight = height * 0.7 * CHART_XAXIS_HEIGHT_RATIO
|
||||||
const remainingHeight = height * 0.7 - this.xAxisHeight
|
const remainingHeight = height * 0.7 - this.xAxisHeight
|
||||||
this.symptomHeight = PixelRatio.roundToNearestPixel(
|
this.symptomHeight = PixelRatio.roundToNearestPixel(
|
||||||
remainingHeight
|
remainingHeight * CHART_SYMPTOM_HEIGHT_RATIO
|
||||||
* CHART_SYMPTOM_HEIGHT_RATIO
|
|
||||||
)
|
)
|
||||||
this.symptomRowHeight = PixelRatio.roundToNearestPixel(
|
this.symptomRowHeight =
|
||||||
this.symptomRowSymptoms.length * this.symptomHeight
|
PixelRatio.roundToNearestPixel(
|
||||||
) + CHART_GRID_LINE_HORIZONTAL_WIDTH
|
this.symptomRowSymptoms.length * this.symptomHeight
|
||||||
|
) + CHART_GRID_LINE_HORIZONTAL_WIDTH
|
||||||
this.columnHeight = remainingHeight - this.symptomRowHeight
|
this.columnHeight = remainingHeight - this.symptomRowHeight
|
||||||
const chartHeight = this.shouldShowTemperatureColumn ?
|
const chartHeight = this.shouldShowTemperatureColumn
|
||||||
height * 0.7 : (this.symptomRowHeight + this.xAxisHeight)
|
? height * 0.7
|
||||||
|
: this.symptomRowHeight + this.xAxisHeight
|
||||||
const numberOfColumnsToRender = Math.round(width / CHART_COLUMN_WIDTH)
|
const numberOfColumnsToRender = Math.round(width / CHART_COLUMN_WIDTH)
|
||||||
const columns = makeColumnInfo()
|
const columns = makeColumnInfo()
|
||||||
|
|
||||||
@@ -131,7 +136,7 @@ class CycleChart extends Component {
|
|||||||
|
|
||||||
updateListeners(dataUpdateHandler) {
|
updateListeners(dataUpdateHandler) {
|
||||||
// remove existing listeners
|
// remove existing listeners
|
||||||
if(this.handleDbChange) {
|
if (this.handleDbChange) {
|
||||||
this.cycleDaysSortedByDate.removeListener(this.handleDbChange)
|
this.cycleDaysSortedByDate.removeListener(this.handleDbChange)
|
||||||
}
|
}
|
||||||
if (this.removeObvListener) this.removeObvListener()
|
if (this.removeObvListener) this.removeObvListener()
|
||||||
@@ -150,7 +155,7 @@ class CycleChart extends Component {
|
|||||||
chartHeight,
|
chartHeight,
|
||||||
chartLoaded,
|
chartLoaded,
|
||||||
shouldShowHint,
|
shouldShowHint,
|
||||||
numberOfColumnsToRender
|
numberOfColumnsToRender,
|
||||||
} = this.state
|
} = this.state
|
||||||
const hasDataToDisplay = this.chartSymptoms.length > 0
|
const hasDataToDisplay = this.chartSymptoms.length > 0
|
||||||
|
|
||||||
@@ -163,53 +168,52 @@ class CycleChart extends Component {
|
|||||||
{!hasDataToDisplay && <NoData />}
|
{!hasDataToDisplay && <NoData />}
|
||||||
{hasDataToDisplay && !chartHeight && !chartLoaded && <AppLoadingView />}
|
{hasDataToDisplay && !chartHeight && !chartLoaded && <AppLoadingView />}
|
||||||
<View style={styles.chartContainer}>
|
<View style={styles.chartContainer}>
|
||||||
{shouldShowHint && chartLoaded &&
|
{shouldShowHint && chartLoaded && (
|
||||||
<Tutorial onClose={this.setShouldShowHint} />
|
<Tutorial onClose={this.setShouldShowHint} />
|
||||||
}
|
)}
|
||||||
{hasDataToDisplay && chartLoaded &&
|
{hasDataToDisplay &&
|
||||||
!this.shouldShowTemperatureColumn &&
|
chartLoaded &&
|
||||||
<View style={styles.centerItem}>
|
!this.shouldShowTemperatureColumn && (
|
||||||
<AppText style={styles.warning}>
|
<View style={styles.centerItem}>
|
||||||
{shared.noTemperatureWarning}
|
<AppText style={styles.warning}>
|
||||||
</AppText>
|
{shared.noTemperatureWarning}
|
||||||
</View>
|
</AppText>
|
||||||
}
|
</View>
|
||||||
|
)}
|
||||||
{hasDataToDisplay && (
|
{hasDataToDisplay && (
|
||||||
<View style={styles.chartArea}>
|
<View style={styles.chartArea}>
|
||||||
|
|
||||||
{chartHeight && chartLoaded && (
|
{chartHeight && chartLoaded && (
|
||||||
<YAxis
|
<YAxis
|
||||||
height={this.columnHeight}
|
height={this.columnHeight}
|
||||||
symptomsToDisplay={this.symptomRowSymptoms}
|
symptomsToDisplay={this.symptomRowSymptoms}
|
||||||
symptomsSectionHeight={this.symptomRowHeight}
|
symptomsSectionHeight={this.symptomRowHeight}
|
||||||
shouldShowTemperatureColumn=
|
shouldShowTemperatureColumn={this.shouldShowTemperatureColumn}
|
||||||
{this.shouldShowTemperatureColumn}
|
|
||||||
xAxisHeight={this.xAxisHeight}
|
xAxisHeight={this.xAxisHeight}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{chartHeight &&
|
{chartHeight && (
|
||||||
<FlatList
|
<FlatList
|
||||||
horizontal={true}
|
horizontal={true}
|
||||||
inverted={true}
|
inverted={true}
|
||||||
showsHorizontalScrollIndicator={false}
|
showsHorizontalScrollIndicator={false}
|
||||||
data={this.state.columns}
|
data={this.state.columns}
|
||||||
renderItem={this.renderColumn}
|
renderItem={this.renderColumn}
|
||||||
keyExtractor={item => item}
|
keyExtractor={(item) => item}
|
||||||
initialNumToRender={numberOfColumnsToRender}
|
initialNumToRender={numberOfColumnsToRender}
|
||||||
windowSize={30}
|
windowSize={30}
|
||||||
onLayout={() => this.setState({chartLoaded: true})}
|
onLayout={() => this.setState({ chartLoaded: true })}
|
||||||
onEndReached={() => this.setState({end: true})}
|
onEndReached={() => this.setState({ end: true })}
|
||||||
ListFooterComponent={<LoadingMoreView end={this.state.end}/>}
|
ListFooterComponent={<LoadingMoreView end={this.state.end} />}
|
||||||
updateCellsBatchingPeriod={800}
|
updateCellsBatchingPeriod={800}
|
||||||
contentContainerStyle={{ height: chartHeight }}
|
contentContainerStyle={{ height: chartHeight }}
|
||||||
/>
|
/>
|
||||||
}
|
)}
|
||||||
{chartHeight && chartLoaded && (
|
{chartHeight && chartLoaded && (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{this.shouldShowTemperatureColumn &&
|
{this.shouldShowTemperatureColumn && (
|
||||||
<HorizontalGrid height={this.columnHeight} />
|
<HorizontalGrid height={this.columnHeight} />
|
||||||
}
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
@@ -223,45 +227,42 @@ class CycleChart extends Component {
|
|||||||
function LoadingMoreView({ end }) {
|
function LoadingMoreView({ end }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.loadingContainer}>
|
<View style={styles.loadingContainer}>
|
||||||
{!end && <ActivityIndicator size={'large'} color={Colors.orange}/>}
|
{!end && <ActivityIndicator size={'large'} color={Colors.orange} />}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadingMoreView.propTypes = {
|
LoadingMoreView.propTypes = {
|
||||||
end: PropTypes.bool
|
end: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
chartArea: {
|
chartArea: {
|
||||||
flexDirection: 'row'
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
chartContainer: {
|
chartContainer: {
|
||||||
flexDirection: 'column'
|
flexDirection: 'column',
|
||||||
},
|
},
|
||||||
loadingContainer: {
|
loadingContainer: {
|
||||||
height: '100%',
|
height: '100%',
|
||||||
backgroundColor: Colors.turquoiseLight,
|
backgroundColor: Colors.turquoiseLight,
|
||||||
justifyContent: 'center'
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
page: {
|
page: {
|
||||||
marginVertical: Spacing.small
|
marginVertical: Spacing.small,
|
||||||
},
|
},
|
||||||
pageContainer: {
|
pageContainer: {
|
||||||
paddingHorizontal: Spacing.base
|
paddingHorizontal: Spacing.base,
|
||||||
},
|
},
|
||||||
warning: {
|
warning: {
|
||||||
padding: Spacing.large
|
padding: Spacing.large,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return {
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, mapDispatchToProps)(CycleChart)
|
||||||
null,
|
|
||||||
mapDispatchToProps,
|
|
||||||
)(CycleChart)
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import CycleDayLabel from './cycle-day-label'
|
|||||||
import {
|
import {
|
||||||
symptomColorMethods,
|
symptomColorMethods,
|
||||||
getTemperatureProps,
|
getTemperatureProps,
|
||||||
isSymptomDataComplete
|
isSymptomDataComplete,
|
||||||
} from '../helpers/chart'
|
} from '../helpers/chart'
|
||||||
|
|
||||||
class DayColumn extends Component {
|
class DayColumn extends Component {
|
||||||
@@ -40,14 +40,17 @@ class DayColumn extends Component {
|
|||||||
this.data = {}
|
this.data = {}
|
||||||
|
|
||||||
if (cycleDayData) {
|
if (cycleDayData) {
|
||||||
this.data = chartSymptoms.reduce((symptomDataToDisplay, symptom, ) => {
|
this.data = chartSymptoms.reduce((symptomDataToDisplay, symptom) => {
|
||||||
const symptomData = cycleDayData[symptom]
|
const symptomData = cycleDayData[symptom]
|
||||||
|
|
||||||
if (symptomData && symptom === 'temperature') {
|
if (symptomData && symptom === 'temperature') {
|
||||||
symptomDataToDisplay[symptom] =
|
symptomDataToDisplay[symptom] = getTemperatureProps(
|
||||||
getTemperatureProps(symptomData, columnHeight, dateString)
|
symptomData,
|
||||||
|
columnHeight,
|
||||||
|
dateString
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
if (symptomData && ! symptomData.exclude) {
|
if (symptomData && !symptomData.exclude) {
|
||||||
// if symptomColorMethods entry doesn't exist for given symptom,
|
// if symptomColorMethods entry doesn't exist for given symptom,
|
||||||
// use 'default'
|
// use 'default'
|
||||||
const getSymptomColorIndex =
|
const getSymptomColorIndex =
|
||||||
@@ -78,12 +81,13 @@ class DayColumn extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { columnHeight,
|
const {
|
||||||
|
columnHeight,
|
||||||
dateString,
|
dateString,
|
||||||
shouldShowTemperatureColumn,
|
shouldShowTemperatureColumn,
|
||||||
symptomHeight,
|
symptomHeight,
|
||||||
symptomRowSymptoms,
|
symptomRowSymptoms,
|
||||||
xAxisHeight
|
xAxisHeight,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -91,22 +95,22 @@ class DayColumn extends Component {
|
|||||||
onPress={() => this.onDaySelect(dateString)}
|
onPress={() => this.onDaySelect(dateString)}
|
||||||
activeOpacity={1}
|
activeOpacity={1}
|
||||||
>
|
>
|
||||||
|
{shouldShowTemperatureColumn && (
|
||||||
|
<TemperatureColumn
|
||||||
|
horizontalLinePosition={this.fhmAndLtl.drawLtlAt}
|
||||||
|
isVerticalLine={this.fhmAndLtl.drawFhmLine}
|
||||||
|
data={this.data && this.data.temperature}
|
||||||
|
columnHeight={columnHeight}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{shouldShowTemperatureColumn && <TemperatureColumn
|
<CycleDayLabel height={xAxisHeight} date={dateString} />
|
||||||
horizontalLinePosition={this.fhmAndLtl.drawLtlAt}
|
|
||||||
isVerticalLine={this.fhmAndLtl.drawFhmLine}
|
|
||||||
data={this.data && this.data.temperature}
|
|
||||||
columnHeight={columnHeight}
|
|
||||||
/>}
|
|
||||||
|
|
||||||
<CycleDayLabel
|
{symptomRowSymptoms.map((symptom, i) => {
|
||||||
height={xAxisHeight}
|
const hasSymptomData = Object.prototype.hasOwnProperty.call(
|
||||||
date={dateString}
|
this.data,
|
||||||
/>
|
symptom
|
||||||
|
)
|
||||||
{ symptomRowSymptoms.map((symptom, i) => {
|
|
||||||
const hasSymptomData =
|
|
||||||
Object.prototype.hasOwnProperty.call(this.data, symptom)
|
|
||||||
return (
|
return (
|
||||||
<SymptomCell
|
<SymptomCell
|
||||||
index={i}
|
index={i}
|
||||||
@@ -117,23 +121,19 @@ class DayColumn extends Component {
|
|||||||
hasSymptomData && isSymptomDataComplete(symptom, dateString)
|
hasSymptomData && isSymptomDataComplete(symptom, dateString)
|
||||||
}
|
}
|
||||||
height={symptomHeight}
|
height={symptomHeight}
|
||||||
/>)
|
/>
|
||||||
}
|
)
|
||||||
)}
|
})}
|
||||||
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return {
|
||||||
setDate: (date) => dispatch(setDate(date)),
|
setDate: (date) => dispatch(setDate(date)),
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, mapDispatchToProps)(DayColumn)
|
||||||
null,
|
|
||||||
mapDispatchToProps,
|
|
||||||
)(DayColumn)
|
|
||||||
|
|||||||
@@ -15,7 +15,12 @@ const NoData = ({ navigate }) => {
|
|||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<AppText>{shared.noDataWarning}</AppText>
|
<AppText>{shared.noDataWarning}</AppText>
|
||||||
<Button isCTA onPress={() => {navigate('CycleDay')}}>
|
<Button
|
||||||
|
isCTA
|
||||||
|
onPress={() => {
|
||||||
|
navigate('CycleDay')
|
||||||
|
}}
|
||||||
|
>
|
||||||
{shared.noDataButtonText}
|
{shared.noDataButtonText}
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
@@ -28,17 +33,14 @@ NoData.propTypes = {
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
...Containers.centerItems
|
...Containers.centerItems,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return {
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, mapDispatchToProps)(NoData)
|
||||||
null,
|
|
||||||
mapDispatchToProps,
|
|
||||||
)(NoData)
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { navigate } from '../../slices/navigation'
|
|||||||
import { Colors, Fonts, Sizes } from '../../styles'
|
import { Colors, Fonts, Sizes } from '../../styles'
|
||||||
|
|
||||||
const Logo = ({ navigate }) => {
|
const Logo = ({ navigate }) => {
|
||||||
return(
|
return (
|
||||||
<TouchableOpacity onPress={() => navigate('Home')}>
|
<TouchableOpacity onPress={() => navigate('Home')}>
|
||||||
<AppText style={styles.logo}>drip.</AppText>
|
<AppText style={styles.logo}>drip.</AppText>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -18,24 +18,21 @@ const Logo = ({ navigate }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logo.propTypes = {
|
Logo.propTypes = {
|
||||||
navigate: PropTypes.func.isRequired
|
navigate: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
logo: {
|
logo: {
|
||||||
color: Colors.turquoiseDark,
|
color: Colors.turquoiseDark,
|
||||||
fontFamily: Fonts.bold,
|
fontFamily: Fonts.bold,
|
||||||
fontSize: Sizes.title
|
fontSize: Sizes.title,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return {
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, mapDispatchToProps)(Logo)
|
||||||
null,
|
|
||||||
mapDispatchToProps,
|
|
||||||
)(Logo)
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const MenuItem = ({ item, navigate, closeMenu }) => {
|
|||||||
navigate(component)
|
navigate(component)
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return (
|
||||||
<TouchableOpacity onPress={onPress}>
|
<TouchableOpacity onPress={onPress}>
|
||||||
<AppText style={styles.text}>{name}</AppText>
|
<AppText style={styles.text}>{name}</AppText>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -26,22 +26,19 @@ const MenuItem = ({ item, navigate, closeMenu }) => {
|
|||||||
MenuItem.propTypes = {
|
MenuItem.propTypes = {
|
||||||
item: PropTypes.object.isRequired,
|
item: PropTypes.object.isRequired,
|
||||||
navigate: PropTypes.func.isRequired,
|
navigate: PropTypes.func.isRequired,
|
||||||
closeMenu: PropTypes.func.isRequired
|
closeMenu: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
text: {
|
text: {
|
||||||
...Typography.subtitle
|
...Typography.subtitle,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return {
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, mapDispatchToProps)(MenuItem)
|
||||||
null,
|
|
||||||
mapDispatchToProps,
|
|
||||||
)(MenuItem)
|
|
||||||
|
|||||||
@@ -10,17 +10,16 @@ import { getNavigation, navigate } from '../../slices/navigation'
|
|||||||
import { Colors, Containers, Fonts, Sizes, Spacing } from '../../styles'
|
import { Colors, Containers, Fonts, Sizes, Spacing } from '../../styles'
|
||||||
|
|
||||||
const MenuItem = ({ component, icon, label, navigate, navigation }) => {
|
const MenuItem = ({ component, icon, label, navigate, navigation }) => {
|
||||||
const isActive = (component === navigation.currentPage)
|
const isActive = component === navigation.currentPage
|
||||||
const textStyle = isActive ? styles.menuTextActive : styles.menuText
|
const textStyle = isActive ? styles.menuTextActive : styles.menuText
|
||||||
const testID = isActive ? 'activeMenuItem' : `menuItem${label}`
|
const testID = isActive ? 'activeMenuItem' : `menuItem${label}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity style={styles.button} onPress={() => navigate(component)}>
|
||||||
style={styles.button}
|
<Icon name={icon} isActive={isActive} />
|
||||||
onPress={() => navigate(component)}
|
<Text testID={testID} style={textStyle}>
|
||||||
>
|
{label}
|
||||||
<Icon name={icon} isActive={isActive}/>
|
</Text>
|
||||||
<Text testID={testID} style={textStyle} >{label}</Text>
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -36,37 +35,34 @@ MenuItem.propTypes = {
|
|||||||
const text = {
|
const text = {
|
||||||
fontFamily: Fonts.bold,
|
fontFamily: Fonts.bold,
|
||||||
fontSize: Sizes.small,
|
fontSize: Sizes.small,
|
||||||
textTransform: 'uppercase'
|
textTransform: 'uppercase',
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
button: {
|
button: {
|
||||||
padding: Spacing.base,
|
padding: Spacing.base,
|
||||||
...Containers.centerItems
|
...Containers.centerItems,
|
||||||
},
|
},
|
||||||
menuText: {
|
menuText: {
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
...text
|
...text,
|
||||||
},
|
},
|
||||||
menuTextActive: {
|
menuTextActive: {
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
...text
|
...text,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return({
|
return {
|
||||||
navigation: getNavigation(state),
|
navigation: getNavigation(state),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return {
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(mapStateToProps, mapDispatchToProps)(MenuItem)
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps,
|
|
||||||
)(MenuItem)
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const cancelButton = { text: shared.cancel, style: 'cancel' }
|
|||||||
|
|
||||||
export default class PasswordPrompt extends Component {
|
export default class PasswordPrompt extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
enableShowApp: PropTypes.func.isRequired
|
enableShowApp: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -32,22 +32,20 @@ export default class PasswordPrompt extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onConfirmDeletion = async () => {
|
onConfirmDeletion = async () => {
|
||||||
Alert.alert(
|
Alert.alert(labels.deleteDatabaseTitle, labels.deleteDatabaseExplainer, [
|
||||||
labels.deleteDatabaseTitle,
|
cancelButton,
|
||||||
labels.deleteDatabaseExplainer,
|
{ text: labels.deleteData, onPress: this.onDeleteData },
|
||||||
[cancelButton, { text: labels.deleteData, onPress: this.onDeleteData}]
|
])
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeleteData = () => {
|
onDeleteData = () => {
|
||||||
Alert.alert(
|
Alert.alert(labels.areYouSureTitle, labels.areYouSure, [
|
||||||
labels.areYouSureTitle,
|
cancelButton,
|
||||||
labels.areYouSure,
|
{
|
||||||
[cancelButton, {
|
|
||||||
text: labels.reallyDeleteData,
|
text: labels.reallyDeleteData,
|
||||||
onPress: this.onDeleteDataConfirmation
|
onPress: this.onDeleteDataConfirmation,
|
||||||
}]
|
},
|
||||||
)
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeleteDataConfirmation = async () => {
|
onDeleteDataConfirmation = async () => {
|
||||||
@@ -56,17 +54,15 @@ export default class PasswordPrompt extends Component {
|
|||||||
this.props.enableShowApp()
|
this.props.enableShowApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
passHashToDb = async hash => {
|
passHashToDb = async (hash) => {
|
||||||
const connected = await openDb(hash)
|
const connected = await openDb(hash)
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
Alert.alert(
|
Alert.alert(shared.incorrectPassword, shared.incorrectPasswordMessage, [
|
||||||
shared.incorrectPassword,
|
{
|
||||||
shared.incorrectPasswordMessage,
|
|
||||||
[{
|
|
||||||
text: shared.tryAgain,
|
text: shared.tryAgain,
|
||||||
onPress: () => this.setState({ password: null })
|
onPress: () => this.setState({ password: null }),
|
||||||
}]
|
},
|
||||||
)
|
])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.props.enableShowApp()
|
this.props.enableShowApp()
|
||||||
@@ -116,10 +112,10 @@ const styles = StyleSheet.create({
|
|||||||
contentContainer: {
|
contentContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginHorizontal: Spacing.base
|
marginHorizontal: Spacing.base,
|
||||||
},
|
},
|
||||||
containerButtons: {
|
containerButtons: {
|
||||||
...Containers.rowContainer,
|
...Containers.rowContainer,
|
||||||
justifyContent: 'space-around'
|
justifyContent: 'space-around',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,22 +27,20 @@ export default class ConfirmWithPassword extends Component {
|
|||||||
this.setState({ password: null })
|
this.setState({ password: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onIncorrectPassword = () => {
|
onIncorrectPassword = () => {
|
||||||
Alert.alert(
|
Alert.alert(shared.incorrectPassword, shared.incorrectPasswordMessage, [
|
||||||
shared.incorrectPassword,
|
{
|
||||||
shared.incorrectPasswordMessage,
|
|
||||||
[{
|
|
||||||
text: shared.cancel,
|
text: shared.cancel,
|
||||||
onPress: this.props.onCancel
|
onPress: this.props.onCancel,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
text: shared.tryAgain,
|
text: shared.tryAgain,
|
||||||
onPress: this.resetPasswordInput
|
onPress: this.resetPasswordInput,
|
||||||
}]
|
},
|
||||||
)
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
checkPassword = async hash => {
|
checkPassword = async (hash) => {
|
||||||
try {
|
try {
|
||||||
await openDb(hash)
|
await openDb(hash)
|
||||||
this.props.onSuccess()
|
this.props.onSuccess()
|
||||||
@@ -73,9 +71,7 @@ export default class ConfirmWithPassword extends Component {
|
|||||||
secureTextEntry={true}
|
secureTextEntry={true}
|
||||||
/>
|
/>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Button onPress={this.props.onCancel}>
|
<Button onPress={this.props.onCancel}>{shared.cancel}</Button>
|
||||||
{shared.cancel}
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
disabled={!isPassword}
|
disabled={!isPassword}
|
||||||
isCTA={isPassword}
|
isCTA={isPassword}
|
||||||
@@ -86,17 +82,16 @@ export default class ConfirmWithPassword extends Component {
|
|||||||
</View>
|
</View>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfirmWithPassword.propTypes = {
|
ConfirmWithPassword.propTypes = {
|
||||||
onSuccess: PropTypes.func,
|
onSuccess: PropTypes.func,
|
||||||
onCancel: PropTypes.func
|
onCancel: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
...Containers.rowContainer
|
...Containers.rowContainer,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default class DeleteData extends Component {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isPasswordSet: hasEncryptionObservable.value,
|
isPasswordSet: hasEncryptionObservable.value,
|
||||||
isConfirmingWithPassword: false
|
isConfirmingWithPassword: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,21 +38,20 @@ export default class DeleteData extends Component {
|
|||||||
|
|
||||||
alertBeforeDeletion = async () => {
|
alertBeforeDeletion = async () => {
|
||||||
const { question, message, confirmation, errors } = settings.deleteSegment
|
const { question, message, confirmation, errors } = settings.deleteSegment
|
||||||
if (isDbEmpty() && !await RNFS.exists(exportedFilePath)) {
|
if (isDbEmpty() && !(await RNFS.exists(exportedFilePath))) {
|
||||||
alertError(errors.noData)
|
alertError(errors.noData)
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(
|
Alert.alert(question, message, [
|
||||||
question,
|
{
|
||||||
message,
|
|
||||||
[{
|
|
||||||
text: confirmation,
|
text: confirmation,
|
||||||
onPress: this.onAlertConfirmation
|
onPress: this.onAlertConfirmation,
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
text: sharedLabels.cancel,
|
text: sharedLabels.cancel,
|
||||||
style: 'cancel',
|
style: 'cancel',
|
||||||
onPress: this.cancelConfirmationWithPassword
|
onPress: this.cancelConfirmationWithPassword,
|
||||||
}]
|
},
|
||||||
)
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,5 +103,5 @@ export default class DeleteData extends Component {
|
|||||||
|
|
||||||
DeleteData.propTypes = {
|
DeleteData.propTypes = {
|
||||||
isDeletingData: PropTypes.bool,
|
isDeletingData: PropTypes.bool,
|
||||||
onStartDeletion: PropTypes.func.isRequired
|
onStartDeletion: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,12 @@ import labels from '../../../i18n/en/settings'
|
|||||||
import { ACTION_DELETE, ACTION_EXPORT, ACTION_IMPORT } from '../../../config'
|
import { ACTION_DELETE, ACTION_EXPORT, ACTION_IMPORT } from '../../../config'
|
||||||
|
|
||||||
export default class DataManagement extends Component {
|
export default class DataManagement extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
currentAction: null
|
currentAction: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ export default class DataManagement extends Component {
|
|||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{isLoading && <AppLoadingView />}
|
{isLoading && <AppLoadingView />}
|
||||||
{!isLoading &&
|
{!isLoading && (
|
||||||
<AppPage>
|
<AppPage>
|
||||||
<Segment title={labels.export.button}>
|
<Segment title={labels.export.button}>
|
||||||
<AppText>{labels.export.segmentExplainer}</AppText>
|
<AppText>{labels.export.segmentExplainer}</AppText>
|
||||||
@@ -79,13 +78,13 @@ export default class DataManagement extends Component {
|
|||||||
<Segment title={labels.deleteSegment.title} last>
|
<Segment title={labels.deleteSegment.title} last>
|
||||||
<AppText>{labels.deleteSegment.explainer}</AppText>
|
<AppText>{labels.deleteSegment.explainer}</AppText>
|
||||||
<DeleteData
|
<DeleteData
|
||||||
isDeletingData = {isDeletingData}
|
isDeletingData={isDeletingData}
|
||||||
onStartDeletion = {() => this.setCurrentAction(ACTION_DELETE)}
|
onStartDeletion={() => this.setCurrentAction(ACTION_DELETE)}
|
||||||
/>
|
/>
|
||||||
</Segment>
|
</Segment>
|
||||||
</AppPage>
|
</AppPage>
|
||||||
}
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const MenuItem = ({ item, last, navigate }) => {
|
|||||||
<AppText style={styles.title}>{item.name}</AppText>
|
<AppText style={styles.title}>{item.name}</AppText>
|
||||||
{item.text.length > 0 && <AppText>{item.text}</AppText>}
|
{item.text.length > 0 && <AppText>{item.text}</AppText>}
|
||||||
</View>
|
</View>
|
||||||
<AppIcon name='chevron-right' color={Colors.orange}/>
|
<AppIcon name="chevron-right" color={Colors.orange} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</Segment>
|
</Segment>
|
||||||
)
|
)
|
||||||
@@ -32,26 +32,23 @@ const MenuItem = ({ item, last, navigate }) => {
|
|||||||
MenuItem.propTypes = {
|
MenuItem.propTypes = {
|
||||||
item: PropTypes.object.isRequired,
|
item: PropTypes.object.isRequired,
|
||||||
last: PropTypes.bool.isRequired,
|
last: PropTypes.bool.isRequired,
|
||||||
navigate: PropTypes.func.isRequired
|
navigate: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
...Containers.rowContainer
|
...Containers.rowContainer,
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
color: Colors.purple,
|
color: Colors.purple,
|
||||||
fontSize: Sizes.subtitle
|
fontSize: Sizes.subtitle,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return {
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(null, mapDispatchToProps)(MenuItem)
|
||||||
null,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(MenuItem)
|
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ export default class TemperatureSlider extends Component {
|
|||||||
onTemperatureSliderChange = (values) => {
|
onTemperatureSliderChange = (values) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
minTemperature: values[0],
|
minTemperature: values[0],
|
||||||
maxTemperature: values[1]
|
maxTemperature: values[1],
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
saveTempScale({ min: values[0], max: values[1] })
|
saveTempScale({ min: values[0], max: values[1] })
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
alertError(labels.tempScale.saveError)
|
alertError(labels.tempScale.saveError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,23 +58,23 @@ export default class TemperatureSlider extends Component {
|
|||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
paddingTop: Sizes.base
|
paddingTop: Sizes.base,
|
||||||
},
|
},
|
||||||
marker: {
|
marker: {
|
||||||
backgroundColor: Colors.turquoiseDark,
|
backgroundColor: Colors.turquoiseDark,
|
||||||
borderRadius: 50,
|
borderRadius: 50,
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
height: Sizes.subtitle,
|
height: Sizes.subtitle,
|
||||||
width: Sizes.subtitle
|
width: Sizes.subtitle,
|
||||||
},
|
},
|
||||||
slider: {
|
slider: {
|
||||||
borderRadius: 25,
|
borderRadius: 25,
|
||||||
height: Sizes.small
|
height: Sizes.small,
|
||||||
},
|
},
|
||||||
sliderAccentBackground: {
|
sliderAccentBackground: {
|
||||||
backgroundColor: Colors.turquoiseDark
|
backgroundColor: Colors.turquoiseDark,
|
||||||
},
|
},
|
||||||
sliderBackground: {
|
sliderBackground: {
|
||||||
backgroundColor: Colors.turquoise
|
backgroundColor: Colors.turquoise,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import AppSwitch from '../../common/app-switch'
|
|||||||
import Segment from '../../common/segment'
|
import Segment from '../../common/segment'
|
||||||
import TemperatureReminder from './temperature-reminder'
|
import TemperatureReminder from './temperature-reminder'
|
||||||
|
|
||||||
import { periodReminderObservable, savePeriodReminder } from '../../../local-storage'
|
import {
|
||||||
|
periodReminderObservable,
|
||||||
|
savePeriodReminder,
|
||||||
|
} from '../../../local-storage'
|
||||||
|
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
|
|
||||||
@@ -14,7 +17,7 @@ export default class Reminders extends Component {
|
|||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isPeriodReminderEnabled: periodReminderObservable.value.enabled
|
isPeriodReminderEnabled: periodReminderObservable.value.enabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user