Lint rule react prop types addition
This commit is contained in:
committed by
Sofiya Tepikin
parent
8444d466db
commit
47379d7a1e
@@ -44,7 +44,7 @@
|
|||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
"prefer-const": "error",
|
"prefer-const": "error",
|
||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"react/prop-types": 0,
|
"react/prop-types": 2,
|
||||||
"max-len": [
|
"max-len": [
|
||||||
1,
|
1,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ export default function AppTextInput({ style, ...props }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppTextInput.propTypes = {
|
AppTextInput.propTypes = {
|
||||||
secureTextEntry: PropTypes.bool
|
autoFocus: PropTypes.bool,
|
||||||
|
onChangeText: PropTypes.func,
|
||||||
|
placeholder: PropTypes.string,
|
||||||
|
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
||||||
|
value: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
AppTextInput.defaultProps = {
|
AppTextInput.defaultProps = {
|
||||||
|
|||||||
+12
-13
@@ -1,27 +1,26 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { Text } from 'react-native'
|
import { Text } from 'react-native'
|
||||||
import styles from "../styles"
|
import styles from "../styles"
|
||||||
import Link from './link'
|
import Link from './link'
|
||||||
|
|
||||||
export default function AppText(props) {
|
export default function AppText({ children, onPress, numberOfLines, style}) {
|
||||||
// we parse for links in case the text contains any
|
// we parse for links in case the text contains any
|
||||||
return (
|
return (
|
||||||
<Link>
|
<Link>
|
||||||
<Text
|
<Text style={[styles.appText, style]}
|
||||||
style={[styles.appText, props.style]}
|
onPress={onPress}
|
||||||
onPress={props.onPress}
|
numberOfLines={numberOfLines}
|
||||||
numberOfLines={props.numberOfLines}
|
|
||||||
>
|
>
|
||||||
{props.children}
|
{children}
|
||||||
</Text>
|
</Text>
|
||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SymptomSectionHeader(props) {
|
AppText.propTypes = {
|
||||||
return (
|
children: PropTypes.node,
|
||||||
<AppText style={styles.symptomViewHeading}>
|
onPress: PropTypes.func,
|
||||||
{props.children}
|
numberOfLines: PropTypes.number,
|
||||||
</AppText>
|
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
||||||
)
|
}
|
||||||
}
|
|
||||||
|
|||||||
+21
-12
@@ -1,22 +1,31 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { TouchableOpacity } from 'react-native'
|
import { TouchableOpacity } from 'react-native'
|
||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
import styles from '../styles'
|
import styles from '../styles'
|
||||||
|
|
||||||
export default function Button(props) {
|
export default function Button({
|
||||||
|
backgroundColor,
|
||||||
|
children,
|
||||||
|
onPress,
|
||||||
|
style,
|
||||||
|
testID
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={props.onPress}
|
onPress={onPress}
|
||||||
style={[
|
style={[styles.button, style, { backgroundColor }]}
|
||||||
styles.button,
|
testID={testID}
|
||||||
props.style,
|
|
||||||
{backgroundColor: props.backgroundColor}
|
|
||||||
]}
|
|
||||||
testID={props.testID}
|
|
||||||
>
|
>
|
||||||
<AppText style={styles.homeButtonText}>
|
<AppText style={styles.homeButtonText}>{children}</AppText>
|
||||||
{props.children}
|
|
||||||
</AppText>
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button.propTypes = {
|
||||||
|
backgroundColor: PropTypes.string,
|
||||||
|
children: PropTypes.node,
|
||||||
|
onPress: PropTypes.func,
|
||||||
|
style: PropTypes.object,
|
||||||
|
testID: PropTypes.string
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { CalendarList } from 'react-native-calendars'
|
import { CalendarList } from 'react-native-calendars'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
@@ -13,6 +14,11 @@ import styles from '../styles/index'
|
|||||||
import nothingChanged from '../db/db-unchanged'
|
import nothingChanged from '../db/db-unchanged'
|
||||||
|
|
||||||
class CalendarView extends Component {
|
class CalendarView extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
setDate: PropTypes.func.isRequired,
|
||||||
|
navigate: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.bleedingDays = getBleedingDaysSortedByDate()
|
this.bleedingDays = getBleedingDaysSortedByDate()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { View, FlatList, ActivityIndicator } from 'react-native'
|
import { View, FlatList, ActivityIndicator } from 'react-native'
|
||||||
|
|
||||||
import AppLoadingView from '../app-loading'
|
import AppLoadingView from '../app-loading'
|
||||||
@@ -17,6 +18,11 @@ import config from '../../config'
|
|||||||
import styles from './styles'
|
import styles from './styles'
|
||||||
|
|
||||||
export default class CycleChart extends Component {
|
export default class CycleChart extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
navigate: PropTypes.func,
|
||||||
|
end: PropTypes.bool
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {}
|
this.state = {}
|
||||||
@@ -147,12 +153,14 @@ export default class CycleChart extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function LoadingMoreView(props) {
|
function LoadingMoreView({ end }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.loadingMore}>
|
<View style={styles.loadingMore}>
|
||||||
{!props.end &&
|
{!end && <ActivityIndicator size={'large'} color={'white'}/>}
|
||||||
<ActivityIndicator size={'large'} color={'white'}/>
|
|
||||||
}
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadingMoreView.propTypes = {
|
||||||
|
end: PropTypes.bool
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { TouchableOpacity } from 'react-native'
|
import { TouchableOpacity } from 'react-native'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
@@ -18,6 +19,18 @@ import {
|
|||||||
} from '../helpers/chart'
|
} from '../helpers/chart'
|
||||||
|
|
||||||
class DayColumn extends Component {
|
class DayColumn extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
dateString: PropTypes.string.isRequired,
|
||||||
|
chartSymptoms: PropTypes.array,
|
||||||
|
columnHeight: PropTypes.number.isRequired,
|
||||||
|
getFhmAndLtlInfo: PropTypes.func.isRequired,
|
||||||
|
navigate: PropTypes.func.isRequired,
|
||||||
|
setDate: PropTypes.func.isRequired,
|
||||||
|
symptomHeight: PropTypes.number.isRequired,
|
||||||
|
symptomRowSymptoms: PropTypes.array,
|
||||||
|
xAxisHeight: PropTypes.number
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { Path, Shape } from 'react-native/Libraries/ART/ReactNativeART'
|
import { Path, Shape } from 'react-native/Libraries/ART/ReactNativeART'
|
||||||
|
|
||||||
import styles from './styles'
|
import styles from './styles'
|
||||||
import config from '../../config'
|
import config from '../../config'
|
||||||
|
|
||||||
export default class DotAndLine extends Component {
|
export default class DotAndLine extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
exclude: PropTypes.bool,
|
||||||
|
leftY: PropTypes.number,
|
||||||
|
leftTemperatureExclude: PropTypes.bool,
|
||||||
|
rightY: PropTypes.number,
|
||||||
|
rightTemperatureExclude: PropTypes.bool,
|
||||||
|
y: PropTypes.number.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(newProps) {
|
shouldComponentUpdate(newProps) {
|
||||||
return Object.keys(newProps).some(key => newProps[key] != this.props[key])
|
return Object.keys(newProps).some(key => newProps[key] != this.props[key])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { View, TouchableOpacity } from 'react-native'
|
import { View, TouchableOpacity } from 'react-native'
|
||||||
|
|
||||||
import AppText from '../app-text'
|
import AppText from '../app-text'
|
||||||
@@ -124,47 +125,50 @@ const l = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SymptomBox extends Component {
|
const getLabel = (symptom, symptomData) => {
|
||||||
getLabel = () => {
|
return symptomData && l[symptom](symptomData)
|
||||||
const { symptom, symptomData } = this.props
|
|
||||||
return symptomData && l[symptom](symptomData)
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { symptom, onPress, disabled } = this.props
|
|
||||||
const data = this.getLabel()
|
|
||||||
const iconName = `drip-icon-${symptom}`
|
|
||||||
|
|
||||||
const disabledStyle = disabled ? styles.symptomInFuture : null
|
|
||||||
const containerStyle = [
|
|
||||||
styles.symptomBox,
|
|
||||||
data && styles.symptomBoxActive,
|
|
||||||
disabledStyle
|
|
||||||
]
|
|
||||||
const titleStyle = [
|
|
||||||
data && styles.symptomTextActive,
|
|
||||||
disabledStyle,
|
|
||||||
{fontSize: 15}
|
|
||||||
]
|
|
||||||
const dataBoxStyle = [styles.symptomDataBox, disabledStyle]
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TouchableOpacity onPress={onPress} disabled={disabled} testID={iconName}>
|
|
||||||
<View style={containerStyle}>
|
|
||||||
<Icon name={iconName} isActive={data} />
|
|
||||||
<AppText style={titleStyle} numberOfLines={1}>
|
|
||||||
{symptomTitles[symptom].toLowerCase()}
|
|
||||||
</AppText>
|
|
||||||
</View>
|
|
||||||
<View style={dataBoxStyle}>
|
|
||||||
<AppText style={styles.symptomDataText} numberOfLines={3}>
|
|
||||||
{data}
|
|
||||||
</AppText>
|
|
||||||
</View>
|
|
||||||
</TouchableOpacity>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Icon = ({name, isActive}) =>
|
export default function SymptomBox(
|
||||||
<DripIcon name={name} size={50} color={isActive ? 'white' : 'black'} />
|
{ disabled, onPress, symptom, symptomData }) {
|
||||||
|
|
||||||
|
const data = getLabel(symptom, symptomData)
|
||||||
|
const iconName = `drip-icon-${symptom}`
|
||||||
|
|
||||||
|
const disabledStyle = disabled ? styles.symptomInFuture : null
|
||||||
|
const containerStyle = [
|
||||||
|
styles.symptomBox,
|
||||||
|
data && styles.symptomBoxActive,
|
||||||
|
disabledStyle
|
||||||
|
]
|
||||||
|
const titleStyle = [
|
||||||
|
data && styles.symptomTextActive,
|
||||||
|
disabledStyle,
|
||||||
|
{fontSize: 15}
|
||||||
|
]
|
||||||
|
const dataBoxStyle = [styles.symptomDataBox, disabledStyle]
|
||||||
|
const iconColor = data ? 'white' : 'black'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TouchableOpacity onPress={onPress} disabled={disabled} testID={iconName}>
|
||||||
|
<View style={containerStyle}>
|
||||||
|
<DripIcon name={iconName} size={50} color={iconColor} />
|
||||||
|
<AppText style={titleStyle} numberOfLines={1}>
|
||||||
|
{symptomTitles[symptom].toLowerCase()}
|
||||||
|
</AppText>
|
||||||
|
</View>
|
||||||
|
<View style={dataBoxStyle}>
|
||||||
|
<AppText style={styles.symptomDataText} numberOfLines={3}>
|
||||||
|
{data}
|
||||||
|
</AppText>
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
SymptomBox.propTypes = {
|
||||||
|
disabled: PropTypes.bool.isRequired,
|
||||||
|
onPress: PropTypes.func.isRequired,
|
||||||
|
symptom: PropTypes.string.isRequired,
|
||||||
|
symptomData: PropTypes.object
|
||||||
|
}
|
||||||
@@ -1,34 +1,38 @@
|
|||||||
import React, { Component } from 'react'
|
import React from 'react'
|
||||||
import {
|
import PropTypes from 'prop-types'
|
||||||
View,
|
import { View, TouchableOpacity } from 'react-native'
|
||||||
TouchableOpacity,
|
|
||||||
} from 'react-native'
|
|
||||||
import styles from '../../styles'
|
|
||||||
import AppText from '../app-text'
|
import AppText from '../app-text'
|
||||||
|
|
||||||
export default class SelectBoxGroup extends Component {
|
import styles from '../../styles'
|
||||||
render() {
|
|
||||||
return (
|
export default function SelectBoxGroup({ labels, onSelect, optionsState }) {
|
||||||
<View style={styles.selectBoxSection}>
|
return (
|
||||||
{Object.keys(this.props.labels).map(key => {
|
<View style={styles.selectBoxSection}>
|
||||||
const style = [styles.selectBox]
|
{Object.keys(labels).map(key => {
|
||||||
const textStyle = []
|
const style = [styles.selectBox]
|
||||||
if (this.props.optionsState[key]) {
|
const textStyle = []
|
||||||
style.push(styles.selectBoxActive)
|
if (optionsState[key]) {
|
||||||
textStyle.push(styles.selectBoxTextActive)
|
style.push(styles.selectBoxActive)
|
||||||
}
|
textStyle.push(styles.selectBoxTextActive)
|
||||||
return (
|
}
|
||||||
<TouchableOpacity
|
return (
|
||||||
onPress={() => this.props.onSelect(key)}
|
<TouchableOpacity
|
||||||
key={key}
|
onPress={() => onSelect(key)}
|
||||||
>
|
key={key}
|
||||||
<View style={style}>
|
>
|
||||||
<AppText style={textStyle}>{this.props.labels[key]}</AppText>
|
<View style={style}>
|
||||||
</View>
|
<AppText style={textStyle}>{labels[key]}</AppText>
|
||||||
</TouchableOpacity>
|
</View>
|
||||||
)
|
</TouchableOpacity>
|
||||||
})}
|
)
|
||||||
</View>
|
})}
|
||||||
)
|
</View>
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectBoxGroup.propTypes = {
|
||||||
|
labels: PropTypes.object.isRequired,
|
||||||
|
onSelect: PropTypes.func.isRequired,
|
||||||
|
optionsState: PropTypes.object.isRequired
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,47 +1,50 @@
|
|||||||
import React, { Component } from 'react'
|
import React from 'react'
|
||||||
import {
|
import PropTypes from 'prop-types'
|
||||||
View,
|
import { View, TouchableOpacity } from 'react-native'
|
||||||
TouchableOpacity,
|
|
||||||
} from 'react-native'
|
|
||||||
import styles from '../../styles'
|
|
||||||
import AppText from '../app-text'
|
import AppText from '../app-text'
|
||||||
|
|
||||||
export default class SelectTabGroup extends Component {
|
import styles from '../../styles'
|
||||||
render() {
|
|
||||||
const { buttons, onSelect } = this.props
|
export default function SelectTabGroup({ active, buttons, onSelect }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.selectTabGroup}>
|
<View style={styles.selectTabGroup}>
|
||||||
{
|
{
|
||||||
buttons.map(({ label, value }, i) => {
|
buttons.map(({ label, value }, i) => {
|
||||||
let firstOrLastStyle
|
let firstOrLastStyle
|
||||||
if (i === buttons.length - 1) {
|
if (i === buttons.length - 1) {
|
||||||
firstOrLastStyle = styles.selectTabLast
|
firstOrLastStyle = styles.selectTabLast
|
||||||
} else if (i === 0) {
|
} else if (i === 0) {
|
||||||
firstOrLastStyle = styles.selectTabFirst
|
firstOrLastStyle = styles.selectTabFirst
|
||||||
}
|
}
|
||||||
let activeStyle
|
let activeStyle
|
||||||
const isActive = value === this.props.active
|
const isActive = value === active
|
||||||
if (isActive) activeStyle = styles.selectTabActive
|
if (isActive) activeStyle = styles.selectTabActive
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => onSelect(isActive ? null : value)}
|
onPress={() => onSelect(isActive ? null : value)}
|
||||||
key={i}
|
key={i}
|
||||||
activeOpacity={1}
|
activeOpacity={1}
|
||||||
>
|
>
|
||||||
<View>
|
<View>
|
||||||
<View style={[
|
<View style={[
|
||||||
styles.selectTab,
|
styles.selectTab,
|
||||||
firstOrLastStyle,
|
firstOrLastStyle,
|
||||||
activeStyle
|
activeStyle
|
||||||
]}>
|
]}>
|
||||||
<AppText style={activeStyle}>{label}</AppText>
|
<AppText style={activeStyle}>{label}</AppText>
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</View>
|
||||||
)
|
</TouchableOpacity>
|
||||||
})
|
)
|
||||||
}
|
})
|
||||||
</View>
|
}
|
||||||
)
|
</View>
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectTabGroup.propTypes = {
|
||||||
|
active: PropTypes.number,
|
||||||
|
buttons: PropTypes.array.isRequired,
|
||||||
|
onSelect: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ class Desire extends Component {
|
|||||||
const symptom = 'desire'
|
const symptom = 'desire'
|
||||||
const { cycleDay } = props
|
const { cycleDay } = props
|
||||||
|
|
||||||
const defaultSymptomData = { value: '' }
|
const defaultSymptomData = { value: null }
|
||||||
|
|
||||||
const symptomData =
|
const symptomData =
|
||||||
cycleDay && cycleDay[symptom] ? cycleDay[symptom] : defaultSymptomData
|
cycleDay && cycleDay[symptom] ? cycleDay[symptom] : defaultSymptomData
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { ScrollView, View, TouchableOpacity } from 'react-native'
|
import { ScrollView, View, TouchableOpacity } from 'react-native'
|
||||||
import Icon from 'react-native-vector-icons/SimpleLineIcons'
|
import Icon from 'react-native-vector-icons/SimpleLineIcons'
|
||||||
import AppText from '../../app-text'
|
import AppText from '../../app-text'
|
||||||
import labels from '../../../i18n/en/symptom-info.js'
|
import labels from '../../../i18n/en/symptom-info.js'
|
||||||
import styles, {iconStyles} from '../../../styles/index'
|
import styles, {iconStyles} from '../../../styles/index'
|
||||||
|
|
||||||
export default function InfoSymptom(props) {
|
export default function InfoSymptom({ close, symptom }) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.infoPopUpWrapper}>
|
<View style={styles.infoPopUpWrapper}>
|
||||||
<View style={styles.dimmed}></View>
|
<View style={styles.dimmed}></View>
|
||||||
<View style={styles.infoPopUp} testID="symptomInfoPopup">
|
<View style={styles.infoPopUp} testID="symptomInfoPopup">
|
||||||
<TouchableOpacity onPress={props.close} style={styles.infoSymptomClose}>
|
<TouchableOpacity onPress={close} style={styles.infoSymptomClose}>
|
||||||
<Icon name='close' {...iconStyles.infoPopUpClose}/>
|
<Icon name='close' {...iconStyles.infoPopUpClose}/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<ScrollView style={styles.infoSymptomText}>
|
<ScrollView style={styles.infoSymptomText}>
|
||||||
<AppText>{labels[props.symptom].text}</AppText>
|
<AppText>{labels[symptom].text}</AppText>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InfoSymptom.propTypes = {
|
||||||
|
close: PropTypes.func.isRequired,
|
||||||
|
symptom: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { TextInput } from 'react-native'
|
import { TextInput } from 'react-native'
|
||||||
|
|
||||||
import SymptomSection from './symptom-section'
|
import SymptomSection from './symptom-section'
|
||||||
@@ -9,6 +10,11 @@ import SymptomView from './symptom-view'
|
|||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
|
|
||||||
class Note extends Component {
|
class Note extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
cycleDay: PropTypes.object.isRequired,
|
||||||
|
date: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
const symptom = 'note'
|
const symptom = 'note'
|
||||||
@@ -41,16 +47,12 @@ class Note extends Component {
|
|||||||
values={this.state}
|
values={this.state}
|
||||||
date={this.props.date}
|
date={this.props.date}
|
||||||
>
|
>
|
||||||
<SymptomSection
|
<SymptomSection explainer={noteExplainer} >
|
||||||
explainer={noteExplainer}
|
|
||||||
>
|
|
||||||
<TextInput
|
<TextInput
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
multiline={true}
|
multiline={true}
|
||||||
placeholder={sharedLabels.enter}
|
placeholder={sharedLabels.enter}
|
||||||
onChangeText={(val) => {
|
onChangeText={(val) => { this.setState({ value: val })}}
|
||||||
this.setState({ value: val })
|
|
||||||
}}
|
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
testID='noteInput'
|
testID='noteInput'
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import AppText, { SymptomSectionHeader } from '../../app-text'
|
import AppText from '../../app-text'
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
|
|
||||||
export default class SymptomSection extends Component {
|
export default class SymptomSection extends Component {
|
||||||
@@ -16,7 +16,7 @@ export default class SymptomSection extends Component {
|
|||||||
return (
|
return (
|
||||||
<View style={[placeHeadingInline, styles.symptomSection]}>
|
<View style={[placeHeadingInline, styles.symptomSection]}>
|
||||||
{ p.header &&
|
{ p.header &&
|
||||||
<SymptomSectionHeader flex={1}>{p.header}</SymptomSectionHeader>
|
<AppText style={styles.symptomViewHeading}>{p.header}</AppText>
|
||||||
}
|
}
|
||||||
<View
|
<View
|
||||||
flexDirection={p.inline ? 'row' : null}
|
flexDirection={p.inline ? 'row' : null}
|
||||||
|
|||||||
@@ -77,15 +77,16 @@ class SymptomView extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { symptom, date, goBack } = this.props
|
const { symptom, date, goBack } = this.props
|
||||||
|
const { shouldShowDelete } = this.state
|
||||||
|
const handleDelete = shouldShowDelete ? this.showConfirmationAlert : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1}}>
|
<View style={{flex: 1}}>
|
||||||
<Header
|
<Header
|
||||||
title={headerTitles[symptom]}
|
title={headerTitles[symptom]}
|
||||||
subtitle={formatDate(date)}
|
subtitle={formatDate(date)}
|
||||||
handleBack={goBack}
|
handleBack={goBack}
|
||||||
handleDelete={
|
handleDelete={handleDelete}
|
||||||
this.state.shouldShowDelete && this.showConfirmationAlert
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<View flex={1}>
|
<View flex={1}>
|
||||||
<ScrollView style={styles.page}>
|
<ScrollView style={styles.page}>
|
||||||
|
|||||||
@@ -102,3 +102,7 @@ const OutOfRangeWarning = ({ temperature }) => {
|
|||||||
|
|
||||||
return <AppText style={styles.hint}>{warningMsg}</AppText>
|
return <AppText style={styles.hint}>{warningMsg}</AppText>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OutOfRangeWarning.propTypes = {
|
||||||
|
temperature: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,21 +5,24 @@ import { View } from 'react-native'
|
|||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
import styles from '../styles'
|
import styles from '../styles'
|
||||||
|
|
||||||
const FramedSegment = ({children, ...props}) => {
|
const FramedSegment = ({ children, last, style, title }) => {
|
||||||
const style = [styles.framedSegment, props.style]
|
const viewStyle = [styles.framedSegment, style]
|
||||||
if (props.last) style.push(styles.framedSegmentLast)
|
if (last) viewStyle.push(styles.framedSegmentLast)
|
||||||
return (
|
return (
|
||||||
<View style={[style]}>
|
<View style={[viewStyle]}>
|
||||||
{
|
{title && <AppText style={styles.framedSegmentTitle}>{title}</AppText>}
|
||||||
props.title
|
|
||||||
&& <AppText style={styles.framedSegmentTitle}>{props.title}</AppText>
|
|
||||||
}
|
|
||||||
{children}
|
{children}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
FramedSegment.propTypes = {
|
FramedSegment.propTypes = {
|
||||||
|
children: PropTypes.oneOfType([
|
||||||
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
PropTypes.node
|
||||||
|
]),
|
||||||
|
last: PropTypes.bool,
|
||||||
|
style: PropTypes.object,
|
||||||
title: PropTypes.string
|
title: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ export default function Header({
|
|||||||
|
|
||||||
Header.propTypes = {
|
Header.propTypes = {
|
||||||
handleBack: PropTypes.func,
|
handleBack: PropTypes.func,
|
||||||
|
handleDelete: PropTypes.func,
|
||||||
handleNext: PropTypes.func,
|
handleNext: PropTypes.func,
|
||||||
title: PropTypes.string,
|
|
||||||
subtitle: PropTypes.string,
|
subtitle: PropTypes.string,
|
||||||
|
title: PropTypes.string.isRequired
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { ScrollView, View, BackHandler } from 'react-native'
|
import { ScrollView, View, BackHandler } from 'react-native'
|
||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
import { shared } from '../i18n/en/labels'
|
import { shared } from '../i18n/en/labels'
|
||||||
@@ -36,4 +37,8 @@ export default function License({setLicense}) {
|
|||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
License.propTypes = {
|
||||||
|
setLicense: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
import Hyperlink from 'react-native-hyperlink'
|
||||||
import styles from '../styles'
|
import styles from '../styles'
|
||||||
import links from '../i18n/en/links'
|
import links from '../i18n/en/links'
|
||||||
@@ -15,6 +16,13 @@ export default function Link(props) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Link.propTypes = {
|
||||||
|
children: PropTypes.oneOfType([
|
||||||
|
PropTypes.arrayOf(PropTypes.node),
|
||||||
|
PropTypes.node
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
function replaceUrlWithText(url) {
|
function replaceUrlWithText(url) {
|
||||||
const link = Object.values(links).find(l => l.url === url)
|
const link = Object.values(links).find(l => l.url === url)
|
||||||
return (link && link.text) || url
|
return (link && link.text) || url
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { Text, TouchableOpacity } from 'react-native'
|
import { Text, TouchableOpacity } from 'react-native'
|
||||||
|
|
||||||
import styles, { iconStyles, secondaryColor } from '../../styles'
|
import styles, { iconStyles, secondaryColor } from '../../styles'
|
||||||
@@ -11,13 +12,11 @@ const menuTitlesLowerCase = Object.keys(menuTitles).reduce((acc, curr) => {
|
|||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
const MenuItem = ({ icon, label, active, onPress }) => {
|
export default function MenuItem({ active, icon, label, onPress }) {
|
||||||
const styleActive = active ? { color: secondaryColor } : null
|
const styleActive = active ? { color: secondaryColor } : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity style={styles.menuItem} onPress={onPress} >
|
||||||
style={styles.menuItem}
|
|
||||||
onPress={onPress}
|
|
||||||
>
|
|
||||||
<Icon name={icon} {...iconStyles.menuIcon} {...styleActive} />
|
<Icon name={icon} {...iconStyles.menuIcon} {...styleActive} />
|
||||||
<Text
|
<Text
|
||||||
testID={active ? 'activeMenuItem' : `menuItem${label}`}
|
testID={active ? 'activeMenuItem' : `menuItem${label}`}
|
||||||
@@ -29,4 +28,9 @@ const MenuItem = ({ icon, label, active, onPress }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MenuItem
|
MenuItem.propTypes = {
|
||||||
|
active: PropTypes.bool,
|
||||||
|
icon: PropTypes.string.isRequired,
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
|
onPress: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { View, TextInput, TouchableOpacity, Alert } from 'react-native'
|
import { View, TextInput, TouchableOpacity, Alert } from 'react-native'
|
||||||
import nodejs from 'nodejs-mobile-react-native'
|
import nodejs from 'nodejs-mobile-react-native'
|
||||||
import { saveEncryptionFlag } from '../local-storage'
|
import { saveEncryptionFlag } from '../local-storage'
|
||||||
@@ -9,6 +10,10 @@ import { passwordPrompt as labels, shared, menuTitles } from '../i18n/en/labels'
|
|||||||
import { requestHash, deleteDbAndOpenNew, openDb } from '../db'
|
import { requestHash, deleteDbAndOpenNew, openDb } from '../db'
|
||||||
|
|
||||||
export default class PasswordPrompt extends Component {
|
export default class PasswordPrompt extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
enableShowApp: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { TouchableOpacity, ScrollView } from 'react-native'
|
import { TouchableOpacity, ScrollView } from 'react-native'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ const menu = [
|
|||||||
{title: labels.license, component: 'License'}
|
{title: labels.license, component: 'License'}
|
||||||
]
|
]
|
||||||
|
|
||||||
const SettingsMenu = (props) => {
|
const SettingsMenu = ({ navigate }) => {
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
{ menu.map(menuItem)}
|
{ menu.map(menuItem)}
|
||||||
@@ -33,7 +34,7 @@ const SettingsMenu = (props) => {
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.framedSegment}
|
style={styles.framedSegment}
|
||||||
key={item.title}
|
key={item.title}
|
||||||
onPress={() => props.navigate(item.component)}
|
onPress={() => navigate(item.component)}
|
||||||
>
|
>
|
||||||
<AppText>{item.title.toLowerCase()}</AppText>
|
<AppText>{item.title.toLowerCase()}</AppText>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -41,6 +42,10 @@ const SettingsMenu = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsMenu.propTypes = {
|
||||||
|
navigate: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => {
|
const mapDispatchToProps = (dispatch) => {
|
||||||
return({
|
return({
|
||||||
navigate: (page) => dispatch(navigate(page)),
|
navigate: (page) => dispatch(navigate(page)),
|
||||||
|
|||||||
@@ -28,8 +28,11 @@ const SettingsButton = ({ children, style, secondary, ...props }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SettingsButton.propTypes = {
|
SettingsButton.propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
disabled: PropTypes.bool,
|
||||||
onPress: PropTypes.func.isRequired,
|
onPress: PropTypes.func.isRequired,
|
||||||
disabled: PropTypes.bool
|
secondary: PropTypes.bool,
|
||||||
|
style: PropTypes.object
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SettingsButton
|
export default SettingsButton
|
||||||
+2
-1
@@ -157,7 +157,8 @@ export default StyleSheet.create({
|
|||||||
},
|
},
|
||||||
symptomViewHeading: {
|
symptomViewHeading: {
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontFamily: textFontBold
|
fontFamily: textFontBold,
|
||||||
|
flex: 1
|
||||||
},
|
},
|
||||||
symptomSection: {
|
symptomSection: {
|
||||||
marginBottom: 10
|
marginBottom: 10
|
||||||
|
|||||||
Reference in New Issue
Block a user