mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-02-24 02:36:19 -05:00
1ebf4b951de6915e153def695a8277908d664990
* Add exception handler library; fix computer vision results * Create loggedIn hook to check whether user is logged in before cv suggestions or upload * Create user profile card on MyObs * Update packages * Add text for camera permissions denied * Remove log * Upgrade react native on iOS * Add vendor file for ruby gems to gitignore * Remove vendor file from github * Update react native for android * Add plural example to fluent; create TranslatedText component to render translations * Add translations and update camera roll screens * Small changes to uploader flow; add date/time picker * Separate explore into landing screen and view screen * Show total number of observations, explore * Clean up styling and add details for grid view; banner for total observations in explore * Add checkboxes for status, quality grade, media filters * Add a lot of explore filters * Show months in Explore filters * Create About screen; sync package.json version using react native version * Get explore filters in mostly working condition * Observations download after login; clear login screen after nav; closes #62 and #60 * Allow separating photos if at least 1 combined photo obs is selected; closes #68 * Fix auth tests; add user id * Pop text input above keyboard to address #66 * Lint cleanup * Create bottom modal for user tapping back button on ObsEdit * Check permissions on android only, camera * Keep trying to get android camera working * Change version number to 0.1.0
iNaturalistReactNative
Install packages and pods
- Run
npm install - Run
npx pod-install iosorcd ios && pod installfrom the root directory - Make sure to place the
.envfile in the root folder, which is not part of the code repo (contains secrets, such as OAuth client ID).
Set up pre-commit hooks
- We're using Husky to automatically run
eslintbefore each commit. Runnpm run prepareto install Husky locally.
Run build
- Run
npm start -- --reset-cache(npm startworks too, but resetting the cache each time makes for a lot less build issues) - Run
npm run iosornpm run android
Tests
# Run all tests
npm test
# Run test paths matching a pattern
./node_modules/.bin/jest MyObs
# Run individual tests matching a pattern
./node_modules/.bin/jest -t accessibility
We currently have two kinds of tests
tests/integration: Tests the test the integration of multiple modules, e.g. a list of observation that makes requests to a mocked API, persists the response data in local storage, retrieves the data from local storage and renders components.tests/unit: Tests that only test specific modules, like a single component, or a hook.
We're using Jest and React Native Testing Library for most of our tests, factoria and faker.js to generate test data for use with mocks. Local* model factories represent locally persisted data, while Remote* factories represent that kinds of records we get from an API or external package.
Running with Staging Environment
- Override
API_URLto a staging API domain - either using a local.envfile, or overriding the environment variable when callingnpm start- e.g.API_URL=http://example.com npm start -- --reset-cache
Translations
Adding New Text
- Add new strings in English to
src/i18n/strings.ftlusing Fluent syntax, e.g.Try to match case and strike a balance between specificity and reusability when choosing a key. Please add context comments to help translators understand how the text is used, avoid variables whenever possible, and try to keep# Header for a paragraph describing projects ABOUT-PROJECTS = ABOUT # Text describing what projects are projects-description = Projects are really great, probably iNat's best feature.strings.ftlalphabetized by key. - Run
node src/i18n/i18ncli.js buildto build the JSON files i18next needs to access text in the app - In a commponent, use the
useTranslationhook to reference your new string, e.g.import { useTranslation } from "react-i18next"; const MyComponent = ( ) => { const { t } = useTranslation(); return ( <View> <Text>{ t( "ABOUT-PROJECTS" ) }</Text> <Text>{ t( "projects-description" ) }</Text> </View> ); };
Translating Text
We manage translations through Crowdin. Actually updating the translation files should be largely automated, but this is what it looks like to do it manually (you must have the Crowdin CLI installed and have an access token associated with a Crowdin user that can post files to the specified project):
# Upload new strings. Source and destination paths are specified in crowdin.yml
crowdin upload --token YOUR_ACCESS_TOKEN --project-id YOUR_PROJECT_ID
# Download new translations and build for use in the app
crowdin download --token YOUR_ACCESS_TOKEN --project-id YOUR_PROJECT_ID
node src/i18n/i18ncli.js build
git add src/i18n/l10n/*
git commit -a -m "Updated translations"
Troubleshooting
- Run
react-native clean-project. This will give you options to clean caches, clean builds, reinstall pods, and reinstall node_modules. Using this eliminates a lot of hard-to-diagnose build issues.
Description
Languages
Fluent
63.6%
JavaScript
18.5%
TypeScript
17.4%
Ruby
0.4%