Rocket.Chat.ReactNative/app/containers/UIKit/MultiSelect/Chips.tsx

54 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-02-11 14:01:35 +00:00
import React from 'react';
import { Text, View } from 'react-native';
2020-02-11 14:01:35 +00:00
import Touchable from 'react-native-platform-touchable';
import FastImage from '@rocket.chat/react-native-fast-image';
2020-02-11 14:01:35 +00:00
import { themes } from '../../../lib/constants';
2020-02-11 14:01:35 +00:00
import { textParser } from '../utils';
import { CustomIcon } from '../../../lib/Icons';
import styles from './styles';
import { IItemData } from '.';
2020-02-11 14:01:35 +00:00
interface IChip {
item: IItemData;
onSelect: (item: IItemData) => void;
style?: object;
theme: string;
}
interface IChips {
items: IItemData[];
onSelect: (item: IItemData) => void;
style?: object;
theme: string;
}
const keyExtractor = (item: IItemData) => item.value.toString();
2020-02-11 14:01:35 +00:00
const Chip = ({ item, onSelect, style, theme }: IChip) => (
2020-02-11 14:01:35 +00:00
<Touchable
key={item.value}
onPress={() => onSelect(item)}
[NEW] Livechat (#2004) * [WIP][NEW] Livechat info/actions * [IMPROVEMENT] RoomActionsView * [NEW] Visitor Navigation * [NEW] Get Department REST * [FIX] Borders * [IMPROVEMENT] Refactor RoomInfo View * [FIX] Error while navigate from mention -> roomInfo * [NEW] Livechat Fields * [NEW] Close Livechat * [WIP] Forward livechat * [NEW] Return inquiry * [WIP] Comment when close livechat * [WIP] Improve roomInfo * [IMPROVEMENT] Forward room * [FIX] Department picker * [FIX] Picker without results * [FIX] Superfluous argument * [FIX] Check permissions on RoomActionsView * [FIX] Livechat permissions * [WIP] Show edit to livechat * [I18N] Add pt-br translations * [WIP] Livechat Info * [IMPROVEMENT] Livechat info * [WIP] Livechat Edit * [WIP] Livechat edit * [WIP] Livechat Edit * [WIP] Livechat edit scroll * [FIX] Edit customFields * [FIX] Clean livechat customField * [FIX] Visitor Navigation * [NEW] Next input logic LivechatEdit * [FIX] Add livechat data to subscription * [FIX] Revert change * [NEW] Livechat user Status * [WIP] Livechat tags * [NEW] Edit livechat tags * [FIX] Prevent some crashes * [FIX] Forward * [FIX] Return Livechat error * [FIX] Prevent livechat info crash * [IMPROVEMENT] Use input style on forward chat * OnboardingSeparator -> OrSeparator * [FIX] Go to next input * [NEW] Added some icons * [NEW] Livechat close * [NEW] Forward Room Action * [FIX] Livechat edit style * [FIX] Change status logic * [CHORE] Remove unnecessary logic * [CHORE] Remove unnecessary code * [CHORE] Remove unecessary case * [FIX] Superfluous argument * [IMPROVEMENT] Submit livechat edit * [CHORE] Remove textInput type * [FIX] Livechat edit * [FIX] Livechat Edit * [FIX] Use same effect * [IMPROVEMENT] Tags input * [FIX] Add empty tag * Fix minor issues * Fix typo * insert livechat room data to our room object * review * add method calls server version Co-authored-by: Diego Mello <diegolmello@gmail.com>
2020-05-08 17:36:10 +00:00
style={[styles.chip, { backgroundColor: themes[theme].auxiliaryBackground }, style]}
background={Touchable.Ripple(themes[theme].bannerBackground)}>
2020-02-11 14:01:35 +00:00
<>
{item.imageUrl ? <FastImage style={styles.chipImage} source={{ uri: item.imageUrl }} /> : null}
<Text numberOfLines={1} style={[styles.chipText, { color: themes[theme].titleText }]}>
{textParser([item.text])}
</Text>
2020-07-27 19:53:33 +00:00
<CustomIcon name='close' size={16} color={themes[theme].auxiliaryText} />
2020-02-11 14:01:35 +00:00
</>
</Touchable>
);
Chip.propTypes = {};
2020-02-11 14:01:35 +00:00
const Chips = ({ items, onSelect, style, theme }: IChips) => (
2020-02-11 14:01:35 +00:00
<View style={styles.chips}>
{items.map(item => (
<Chip key={keyExtractor(item)} item={item} onSelect={onSelect} style={style} theme={theme} />
))}
2020-02-11 14:01:35 +00:00
</View>
);
export default Chips;