From 0878654e8291bbcbd0e5f5e70bde3979c49f20bb Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Sat, 2 Feb 2019 11:55:03 +0100 Subject: [PATCH] Extract link component and parse all app text for links --- components/app-text.js | 16 ++++++++++------ components/helpers/replace-url-with-text.js | 6 ------ components/home.js | 10 +++------- components/license.js | 8 ++------ components/link.js | 21 +++++++++++++++++++++ components/settings/about.js | 11 ++--------- components/settings/license.js | 8 ++------ components/settings/nfp-settings/index.js | 6 +----- 8 files changed, 41 insertions(+), 45 deletions(-) delete mode 100644 components/helpers/replace-url-with-text.js create mode 100644 components/link.js diff --git a/components/app-text.js b/components/app-text.js index 8311d39..2f1f826 100644 --- a/components/app-text.js +++ b/components/app-text.js @@ -1,15 +1,19 @@ import React from 'react' import { Text } from 'react-native' import styles from "../styles" +import Link from './link' export default function AppText(props) { + // we parse for links in case the text contains any return ( - - {props.children} - + + + {props.children} + + ) } diff --git a/components/helpers/replace-url-with-text.js b/components/helpers/replace-url-with-text.js deleted file mode 100644 index 5b98cd0..0000000 --- a/components/helpers/replace-url-with-text.js +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/components/home.js b/components/home.js index f4ec660..e9eb0f4 100644 --- a/components/home.js +++ b/components/home.js @@ -2,7 +2,6 @@ import React, { Component } from 'react' import { ScrollView, View, TouchableHighlight, Dimensions } from 'react-native' import { LocalDate, ChronoUnit } from 'js-joda' import Icon from 'react-native-vector-icons/Entypo' -import Hyperlink from 'react-native-hyperlink' import { secondaryColor, cycleDayColor, periodColor } from '../styles' import { home as labels, @@ -12,7 +11,6 @@ import { import links from '../i18n/en/links' import cycleModule from '../lib/cycle' import { getFertilityStatusForDay } from '../lib/sympto-adapter' -import replace from './helpers/replace-url-with-text' import styles from '../styles' import AppText from './app-text' import DripHomeIcon from '../assets/drip-home-icons' @@ -158,11 +156,9 @@ export default class Home extends Component { } { isShowingMore && - - - { `${statusText} ${links.moreAboutNfp.url}` } - - + + { `${statusText} ${links.moreAboutNfp.url}` } + } diff --git a/components/license.js b/components/license.js index 051e4ec..027e34b 100644 --- a/components/license.js +++ b/components/license.js @@ -1,22 +1,18 @@ import React from 'react' import { ScrollView, View, BackHandler } from 'react-native' -import Hyperlink from 'react-native-hyperlink' import AppText from './app-text' import { shared } from '../i18n/en/labels' import settingsLabels from '../i18n/en/settings' import styles,{secondaryColor} from '../styles' import Button from './button' import { saveLicenseFlag } from '../local-storage' -import replace from './helpers/replace-url-with-text' const labels = settingsLabels.license export default function License({setLicense}) { return ( - - {labels.title} - {labels.text} - + {labels.title} + {labels.text}