diff --git a/app/screens/invite/selected_email.tsx b/app/components/selected_chip/index.tsx similarity index 74% rename from app/screens/invite/selected_email.tsx rename to app/components/selected_chip/index.tsx index 491f540c10..3ea8e221dd 100644 --- a/app/screens/invite/selected_email.tsx +++ b/app/components/selected_chip/index.tsx @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import React, {useCallback} from 'react'; -import {Text, TouchableOpacity} from 'react-native'; +import {Text, TouchableOpacity, View} from 'react-native'; import Animated, {FadeIn, FadeOut} from 'react-native-reanimated'; import CompassIcon from '@components/compass_icon'; @@ -10,8 +10,10 @@ import {useTheme} from '@context/theme'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; -type Props = { - email: string; +type SelectedChipProps = { + id: string; + text: string; + extra?: React.ReactNode; onRemove: (id: string) => void; testID?: string; } @@ -33,49 +35,59 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme) => { marginRight: 8, paddingHorizontal: 7, }, - remove: { - justifyContent: 'center', - marginLeft: 7, + extraContent: { + flexDirection: 'row', + alignItems: 'center', + color: theme.centerChannelColor, }, text: { marginLeft: 8, color: theme.centerChannelColor, ...typography('Body', 100, 'SemiBold'), }, + remove: { + justifyContent: 'center', + marginLeft: 7, + }, }; }); -export default function SelectedEmail({ - email, +export default function SelectedChip({ + id, + text, + extra, onRemove, testID, -}: Props) { +}: SelectedChipProps) { const theme = useTheme(); const style = getStyleFromTheme(theme); const onPress = useCallback(() => { - onRemove(email); - }, [onRemove, email]); - - const selectedEmailTestID = `${testID}.${email}`; + onRemove(id); + }, [onRemove, id]); return ( + {extra && ( + + {extra} + + )} - {email} + {text} { - return { - container: { - alignItems: 'center', - justifyContent: 'center', - flexDirection: 'row', - borderRadius: 16, - height: USER_CHIP_HEIGHT, - backgroundColor: changeOpacity(theme.centerChannelColor, 0.08), - marginBottom: USER_CHIP_BOTTOM_MARGIN, - marginRight: 8, - paddingHorizontal: 7, - }, - remove: { - justifyContent: 'center', - marginLeft: 7, - }, - profileContainer: { - flexDirection: 'row', - alignItems: 'center', - marginRight: 8, - color: theme.centerChannelColor, - }, - text: { - color: theme.centerChannelColor, - ...typography('Body', 100, 'SemiBold'), - }, - }; -}); - export default function SelectedUser({ teammateNameDisplay, user, onRemove, testID, }: Props) { - const theme = useTheme(); - const style = getStyleFromTheme(theme); const intl = useIntl(); - const onPress = useCallback(() => { - onRemove(user.id); - }, [onRemove, user.id]); + const onPress = useCallback((id: string) => { + onRemove(id); + }, [onRemove]); const userItemTestID = `${testID}.${user.id}`; + return ( - - + - - - {displayUsername(user, intl.locale, teammateNameDisplay)} - - - - - + )} + onRemove={onPress} + testID={userItemTestID} + /> ); } diff --git a/app/screens/invite/invite.tsx b/app/screens/invite/invite.tsx index 001594aa32..6246f316a1 100644 --- a/app/screens/invite/invite.tsx +++ b/app/screens/invite/invite.tsx @@ -337,7 +337,7 @@ export default function Invite({ }, }, }); - }, [componentId, locale, theme, stage]); + }, [componentId, locale, theme, stage === Stage.RESULT]); useEffect(() => { return () => { diff --git a/app/screens/invite/selection.tsx b/app/screens/invite/selection.tsx index c7e1e3d082..f14dd66055 100644 --- a/app/screens/invite/selection.tsx +++ b/app/screens/invite/selection.tsx @@ -15,6 +15,7 @@ import { import Animated, {useAnimatedStyle, useDerivedValue} from 'react-native-reanimated'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; +import SelectedChip from '@components/selected_chip'; import SelectedUser from '@components/selected_users/selected_user'; import TouchableWithFeedback from '@components/touchable_with_feedback'; import UserItem from '@components/user_item'; @@ -25,7 +26,6 @@ import {useIsTablet, useKeyboardHeight} from '@hooks/device'; import {makeStyleSheetFromTheme, changeOpacity} from '@utils/theme'; import {SearchResult} from './invite'; -import SelectedEmail from './selected_email'; import SelectionSearchBar from './selection_search_bar'; import SelectionTeamBar from './selection_team_bar'; import TextItem, {TextItemType} from './text_item'; @@ -279,11 +279,12 @@ export default function Selection({ const selectedItem = selectedIds[id]; selectedItems.push(typeof selectedItem === 'string' ? ( - ) : (