From f9575530262318e9219cb01086a261993524d09b Mon Sep 17 00:00:00 2001 From: Sofiya Tepikin Date: Mon, 19 Sep 2022 09:25:16 +0000 Subject: [PATCH] Chore/Retire hyperlink library --- components/common/AppLink.js | 28 +++++++++++++++ components/common/app-text.js | 14 +++----- components/common/link.js | 40 ---------------------- components/settings/{about.js => About.js} | 17 +++++---- components/settings/License.js | 10 +++--- components/settings/index.js | 2 +- i18n/en.json | 5 +-- package.json | 1 - yarn.lock | 25 -------------- 9 files changed, 52 insertions(+), 90 deletions(-) create mode 100644 components/common/AppLink.js delete mode 100644 components/common/link.js rename components/settings/{about.js => About.js} (77%) diff --git a/components/common/AppLink.js b/components/common/AppLink.js new file mode 100644 index 0000000..264bc10 --- /dev/null +++ b/components/common/AppLink.js @@ -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 ( + Linking.openURL(url)}> + {children} + + ) +} + +AppLink.propTypes = { + children: PropTypes.node, + url: PropTypes.string, +} + +const styles = StyleSheet.create({ + link: { + ...Typography.mainText, + color: Colors.purple, + textDecorationLine: 'underline', + }, +}) + +export default AppLink diff --git a/components/common/app-text.js b/components/common/app-text.js index 7501f1a..94ce103 100644 --- a/components/common/app-text.js +++ b/components/common/app-text.js @@ -2,24 +2,18 @@ import React from 'react' import PropTypes from 'prop-types' import { StyleSheet, Text } from 'react-native' -import Link from './link' - import { Colors, Typography } from '../../styles' -const AppText = ({ children, linkStyle, style, ...props }) => { - // we parse for links in case the text contains any +const AppText = ({ children, style, ...props }) => { return ( - - - {children} - - + + {children} + ) } AppText.propTypes = { children: PropTypes.node, - linkStyle: PropTypes.object, style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]), } diff --git a/components/common/link.js b/components/common/link.js deleted file mode 100644 index e624c27..0000000 --- a/components/common/link.js +++ /dev/null @@ -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 ( - - {children} - - ) -} - -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 diff --git a/components/settings/about.js b/components/settings/About.js similarity index 77% rename from components/settings/about.js rename to components/settings/About.js index 341f680..1917edc 100644 --- a/components/settings/about.js +++ b/components/settings/About.js @@ -3,6 +3,7 @@ import { Platform, Linking } from 'react-native' import AppPage from '../common/app-page' import AppText from '../common/app-text' +import AppLink from '../common/AppLink' import Segment from '../common/segment' import Button from '../common/button' import ButtonRow from '../common/button-row' @@ -35,13 +36,15 @@ const AboutSection = () => { - {t('credits.text', { - smashicons: links.smashicons.url, - pause08: links.pause08.url, - kazachek: links.kazachek.url, - freepik: links.freepik.url, - flaticon: links.flaticon.url, - })} + {t('credits.text')}{' '} + flaticon.{' '} + + + {t('credits.madeBy')}{' '} + smashicons,{' '} + pause08,{' '} + kazachek,{' '} + freepik. diff --git a/components/settings/License.js b/components/settings/License.js index 69b1fcd..db5a980 100644 --- a/components/settings/License.js +++ b/components/settings/License.js @@ -4,16 +4,18 @@ import { useTranslation } from 'react-i18next' import AppPage from '../common/app-page' import AppText from '../common/app-text' +import AppLink from '../common/AppLink' import Segment from '../common/segment' const License = ({ children }) => { - const { t } = useTranslation() + const { t } = useTranslation(null, { keyPrefix: 'settings.license' }) const currentYear = new Date().getFullYear() - + const link = 'https://www.gnu.org/licenses/gpl-3.0.html' return ( - + - {t('settings.license.text', { currentYear })} + {t('text', { currentYear })} + {link} {children} diff --git a/components/settings/index.js b/components/settings/index.js index cd50c84..2ee7985 100644 --- a/components/settings/index.js +++ b/components/settings/index.js @@ -2,7 +2,7 @@ import Reminders from './reminders/reminders' import NfpSettings from './nfp-settings' import DataManagement from './data-management' import Password from './password' -import About from './about' +import About from './About' import License from './License' import PrivacyPolicy from './privacy-policy' diff --git a/i18n/en.json b/i18n/en.json index 0afe60f..74fbbfa 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -17,7 +17,8 @@ "about": { "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": { "button": "Donate here", @@ -38,7 +39,7 @@ }, "license": { "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": { "title": "Privacy Policy", diff --git a/package.json b/package.json index 85a641d..153be80 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "react-native-calendars": "^1.1287.0", "react-native-document-picker": "^8.1.1", "react-native-fs": "^2.20.0", - "react-native-hyperlink": "0.0.19", "react-native-modal-datetime-picker": "14.0.0", "react-native-push-notification": "3.2.1", "react-native-share": "^7.9.0", diff --git a/yarn.lock b/yarn.lock index f998666..1f4a6f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" 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: version "3.0.0" 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: 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: version "5.2.1" 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" 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: version "14.0.0" 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" 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: version "3.3.9" resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"