diff --git a/app/components/option_item/index.tsx b/app/components/option_item/index.tsx index 3220b490a8..36c0d3095c 100644 --- a/app/components/option_item/index.tsx +++ b/app/components/option_item/index.tsx @@ -5,25 +5,32 @@ import React, {useCallback, useMemo} from 'react'; import {Platform, StyleProp, Switch, Text, TextStyle, TouchableOpacity, View, ViewStyle} from 'react-native'; import CompassIcon from '@components/compass_icon'; +import TouchableWithFeedback from '@components/touchable_with_feedback'; import {useTheme} from '@context/theme'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; import RadioItem, {RadioItemProps} from './radio_item'; -const OptionType = { +const TouchableOptionTypes = { ARROW: 'arrow', DEFAULT: 'default', - NONE: 'none', RADIO: 'radio', + REMOVE: 'remove', SELECT: 'select', +}; + +const OptionType = { + NONE: 'none', TOGGLE: 'toggle', + ...TouchableOptionTypes, } as const; type OptionType = typeof OptionType[keyof typeof OptionType]; export const ITEM_HEIGHT = 48; +const hitSlop = {top: 11, bottom: 11, left: 11, right: 11}; const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { return { actionContainer: { @@ -75,6 +82,13 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { color: theme.centerChannelColor, ...typography('Body', 200), }, + removeContainer: { + flex: 1, + alignItems: 'flex-end', + color: theme.centerChannelColor, + marginRight: 20, + ...typography('Body', 200), + }, row: { flex: 1, flexDirection: 'row', @@ -91,6 +105,7 @@ export type OptionItemProps = { info?: string; inline?: boolean; label: string; + onRemove?: () => void; optionDescriptionTextStyle?: StyleProp; optionLabelTextStyle?: StyleProp; radioItemProps?: Partial; @@ -99,6 +114,7 @@ export type OptionItemProps = { type: OptionType; value?: string; } + const OptionItem = ({ action, containerStyle, @@ -108,6 +124,7 @@ const OptionItem = ({ info, inline = false, label, + onRemove, optionDescriptionTextStyle, optionLabelTextStyle, radioItemProps, @@ -182,6 +199,21 @@ const OptionItem = ({ size={24} /> ); + } else if (type === OptionType.REMOVE) { + actionComponent = ( + + + + ); } const onPress = useCallback(() => { @@ -237,7 +269,7 @@ const OptionItem = ({ ); - if (type === OptionType.DEFAULT || type === OptionType.SELECT || type === OptionType.ARROW || type === OptionType.RADIO) { + if (Object.values(TouchableOptionTypes).includes(type)) { return ( {component} diff --git a/app/screens/home/search/initial/recent_searches/recent_item.tsx b/app/screens/home/search/initial/recent_searches/recent_item.tsx index d440b6181b..ae61a19635 100644 --- a/app/screens/home/search/initial/recent_searches/recent_item.tsx +++ b/app/screens/home/search/initial/recent_searches/recent_item.tsx @@ -2,41 +2,18 @@ // See LICENSE.txt for license information. import React, {useCallback} from 'react'; -import {Text, TouchableOpacity, View} from 'react-native'; +import {StyleSheet} from 'react-native'; import {removeSearchFromTeamSearchHistory} from '@actions/local/team'; -import CompassIcon from '@components/compass_icon'; -import MenuItem from '@components/menu_item'; +import OptionItem from '@components/option_item'; import {useServerUrl} from '@context/server'; -import {useTheme} from '@context/theme'; -import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; -import {typography} from '@utils/typography'; import type TeamSearchHistoryModel from '@typings/database/models/servers/team_search_history'; -const getStyleFromTheme = makeStyleSheetFromTheme((theme) => { - return { - container: { - marginVertical: -16, - paddingLeft: 20, - paddingRight: 6, - alignItems: 'center', - height: 48, - flexDirection: 'row', - }, - remove: { - height: 40, - width: 40, - alignItems: 'center', - justifyContent: 'center', - }, - term: { - flex: 1, - marginLeft: 16, - color: theme.centerChannelColor, - ...typography('Body', 200, 'Regular'), - }, - }; +const styles = StyleSheet.create({ + container: { + marginLeft: 20, + }, }); type Props = { @@ -45,9 +22,6 @@ type Props = { } const RecentItem = ({item, setRecentValue}: Props) => { - const theme = useTheme(); - const style = getStyleFromTheme(theme); - const testID = 'search.recent_item'; const serverUrl = useServerUrl(); const handlePress = useCallback(() => { @@ -59,31 +33,15 @@ const RecentItem = ({item, setRecentValue}: Props) => { }, [item.id, serverUrl]); return ( - - - {item.term} - - - - - } - separator={false} + ); };