Extract link component and parse all app text for links
This commit is contained in:
+10
-6
@@ -1,15 +1,19 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Text } from 'react-native'
|
import { Text } from 'react-native'
|
||||||
import styles from "../styles"
|
import styles from "../styles"
|
||||||
|
import Link from './link'
|
||||||
|
|
||||||
export default function AppText(props) {
|
export default function AppText(props) {
|
||||||
|
// we parse for links in case the text contains any
|
||||||
return (
|
return (
|
||||||
<Text
|
<Link>
|
||||||
style={[styles.appText, props.style]}
|
<Text
|
||||||
onPress={props.onPress}
|
style={[styles.appText, props.style]}
|
||||||
>
|
onPress={props.onPress}
|
||||||
{props.children}
|
>
|
||||||
</Text>
|
{props.children}
|
||||||
|
</Text>
|
||||||
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
import links from '../../i18n/en/links'
|
|
||||||
|
|
||||||
export default function(url) {
|
|
||||||
const link = Object.values(links).find(link => link.url === url)
|
|
||||||
return link ? link.text : url
|
|
||||||
}
|
|
||||||
+3
-7
@@ -2,7 +2,6 @@ import React, { Component } from 'react'
|
|||||||
import { ScrollView, View, TouchableHighlight, Dimensions } from 'react-native'
|
import { ScrollView, View, TouchableHighlight, Dimensions } from 'react-native'
|
||||||
import { LocalDate, ChronoUnit } from 'js-joda'
|
import { LocalDate, ChronoUnit } from 'js-joda'
|
||||||
import Icon from 'react-native-vector-icons/Entypo'
|
import Icon from 'react-native-vector-icons/Entypo'
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
|
||||||
import { secondaryColor, cycleDayColor, periodColor } from '../styles'
|
import { secondaryColor, cycleDayColor, periodColor } from '../styles'
|
||||||
import {
|
import {
|
||||||
home as labels,
|
home as labels,
|
||||||
@@ -12,7 +11,6 @@ import {
|
|||||||
import links from '../i18n/en/links'
|
import links from '../i18n/en/links'
|
||||||
import cycleModule from '../lib/cycle'
|
import cycleModule from '../lib/cycle'
|
||||||
import { getFertilityStatusForDay } from '../lib/sympto-adapter'
|
import { getFertilityStatusForDay } from '../lib/sympto-adapter'
|
||||||
import replace from './helpers/replace-url-with-text'
|
|
||||||
import styles from '../styles'
|
import styles from '../styles'
|
||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
import DripHomeIcon from '../assets/drip-home-icons'
|
import DripHomeIcon from '../assets/drip-home-icons'
|
||||||
@@ -158,11 +156,9 @@ export default class Home extends Component {
|
|||||||
}
|
}
|
||||||
{ isShowingMore &&
|
{ isShowingMore &&
|
||||||
<View>
|
<View>
|
||||||
<Hyperlink linkStyle={styles.link} linkText={replace} linkDefault>
|
<AppText styles={styles.paragraph}>
|
||||||
<AppText styles={styles.paragraph}>
|
{ `${statusText} ${links.moreAboutNfp.url}` }
|
||||||
{ `${statusText} ${links.moreAboutNfp.url}` }
|
</AppText>
|
||||||
</AppText>
|
|
||||||
</Hyperlink>
|
|
||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
</HomeElement>
|
</HomeElement>
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { ScrollView, View, BackHandler } from 'react-native'
|
import { ScrollView, View, BackHandler } from 'react-native'
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
|
||||||
import AppText from './app-text'
|
import AppText from './app-text'
|
||||||
import { shared } from '../i18n/en/labels'
|
import { shared } from '../i18n/en/labels'
|
||||||
import settingsLabels from '../i18n/en/settings'
|
import settingsLabels from '../i18n/en/settings'
|
||||||
import styles,{secondaryColor} from '../styles'
|
import styles,{secondaryColor} from '../styles'
|
||||||
import Button from './button'
|
import Button from './button'
|
||||||
import { saveLicenseFlag } from '../local-storage'
|
import { saveLicenseFlag } from '../local-storage'
|
||||||
import replace from './helpers/replace-url-with-text'
|
|
||||||
|
|
||||||
const labels = settingsLabels.license
|
const labels = settingsLabels.license
|
||||||
export default function License({setLicense}) {
|
export default function License({setLicense}) {
|
||||||
return (
|
return (
|
||||||
<ScrollView style={styles.licensePage}>
|
<ScrollView style={styles.licensePage}>
|
||||||
<Hyperlink linkStyle={styles.link} linkText={replace} linkDefault>
|
<AppText style={styles.settingsSegmentTitle}>{labels.title}</AppText>
|
||||||
<AppText style={styles.settingsSegmentTitle}>{labels.title}</AppText>
|
<AppText>{labels.text}</AppText>
|
||||||
<AppText>{labels.text}</AppText>
|
|
||||||
</Hyperlink>
|
|
||||||
<View style={styles.licenseButtons}>
|
<View style={styles.licenseButtons}>
|
||||||
<Button
|
<Button
|
||||||
style={styles.licenseButton}
|
style={styles.licenseButton}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import Hyperlink from 'react-native-hyperlink'
|
||||||
|
import styles from '../styles'
|
||||||
|
import links from '../i18n/en/links'
|
||||||
|
|
||||||
|
export default function Link(props) {
|
||||||
|
return (
|
||||||
|
<Hyperlink
|
||||||
|
linkStyle={styles.link}
|
||||||
|
linkText={replaceUrlWithText}
|
||||||
|
linkDefault
|
||||||
|
>
|
||||||
|
{props.children}
|
||||||
|
</Hyperlink>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceUrlWithText(url) {
|
||||||
|
const link = Object.values(links).find(l => l.url === url)
|
||||||
|
return (link && link.text) || url
|
||||||
|
}
|
||||||
@@ -1,21 +1,16 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { ScrollView } from 'react-native'
|
import { ScrollView } from 'react-native'
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
|
||||||
import AppText from '../app-text'
|
import AppText from '../app-text'
|
||||||
import SettingsSegment from './shared/settings-segment'
|
import SettingsSegment from './shared/settings-segment'
|
||||||
import styles from '../../styles/index'
|
|
||||||
import labels from '../../i18n/en/settings'
|
import labels from '../../i18n/en/settings'
|
||||||
import links from '../../i18n/en/links'
|
import links from '../../i18n/en/links'
|
||||||
import replace from '../helpers/replace-url-with-text'
|
|
||||||
|
|
||||||
export default class AboutSection extends Component {
|
export default class AboutSection extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<SettingsSegment title={labels.aboutSection.title}>
|
<SettingsSegment title={labels.aboutSection.title}>
|
||||||
<Hyperlink linkStyle={styles.link} linkText={replace} linkDefault>
|
<AppText>{labels.aboutSection.text}</AppText>
|
||||||
<AppText>{labels.aboutSection.text}</AppText>
|
|
||||||
</Hyperlink>
|
|
||||||
</SettingsSegment>
|
</SettingsSegment>
|
||||||
<SettingsSegment title={labels.philosophy.title}>
|
<SettingsSegment title={labels.philosophy.title}>
|
||||||
<AppText>{labels.philosophy.text}</AppText>
|
<AppText>{labels.philosophy.text}</AppText>
|
||||||
@@ -24,9 +19,7 @@ export default class AboutSection extends Component {
|
|||||||
<AppText>{labels.credits.note}</AppText>
|
<AppText>{labels.credits.note}</AppText>
|
||||||
</SettingsSegment>
|
</SettingsSegment>
|
||||||
<SettingsSegment title={labels.website.title}>
|
<SettingsSegment title={labels.website.title}>
|
||||||
<Hyperlink linkStyle={styles.link} linkDefault>
|
<AppText>{links.website.url}</AppText>
|
||||||
<AppText>{links.website.url}</AppText>
|
|
||||||
</Hyperlink>
|
|
||||||
</SettingsSegment>
|
</SettingsSegment>
|
||||||
<SettingsSegment title={labels.version.title} last>
|
<SettingsSegment title={labels.version.title} last>
|
||||||
<AppText>{require('../../package.json').version}</AppText>
|
<AppText>{require('../../package.json').version}</AppText>
|
||||||
|
|||||||
@@ -1,20 +1,16 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View, ScrollView } from 'react-native'
|
import { View, ScrollView } from 'react-native'
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
|
||||||
import AppText from '../app-text'
|
import AppText from '../app-text'
|
||||||
import styles from '../../styles/index'
|
import styles from '../../styles/index'
|
||||||
import labels from '../../i18n/en/settings'
|
import labels from '../../i18n/en/settings'
|
||||||
import replace from '../helpers/replace-url-with-text'
|
|
||||||
|
|
||||||
export default class License extends Component {
|
export default class License extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<View style={styles.settingsSegment}>
|
<View style={styles.settingsSegment}>
|
||||||
<Hyperlink linkStyle={styles.link} linkText={replace} linkDefault>
|
<AppText style={styles.settingsSegmentTitle}>{`${labels.license.title} `}</AppText>
|
||||||
<AppText style={styles.settingsSegmentTitle}>{`${labels.license.title} `}</AppText>
|
<AppText>{`${labels.license.text} `}</AppText>
|
||||||
<AppText>{`${labels.license.text} `}</AppText>
|
|
||||||
</Hyperlink>
|
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React, { Component } from 'react'
|
|||||||
import {
|
import {
|
||||||
ScrollView, View
|
ScrollView, View
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
|
||||||
import styles, { iconStyles } from '../../../styles'
|
import styles, { iconStyles } from '../../../styles'
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
import AppText from '../../app-text'
|
import AppText from '../../app-text'
|
||||||
@@ -10,7 +9,6 @@ import SettingsSegment from '../shared/settings-segment'
|
|||||||
import TempSlider from './temp-slider'
|
import TempSlider from './temp-slider'
|
||||||
import UseCervixSetting from './use-cervix'
|
import UseCervixSetting from './use-cervix'
|
||||||
import Icon from 'react-native-vector-icons/Entypo'
|
import Icon from 'react-native-vector-icons/Entypo'
|
||||||
import replaceUrlWithText from '../../helpers/replace-url-with-text'
|
|
||||||
|
|
||||||
export default class Settings extends Component {
|
export default class Settings extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -33,9 +31,7 @@ export default class Settings extends Component {
|
|||||||
<Icon name="info-with-circle" style={iconStyles.infoInHeading}/>
|
<Icon name="info-with-circle" style={iconStyles.infoInHeading}/>
|
||||||
<AppText style={styles.settingsSegmentTitle}>{`${labels.preOvu.title} `}</AppText>
|
<AppText style={styles.settingsSegmentTitle}>{`${labels.preOvu.title} `}</AppText>
|
||||||
</View>
|
</View>
|
||||||
<Hyperlink linkStyle={styles.link} linkText={replaceUrlWithText} linkDefault>
|
<AppText>{labels.preOvu.note}</AppText>
|
||||||
<AppText>{labels.preOvu.note}</AppText>
|
|
||||||
</Hyperlink>
|
|
||||||
</SettingsSegment>
|
</SettingsSegment>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user