mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
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>
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
// @flow
|
|
|
|
import { Image, Pressable, View } from "components/styledComponents";
|
|
import { RealmContext } from "providers/contexts";
|
|
import type { Node } from "react";
|
|
import React, { useEffect, useState } from "react";
|
|
import { Avatar } from "react-native-paper";
|
|
|
|
import Observation from "../../../models/Observation";
|
|
import Photo from "../../../models/Photo";
|
|
import ObsCardDetails from "./ObsCardDetails";
|
|
import ObsCardStats from "./ObsCardStats";
|
|
|
|
const { useRealm } = RealmContext;
|
|
|
|
type Props = {
|
|
item: Object,
|
|
handlePress: Function
|
|
}
|
|
|
|
const ObsCard = ( { item, handlePress }: Props ): Node => {
|
|
const [needsUpload, setNeedsUpload] = useState( false );
|
|
const onPress = ( ) => handlePress( item );
|
|
const realm = useRealm( );
|
|
|
|
const photo = item?.observationPhotos?.[0]?.photo;
|
|
|
|
useEffect( ( ) => {
|
|
const markAsNeedsUpload = async ( ) => {
|
|
const isUnsyncedObs = Observation.isUnsyncedObservation( realm, item );
|
|
setNeedsUpload( isUnsyncedObs );
|
|
};
|
|
markAsNeedsUpload( );
|
|
}, [item, realm] );
|
|
|
|
return (
|
|
<Pressable
|
|
onPress={onPress}
|
|
className="flex-row my-2 mx-3 justify-between"
|
|
testID={`ObsList.obsCard.${item.uuid}`}
|
|
accessibilityRole="link"
|
|
accessibilityLabel="Navigate to observation details screen"
|
|
>
|
|
<View className="flex-row shrink">
|
|
<Image
|
|
source={{ uri: Photo.displayLocalOrRemoteSquarePhoto( photo ) }}
|
|
className="w-16 h-16 rounded-md mr-2"
|
|
testID="ObsList.photo"
|
|
/>
|
|
<View className="shrink">
|
|
<ObsCardDetails item={item} />
|
|
</View>
|
|
</View>
|
|
<View className="flex-row items-center justify-items-center ml-2">
|
|
{needsUpload
|
|
? <Avatar.Icon size={40} icon="arrow-up-circle-outline" />
|
|
: <ObsCardStats item={item} type="list" />}
|
|
</View>
|
|
</Pressable>
|
|
);
|
|
};
|
|
|
|
export default ObsCard;
|