mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 14:08:31 -04:00
FYI, this also essentially outlaws variables in translation keys because a key that is only used with interpolated strings will never appear as "used". Also starts using a convention of adding info to i18n keys that do not relate to the text after double dashes, e.g. `Unknown--taxon = Unknown` for a string that is specifically meant to describe a missing taxon but only needs to have the word "Unknown". * Changed several accessibilityHints to 3rd person * Made several accessibilityLabels shorter and more verb-oriented * Removed many unused i18n keys * Refactored variables in i18n keys * Removed some unused code from the old Settings
72 lines
1.7 KiB
JavaScript
72 lines
1.7 KiB
JavaScript
// @flow
|
|
import { useNavigation } from "@react-navigation/native";
|
|
import {
|
|
Body1, INatIcon,
|
|
List2, UserIcon
|
|
} from "components/SharedComponents";
|
|
import { Pressable, View } from "components/styledComponents";
|
|
import type { Node } from "react";
|
|
import React, { useCallback } from "react";
|
|
import User from "realmModels/User";
|
|
import { useTranslation } from "sharedHooks";
|
|
|
|
type Props = {
|
|
item: Object,
|
|
countText: string,
|
|
onPress?: Function,
|
|
accessibilityLabel?: string
|
|
};
|
|
|
|
const UserListItem = ( {
|
|
item,
|
|
countText,
|
|
onPress: onPressProp,
|
|
accessibilityLabel: accessibilityLabelProp
|
|
}: Props ): Node => {
|
|
const { t } = useTranslation( );
|
|
const user = item?.user;
|
|
const navigation = useNavigation( );
|
|
|
|
const onPress = useCallback( ( ) => {
|
|
if ( onPressProp ) return onPressProp( );
|
|
return navigation.navigate( "UserProfile", { userId: user?.id } );
|
|
}, [
|
|
navigation,
|
|
onPressProp,
|
|
user?.id
|
|
] );
|
|
|
|
return (
|
|
<Pressable
|
|
accessibilityRole={
|
|
onPressProp
|
|
? "button"
|
|
: "link"
|
|
}
|
|
className="flex-row items-center mx-3 my-2"
|
|
testID={`UserProfile.${user?.id}`}
|
|
onPress={onPress}
|
|
accessibilityLabel={accessibilityLabelProp || t( "Navigates-to-user-profile" )}
|
|
accessibilityState={{ disabled: false }}
|
|
>
|
|
|
|
{user?.icon_url
|
|
? <UserIcon uri={User.uri( user )} medium />
|
|
: (
|
|
<INatIcon
|
|
name="person"
|
|
size={62}
|
|
/>
|
|
)}
|
|
<View className="ml-3">
|
|
{user?.login && <Body1 className="mt-3">{user?.login}</Body1>}
|
|
<List2 className="mt-1">
|
|
{countText}
|
|
</List2>
|
|
</View>
|
|
</Pressable>
|
|
);
|
|
};
|
|
|
|
export default UserListItem;
|