Commit Graph

19 Commits

Author SHA1 Message Date
Amanda Bullington
045ce6f789 Improve Jest performance (#1160)
* Use faker import with specific locale

* Add global beforeAll to initiate i18next
2024-02-16 16:17:00 -08:00
Amanda Bullington
d147ac5d54 Explore defaults to viewer's location (#1157)
* Show observations by defaulting to user location

* Remove log

* Create useHeaderCount hook to load user location count before global count

* Header count and location permission fixes

* Remove log

* Fix Explore tests

* Test fixes and add blocked/denied state
2024-02-15 18:28:33 -08:00
Amanda Bullington
d160083177 Redo search in map, Explore (#1151)
* Add tests for redo search button

* Update tiles, observation, and count with map area query params
2024-02-14 13:37:28 -08:00
Amanda Bullington
eb7f9d28e4 Add navigation links to explore views (#1146)
* Add navigation links to species, observer, identifier view items

* Add tests to check for navigation; closes #1054
2024-02-13 16:52:11 -08:00
Johannes Klein
60de855f6b Explore filters (#1067)
* Remove Explore Filters screen

* State for Explore filters modal

* Accept modal state in Header to open modal

* Basic explore filters modal

* Save taxon object to explore state on update

* Update types expected

* Pass state and update function into filters modal

* Receive new props

* Destructure taxon from props

* Restyle header View

* Add main Heading

* Add taxon section

* Restyle modal header

* Add numbers badge component

* TaxonResult add prop for general on press

* Make TaxonResult checkmark optional

* DisplayTaxon can receive children as right-side component

* Refactor ExploreFilters component tree

* Move header out of scroll view

* Update ExploreFilters.js

* Update ExploreFilters.js

* Add icon to display taxon

* Update ExploreFilters.js

* Add basic taxon search screen

* Use taxon result without checkmark, send taxon to Explore screen

* Add string

* Accept taxon on explore screen

* Add a dummy screen for explore location search

* Add type

* Store place in state when received as route param

* Basic explore filters location section

* Add strings

* Move filter modal to separate component, add sort by props

* Add screen for testing purposes

Because atm we can not have two modals open at the same time, I move filters to a separate screen for testing the other modals.

* Add initial filter params and do not pass down undefined ones

* Pass function to update sort by down

* Create SortBySheet.js

* Navigate to test screen instead

* Sort by button text

* Add default filters definition

* Call reset function if filters are not default

* Add prop and function to reset

* Add user search screen

* Move search screens

* Move references

* Replace list with flash list

* Add item separator

* Remove footer

* Return user to Explore

* On press handle for user list item

* Fix wrong imports

* If a user is in prop show user icon and edit button instead

* Refactor display taxon to be inside a Pressable

* Missing import

* Receive user in explore rout params

* Quality grade section header

* Placeholder

* Add TODO

* Calculate number of filters set

* Only send user id to explore screen

* Do send back user object, filter out user_id

* Add project section

* Refactor project list item into standalone component

* Change initial value to undefined

* Add project search screen

* Remove loading state

* Show project in filter modal

* If project is in param set it to state

* Add Checkboxes to filter modal

* Remove comment

* Taxonomic Ranks section UI

* Use props for checkboxes

* Update ExploreContainer.js

* Calculate actual query param

* Is Most Faved possible?

* Actually set sort by query params

* Save hrank and lrank to explore state, prop down

* Update ExploreContainer.js

* Show ranks in button text

* Radio modal to test taxonomic ranks

* Add sticky toolbar

* Update strings.ftl

* Date observed section bottom sheet

* Date observed prop

* Change padding

* Date observed all UI

* Taxonomic ranks section

* Add todo

* Refactor open sheets state

* Update button

* Add exact date picker sections

* Store dates in state

* Update strings.ftl

* Refactor function name

* Refactor constants

* Reset date states on mode change

* Set new months to state on change

* Configuration for showing months checkboxes

* Receive and update months with checkboxes

* Refactor RadioButton sheet to export radio button row

* Add Media section UI

* Add media state to Explore

* Start with Establishment Means section

* Add checkbox texts

* Add states

* Functions to update state

* Add sort by param for most faved

* Spacing for checkboxes

* Wild Status section UI

* Wild status state

* Reviewed UI section

* Reviewed state

* Set current user id as viewer_id for review true to work

* Remove testing code

* Photo licensing UI section

* Photo license state

* Prop down photo license update, use param in search

Forgotten in previous commit

* Unused prop

* Add noStatus state

* Change Establishment Means status to TODO

* Add TODO text

* Console log for testing params

* After rebase from main this was necessary

* Simple switch between two UIs

* Simple explore context

* Lift Provider one up

* Copy over photo license to new provider

* Copy over review filter

* Refactor to use enum

* Copy over wild status, and enum refactors

* Refactor some more state

* Remove unused navigation

* Refactor one state

* Refactor some more state

* Refactor some more state

* Remove testing screen

* Refactor some more state and derived state

* Do send over project as param from Project Details

* Update FilterModal.js

* Rename components

* Remove unused param handling

* Add keys

* Remove substring for key

* lrank and hrank combined counts as one only

* Use the correct constants

* Add key

* Fix issue with button text

* Add View Wrapper for filters section

* UI cosmetics

* Compare current filters state to a snapshot

* Change button level to focus

* Add context action to revert to snapshot

* Confirmation dialog strings

* Add confirmation sheet

* Send current user along to Explore from Home Header

Closes #887

* Date bottom sheets texts

* Show texts in modal

* Set search to worldwide on param received

* Send taxon as param to Explore from Taxon details screen

Closes #889

* Show all observations worldwide of project

* On species view pressed should navigate to explore species view

Closes #893

* Go to explore from users profile

* Navigate to species view from user profile

Closes #894

* Enable unclear filters

* Add taxon to context

* Use context for explore params further down the tree

* Refactor one state

* Remove unused action

* Remove unused state

* Refactor function

* Refactor state

* Refactor place_id, which concludes reducer refactor

* Refactor names

* Do not use key inside context's state

* Add a11y label

* Remove duplicate test ID

* Remove superfluous component

* Create ProjectListItem.test.js

* Add failing filter modal test

* Remove log

* Rename function

* Months strings

* Remove todo

* A11y labels

* Remove TODOs

* A11y label

* A11y label

* Refactor taxon search hook

* Update FilterModal.js

* A11y labels

* A11y not possible in react-native-paper lead to test fails

* Update TaxonSearch.test.js

* Add dropshadow

* Another dropshadow

* Add TODO text to UI elements that are not finished

* Reverse order

* Refactor constants

* Revert "Refactor constants"

This reverts commit 2f52e936d6.

* Refactor to use constants

* Refactor constants use

* Refactor constant use

* Refactor constants use

* Refactor constants use

* Refactor constants use

* Refactor code

* Add validation of date format

* Correct type for snapshot action

* Add taxonomic rank enum

* Taxon can be undefined

* More precise type

* Fix wrong string usage

* Refactor radio button row component

* Refactor ProjectListItem import

* Example usage of new ui elements

* Pull sort by sheet back inside filter modal

* Rename params

* Add useEffect dependency

* Rename param

* Fix broken function
2024-01-23 18:08:36 +01:00
Amanda Bullington
d0cf6751cf Render loading wheel until data is available for FlashList (#1016)
* Render loading wheel until data is available for FlashList; closes #756

* Fix: show loading wheel in Explore before data rendered

* Fix test
2024-01-10 14:33:59 -08:00
Ken-ichi
f7dc08a704 Suggestions fixes (#972)
* Bugfix: TaxonDetails was crashing if it received a null taxon
* Send lat and lng instead of latitude and longitude to the score_image
  endpoint
* Show offline suggestions when you are offline
* Show notice when viewing offline suggestions
* Moved code unique to useOnlineSuggestions into that file
* Ensure we use a medium size image to get suggestions when dealing with
  remote URLs
* More logging around React Query retries
* Use default retry logic for useAuthenticatedQuery
* Made a module-resolver shortcut for tests
* Move offline notice above top suggestion; hide when offlines exist but onlines do too
2023-12-15 19:58:12 -08:00
Amanda Bullington
ebcbcbe3c6 Add loading wheels to infinite scrolls; fix Species view; add tests; closes #888 (#934) 2023-11-29 15:46:28 -08:00
Amanda Bullington
8a92fca2e8 Update obs list to use React Query, fetch observations via id_below (#273)
* Rewrite remote observation & update fetching using useQuery in ObsList
* Fix ObsList test by adding query provider
* Add padding to infinite scroll view indicator
* Only set next uuid for obslist if not still loading results from last api call
* Improve how ObsList works when observations don't fill screen
* Remove explore, explore provider, dropdown menu, and related screens; fix tests
* Move setIdBelow function into onEndReached
2022-12-09 12:17:26 -08:00
Amanda Bullington
c740a06224 Start using Tailwind CSS (#185)
Starts changing styles over to tailwind via nativewind.

* Update node to 16.17.0
* Use styled() to ignore flow errors about className or tw props when styling components with nativewind
* Upgrade realm to make test suite run; set failing test in Explore as todo
* Add workaround for getting pods to run with XCode 14
* Fix for loading remote obs with infinite scroll
* Add styling section to README
* Use IconButton from rn-paper to make buttons more responsive to press
* Add caret next to camera roll album picker
* Fixed broken addition of gallery photos to existing observation
* Removed flatlist from scrollview on ProjectDetails (apparently not allowed?)
* Moved border style from Image to container in PhotoCarousel (border color
  not allowed for images?)

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-19 17:15:55 -07:00
Amanda Bullington
e81894d406 Use authenticated queries for fetch/search requests (#195)
* Use authenticated query for search results
* Use search API for fetching places from Settings
* Use authenticated query for authorized applications
* Use authenticated query to fetch user.me
* Move fetch/search api calls into react query format, out of hooks
* Update with react query instead of hooks
* Fetch list of blocked and muted users with authenticated query
* Added Podfile postinstall block to get app running in a Simulator
* Use auth query in identify
* Upgrade Realm to 11.0.0-rc.0, most recent version that will work with RN 0.68.2
* Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm
* Use authquery for explore provider
* ObsDetail wasn't showing the edit button for obs created while signed out
* simplified ObsEditHeader so it takes a full observation instead of relying
  on the ObsEditContext
* ObsEdit now accepts an obs UUID as a param and loads that if the context
  doesn't have a current obs
* null checks for API methods, mostly to prevent requests that won't work b/c
  of missing params

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-19 13:01:04 -07:00
Amanda Bullington
c4d9cd4dc6 Use babel-plugin-module-resolver (#188)
* Add alias and update eslint/flow to resolve modules

* Update aliases for components and api

* Add other src directories to module resolver aliases
2022-10-07 10:20:55 -07:00
Ken-ichi
c22d0fe79a Use RealmProvider (#183)
This attempts to remove the necessity of opening and closing Realm
connections, which can lead to stale connections and invalidated objects. I
did not try to remove direct access to realm from AuthenticatedService,
which exists outside of the component hierarchy and can't really access
context, but I think eventually we may want to bring all that functionality
within the component hierarchy so there really is only one Realm connection
in the app.

Probably still some bugs here. One major problem is that deleting the Realm
file does not seem to trigger a re-render of the RealmProvider. My workaround
was to delete all the data in RealmProvider connection to Realm before
deleting the file, but it seems kind of redundant.

Some other changes

* Updated react-native-image-resizer and worked around some regressions
* Needed to use Array.from on Realm collections in many places;
  map( o => o ) doesn't seem to work for creating POJOs from realm objects any more
* React Native Paper provider needs to be inside the Realm provider for any
  realm stuff to happen with rn paper modals
* Several workarounds for the fact that Realm objects don't behave like POJOs
* Added useApiToken hook (#158)
* Renamed the useUser hook to useRemoteUser, since that's what it was doing
2022-10-06 16:15:22 -07:00
Amanda Bullington
af8f17190d Keep toolbar sticky & collapse header on ObsList scroll (#182)
* Change bottom sheet modal to bottom sheet
* Give flatlist container a minHeight to make bottom sheet snap correctly when flatlist has few items
* Make entire header sticky above FlatList
* Hide header on scroll while keeping toolbar sticky on scroll
* Allow flatlist to scroll while bottom sheet modal up
* Use animated event on scroll with interpolation and stickyheaderindices to keep toolbar sticky while animating header
* Add accessibility label to logged out card

Closes #175
2022-09-27 16:20:13 -07:00
Amanda Bullington
337d812ab9 UI updates to bottom sheet (#181)
* Changes My Observations upload bottom sheet from modal to non-modal
* Give flatlist container a minHeight to make bottom sheet snap correctly when flatlist has few items
* Mock useLoggedIn hook in tests
* Move useCurrentUser to sharedHooks/ and mock in ObsList test
* Mock useUser hook
* Use useCurrentUser hook on user profile
* Downgrade gesture handler
2022-09-19 14:40:26 -07:00
Ken-ichi
e929764c25 Adopted and enforced code style from other iNat Javascript projects
These rules are largely based on the AirBnB ones, which are not quite standard
for the React Native world, where Prettier seems to be more common, but I
think they add a lot of useful checks, and unlike Prettier we can customize
them. This also just makes it easier for people on the iNat team to work on
the mobile app.

Some specific changes:

* Added eslint-plugin-react-hooks to eslint rules
* Added eslint-plugin-simple-import-sort to eslint rules
* Bugfix: could not import photo from gallery
* Added support for react-native/no-inline-styles eslint rule
* useUser should not bother fetching a user for a blank userId
2022-07-13 13:55:59 -07:00
Amanda Bullington
1ebf4b951d Bug fixes from beta 0.0.1 (#75)
* 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
2022-04-01 15:46:51 -07:00
Amanda Bullington
c5c50b3c24 Merge projects / project details into main (#38)
* Create projects screen which searches projects and changes API params on button press

* Create project details screen which makes an API call by project id

* Clean up project code; get one project test passing

* Basic styling for project details; add project observations grid

* Add testing for project details
2022-01-12 14:27:51 -08:00
Amanda Bullington
9ef85a6818 Explore and explore filters (#24)
* Create Explore screen

* Add input field component

* Add input fields

* UI for list view in Explore; dropdown taxa picker

* UI for list view in Explore; dropdown taxa picker

* ObservationViews component is shared between Explore and My Observations

* Get tests passing with Explore + ObservationViews

* Add map view, iOS location permission whenInUse, and geolocation fetch

* Add RN permissions and geolocation to jest mocks

* Explore filters, testing, explore provider/navigation stack

* Crash fix for grid items with no observation photos

* Code cleanup; remove duplicate files

* Remove more duplication

* Consolidate pickers into a single component

* Move copyRealmSchema into Observation model

* Move copyRealmSchema into Observation model

* Move observation photo logic to Obs model

* Obs details fetches an observation from API instead of from realm/exploreList

* Rename hooks files with 'use' instead of 'fetch'

* Add user to observation schema

* Change realm keys from camelcase to snakecase with mapping

* Simplify model code

* Fix tests for ObsDetails

* Attempt to clean up ObsList code; move useObservations hook into provider

* Several minor changes to get tests passing

* Stopped mocking useObservation hook in MyObservations integration test; this
  should not be mocked in an integration test since the point is to test the
  integration of all the different moving pieces within the app, and it was
  causing a failure because it was mocked but none of the methods were
  actually provided with mock responses, so it wasn't doing anything
* Used the LocalObservation factory for ObsDetails.test.js, where the
  useObservation hook should return an observation in the Realm schema
  (or something like it), not in the remote schema
* Updated the LocalObservation factory to meet expectations

* Attempting to work around weird problem with fkirc/skip-duplicate-actions

* Removed fkirc/skip-duplicate-actions from CI for now

* CI fix

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-01-07 11:38:50 -08:00