Chore/Retire hyperlink library

This commit is contained in:
Sofiya Tepikin
2022-09-19 09:25:16 +00:00
parent 0597540b88
commit f957553026
9 changed files with 52 additions and 90 deletions
+28
View File
@@ -0,0 +1,28 @@
import React from 'react'
import PropTypes from 'prop-types'
import { StyleSheet, Text, Linking } from 'react-native'
import { Colors, Typography } from '../../styles'
const AppLink = ({ children, url, ...props }) => {
return (
<Text style={styles.link} {...props} onPress={() => Linking.openURL(url)}>
{children}
</Text>
)
}
AppLink.propTypes = {
children: PropTypes.node,
url: PropTypes.string,
}
const styles = StyleSheet.create({
link: {
...Typography.mainText,
color: Colors.purple,
textDecorationLine: 'underline',
},
})
export default AppLink
+4 -10
View File
@@ -2,24 +2,18 @@ import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { StyleSheet, Text } from 'react-native' import { StyleSheet, Text } from 'react-native'
import Link from './link'
import { Colors, Typography } from '../../styles' import { Colors, Typography } from '../../styles'
const AppText = ({ children, linkStyle, style, ...props }) => { const AppText = ({ children, style, ...props }) => {
// we parse for links in case the text contains any
return ( return (
<Link style={linkStyle}> <Text style={[styles.text, style]} {...props}>
<Text style={[styles.text, style]} {...props}> {children}
{children} </Text>
</Text>
</Link>
) )
} }
AppText.propTypes = { AppText.propTypes = {
children: PropTypes.node, children: PropTypes.node,
linkStyle: PropTypes.object,
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]), style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
} }
-40
View File
@@ -1,40 +0,0 @@
import React from 'react'
import PropTypes from 'prop-types'
import Hyperlink from 'react-native-hyperlink'
import { StyleSheet } from 'react-native'
import { Colors, Typography } from '../../styles'
import links from '../../i18n/en/links'
const Link = ({ children, style }) => {
return (
<Hyperlink
linkStyle={[styles.link, style]}
linkText={replaceUrlWithText}
linkDefault
>
{children}
</Hyperlink>
)
}
Link.propTypes = {
children: PropTypes.node,
style: PropTypes.object,
}
const styles = StyleSheet.create({
link: {
color: Colors.purple,
textDecorationLine: 'underline',
...Typography.mainText,
},
})
function replaceUrlWithText(url) {
const link = Object.values(links).find((l) => l.url === url)
return (link && link.text) || url
}
export default Link
@@ -3,6 +3,7 @@ import { Platform, Linking } from 'react-native'
import AppPage from '../common/app-page' import AppPage from '../common/app-page'
import AppText from '../common/app-text' import AppText from '../common/app-text'
import AppLink from '../common/AppLink'
import Segment from '../common/segment' import Segment from '../common/segment'
import Button from '../common/button' import Button from '../common/button'
import ButtonRow from '../common/button-row' import ButtonRow from '../common/button-row'
@@ -35,13 +36,15 @@ const AboutSection = () => {
</Segment> </Segment>
<Segment title={t('credits.title')}> <Segment title={t('credits.title')}>
<AppText> <AppText>
{t('credits.text', { {t('credits.text')}{' '}
smashicons: links.smashicons.url, <AppLink url={links.flaticon.url}>flaticon</AppLink>.{' '}
pause08: links.pause08.url, </AppText>
kazachek: links.kazachek.url, <AppText>
freepik: links.freepik.url, {t('credits.madeBy')}{' '}
flaticon: links.flaticon.url, <AppLink url={links.smashicons.url}>smashicons</AppLink>,{' '}
})} <AppLink url={links.pause08.url}>pause08</AppLink>,{' '}
<AppLink url={links.kazachek.url}>kazachek</AppLink>,{' '}
<AppLink url={links.freepik.url}>freepik</AppLink>.
</AppText> </AppText>
</Segment> </Segment>
<Segment title={t('donate.title')}> <Segment title={t('donate.title')}>
+6 -4
View File
@@ -4,16 +4,18 @@ import { useTranslation } from 'react-i18next'
import AppPage from '../common/app-page' import AppPage from '../common/app-page'
import AppText from '../common/app-text' import AppText from '../common/app-text'
import AppLink from '../common/AppLink'
import Segment from '../common/segment' import Segment from '../common/segment'
const License = ({ children }) => { const License = ({ children }) => {
const { t } = useTranslation() const { t } = useTranslation(null, { keyPrefix: 'settings.license' })
const currentYear = new Date().getFullYear() const currentYear = new Date().getFullYear()
const link = 'https://www.gnu.org/licenses/gpl-3.0.html'
return ( return (
<AppPage title={t('settings.license.title')}> <AppPage title={t('title')}>
<Segment last> <Segment last>
<AppText>{t('settings.license.text', { currentYear })}</AppText> <AppText>{t('text', { currentYear })}</AppText>
<AppLink url={link}>{link}</AppLink>
{children} {children}
</Segment> </Segment>
</AppPage> </AppPage>
+1 -1
View File
@@ -2,7 +2,7 @@ import Reminders from './reminders/reminders'
import NfpSettings from './nfp-settings' import NfpSettings from './nfp-settings'
import DataManagement from './data-management' import DataManagement from './data-management'
import Password from './password' import Password from './password'
import About from './about' import About from './About'
import License from './License' import License from './License'
import PrivacyPolicy from './privacy-policy' import PrivacyPolicy from './privacy-policy'
+3 -2
View File
@@ -17,7 +17,8 @@
"about": { "about": {
"credits": { "credits": {
"title": "Credits", "title": "Credits",
"text": "We love the drip. team. Thanks and lots of <3 to all of our condriputors. Thanks to Paula Härtel for the symptom tracking icons. All the other icons are made by {{smashicons}}, {{pause08}}, {{kazachek}} & {{freepik}} from {{flaticon}}." "text": "We love the drip. team. Thanks and lots of <3 to all of our condriputors. Thanks to Paula Härtel for the symptom tracking icons. All the other icons from:",
"madeBy": "Made by:"
}, },
"donate": { "donate": {
"button": "Donate here", "button": "Donate here",
@@ -38,7 +39,7 @@
}, },
"license": { "license": {
"title": "drip. an open-source cycle tracking app", "title": "drip. an open-source cycle tracking app",
"text": "Copyright (C) {{currentYear}} Heart of Code e.V.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details: https://www.gnu.org/licenses/gpl-3.0.html." "text": "Copyright (C) {{currentYear}} Heart of Code e.V.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details:"
}, },
"privacyPolicy": { "privacyPolicy": {
"title": "Privacy Policy", "title": "Privacy Policy",
-1
View File
@@ -48,7 +48,6 @@
"react-native-calendars": "^1.1287.0", "react-native-calendars": "^1.1287.0",
"react-native-document-picker": "^8.1.1", "react-native-document-picker": "^8.1.1",
"react-native-fs": "^2.20.0", "react-native-fs": "^2.20.0",
"react-native-hyperlink": "0.0.19",
"react-native-modal-datetime-picker": "14.0.0", "react-native-modal-datetime-picker": "14.0.0",
"react-native-push-notification": "3.2.1", "react-native-push-notification": "3.2.1",
"react-native-share": "^7.9.0", "react-native-share": "^7.9.0",
-25
View File
@@ -5429,13 +5429,6 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632"
integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
linkify-it@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf"
integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==
dependencies:
uc.micro "^1.0.1"
locate-path@^3.0.0: locate-path@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
@@ -5580,11 +5573,6 @@ mdast-util-compact@^1.0.0:
dependencies: dependencies:
unist-util-visit "^1.1.0" unist-util-visit "^1.1.0"
mdurl@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==
memoize-one@^5.2.1: memoize-one@^5.2.1:
version "5.2.1" version "5.2.1"
resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.2.1.tgz#8337aa3c4335581839ec01c3d594090cebe8f00e" resolved "https://registry.yarnpkg.com/memoize-one/-/memoize-one-5.2.1.tgz#8337aa3c4335581839ec01c3d594090cebe8f00e"
@@ -6903,14 +6891,6 @@ react-native-fs@^2.20.0:
base-64 "^0.1.0" base-64 "^0.1.0"
utf8 "^3.0.0" utf8 "^3.0.0"
react-native-hyperlink@0.0.19:
version "0.0.19"
resolved "https://registry.yarnpkg.com/react-native-hyperlink/-/react-native-hyperlink-0.0.19.tgz#ca375cde1d244bb94c551736852ee0d688c8bb1f"
integrity sha512-x4wuRGDMnnpWcRr5MCK1D2UcEuzD9IHK8lfjEhO/+QqXNaX31HdeD3ss3BXXZgHxpRYtLbTB0TuFcl1HHANp3w==
dependencies:
linkify-it "^2.2.0"
mdurl "^1.0.0"
react-native-modal-datetime-picker@14.0.0: react-native-modal-datetime-picker@14.0.0:
version "14.0.0" version "14.0.0"
resolved "https://registry.yarnpkg.com/react-native-modal-datetime-picker/-/react-native-modal-datetime-picker-14.0.0.tgz#ca2c81a275ee3a23d9ad02113e76ed243c90781e" resolved "https://registry.yarnpkg.com/react-native-modal-datetime-picker/-/react-native-modal-datetime-picker-14.0.0.tgz#ca2c81a275ee3a23d9ad02113e76ed243c90781e"
@@ -8280,11 +8260,6 @@ ua-parser-js@^0.7.30:
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6"
integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ== integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ==
uc.micro@^1.0.1:
version "1.0.6"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
uglify-es@^3.1.9: uglify-es@^3.1.9:
version "3.3.9" version "3.3.9"
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677" resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"