From 4877c1a36940bf390cd119b9399d5a39bbbc7134 Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Sun, 25 Feb 2024 22:33:04 +0100 Subject: [PATCH] Add Support screen (#1171) * Update strings.ftl * Add drawer item for Support * Update strings.ftl * Change key * UI for Support screen * Link out to websites on button presses * Restyle screen header * Eslint settings to get rid of an error * Use react-native-store-review to ask for review * Not needed use of .tsx in import * Remove comments --- .eslintrc.js | 5 +- .flowconfig | 5 +- ios/Podfile.lock | 6 ++ package-lock.json | 11 ++++ package.json | 1 + src/components/SharedComponents/index.js | 2 +- src/components/Support/Support.js | 72 ++++++++++++++++++++++ src/i18n/l10n/en.ftl | 22 ++++++- src/i18n/l10n/en.ftl.json | 11 +++- src/i18n/strings.ftl | 22 ++++++- src/navigation/BottomTabNavigator/index.js | 32 +++++----- src/navigation/CustomDrawerContent.js | 10 +-- 12 files changed, 170 insertions(+), 29 deletions(-) create mode 100644 src/components/Support/Support.js diff --git a/.eslintrc.js b/.eslintrc.js index b2312641f..3e6268ad8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -130,7 +130,10 @@ module.exports = { ignorePatterns: ["/coverage/*", "/vendor/*"], settings: { "import/resolver": { - "babel-module": { allowExistingDirectories: true } + "babel-module": { allowExistingDirectories: true }, + node: { + extensions: [".js", ".jsx", ".ts", ".tsx"] + } } } }; diff --git a/.flowconfig b/.flowconfig index 3c5e2851f..aac01fcfc 100644 --- a/.flowconfig +++ b/.flowconfig @@ -37,6 +37,8 @@ format.bracket_spacing=false module.file_ext=.js module.file_ext=.json module.file_ext=.ios.js +module.file_ext=.ts +module.file_ext=.tsx munge_underscores=true @@ -53,9 +55,6 @@ suppress_type=$FlowFixMe suppress_type=$FlowFixMeProps suppress_type=$FlowFixMeState -module.file_ext=.ts -module.file_ext=.tsx - [lints] sketchy-null-number=warn sketchy-null-mixed=warn diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ab1d64b9d..c97eace09 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -448,6 +448,8 @@ PODS: - React-RCTImage - RNShareMenu (6.0.0): - React + - RNStoreReview (0.4.3): + - React-Core - RNSVG (13.14.0): - React-Core - RNVectorIcons (9.2.0): @@ -530,6 +532,7 @@ DEPENDENCIES: - RNReanimated (from `../node_modules/react-native-reanimated`) - RNScreens (from `../node_modules/react-native-screens`) - RNShareMenu (from `../node_modules/react-native-share-menu`) + - RNStoreReview (from `../node_modules/react-native-store-review`) - RNSVG (from `../node_modules/react-native-svg`) - RNVectorIcons (from `../node_modules/react-native-vector-icons`) - VisionCamera (from `../node_modules/react-native-vision-camera`) @@ -676,6 +679,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-screens" RNShareMenu: :path: "../node_modules/react-native-share-menu" + RNStoreReview: + :path: "../node_modules/react-native-store-review" RNSVG: :path: "../node_modules/react-native-svg" RNVectorIcons: @@ -757,6 +762,7 @@ SPEC CHECKSUMS: RNReanimated: f186e85d9f28c9383d05ca39e11dd194f59093ec RNScreens: d3675ab2878704de70c9dae57fa5d024802404cc RNShareMenu: cb9dac548c8bf147d06f0bf07296ad51ea9f5fc3 + RNStoreReview: 31dbfd0dac2eea9675f0b84f1dd3261c2110c337 RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396 RNVectorIcons: fcc2f6cb32f5735b586e66d14103a74ce6ad61f8 VisionCamera: 523b49054bee9dace64189ab6631cb41e8b83fe0 diff --git a/package-lock.json b/package-lock.json index e02b2dce9..0c69e4d55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,6 +86,7 @@ "react-native-screens": "^3.21.1", "react-native-sensitive-info": "^6.0.0-alpha.9", "react-native-share-menu": "^6.0.0", + "react-native-store-review": "^0.4.3", "react-native-svg": "^13.14.0", "react-native-svg-transformer": "^1.1.0", "react-native-uuid": "^2.0.1", @@ -23006,6 +23007,11 @@ "resolved": "https://registry.npmjs.org/react-native-share-menu/-/react-native-share-menu-6.0.0.tgz", "integrity": "sha512-KdmRnqjI/B2MigSxGmhbYJ3WMJxKXj+0c47ANcVZ/PTzc2vtz6d1r4KQJgkBImXgNC+vowpuD2UGdPllxadr2A==" }, + "node_modules/react-native-store-review": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/react-native-store-review/-/react-native-store-review-0.4.3.tgz", + "integrity": "sha512-RSQ6vx2j4p41GwTqNv2VV7yold62j5qDbGEBAjFi6gkXMrMpxFMg+82FPjbh6012tqv6Ebzwfqw6S4m4d7sddw==" + }, "node_modules/react-native-svg": { "version": "13.14.0", "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-13.14.0.tgz", @@ -42843,6 +42849,11 @@ "resolved": "https://registry.npmjs.org/react-native-share-menu/-/react-native-share-menu-6.0.0.tgz", "integrity": "sha512-KdmRnqjI/B2MigSxGmhbYJ3WMJxKXj+0c47ANcVZ/PTzc2vtz6d1r4KQJgkBImXgNC+vowpuD2UGdPllxadr2A==" }, + "react-native-store-review": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/react-native-store-review/-/react-native-store-review-0.4.3.tgz", + "integrity": "sha512-RSQ6vx2j4p41GwTqNv2VV7yold62j5qDbGEBAjFi6gkXMrMpxFMg+82FPjbh6012tqv6Ebzwfqw6S4m4d7sddw==" + }, "react-native-svg": { "version": "13.14.0", "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-13.14.0.tgz", diff --git a/package.json b/package.json index e15b4d380..35cf3deaa 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "react-native-screens": "^3.21.1", "react-native-sensitive-info": "^6.0.0-alpha.9", "react-native-share-menu": "^6.0.0", + "react-native-store-review": "^0.4.3", "react-native-svg": "^13.14.0", "react-native-svg-transformer": "^1.1.0", "react-native-uuid": "^2.0.1", diff --git a/src/components/SharedComponents/index.js b/src/components/SharedComponents/index.js index 25de0c9bd..d846d0518 100644 --- a/src/components/SharedComponents/index.js +++ b/src/components/SharedComponents/index.js @@ -1,4 +1,4 @@ -export { default as ActivityAnimation } from "./ActivityAnimation/ActivityAnimation.tsx"; +export { default as ActivityAnimation } from "./ActivityAnimation/ActivityAnimation"; export { default as ActivityCount } from "./ActivityCount/ActivityCount"; export { default as CommentsCount } from "./ActivityCount/CommentsCount"; export { default as IdentificationsCount } from "./ActivityCount/IdentificationsCount"; diff --git a/src/components/Support/Support.js b/src/components/Support/Support.js new file mode 100644 index 000000000..f3db76f7c --- /dev/null +++ b/src/components/Support/Support.js @@ -0,0 +1,72 @@ +// @flow + +import { + Body2, Button, Heading4, ScrollViewWrapper +} from "components/SharedComponents"; +import { View } from "components/styledComponents"; +import { t } from "i18next"; +import type { Node } from "react"; +import React from "react"; +import { Alert, Linking } from "react-native"; +import * as StoreReview from "react-native-store-review"; + +const Support = (): Node => { + const onDonatePress = async ( ) => { + const url = "https://inaturalist.org/donate"; + const supported = await Linking.canOpenURL( url ); + if ( supported ) { + await Linking.openURL( url ); + } else { + Alert.alert( `Don't know how to open this URL: ${url}` ); + } + }; + + const onShopPress = async ( ) => { + const url = "https://inaturalist.threadless.com"; + const supported = await Linking.canOpenURL( url ); + if ( supported ) { + await Linking.openURL( url ); + } else { + Alert.alert( `Don't know how to open this URL: ${url}` ); + } + }; + + const onReviewPress = ( ) => { + StoreReview.requestReview( ); + }; + + return ( + + + {t( "DONATE-TO-INATURALIST" )} + {t( "Your-donation-to-iNaturalist" )} + {t( "iNaturalist-is-a-501" )} +