2020-09-11 17:10:16 +00:00
|
|
|
import React from 'react';
|
2021-09-13 20:41:05 +00:00
|
|
|
import { StyleSheet, Text, View } from 'react-native';
|
2020-09-11 17:10:16 +00:00
|
|
|
import { BorderlessButton } from 'react-native-gesture-handler';
|
|
|
|
|
|
|
|
import { themes } from '../../../constants/colors';
|
|
|
|
import { CustomIcon } from '../../../lib/Icons';
|
|
|
|
import sharedStyles from '../../Styles';
|
|
|
|
import Touch from '../../../utils/touch';
|
2022-02-01 13:39:09 +00:00
|
|
|
import { TServerHistoryModel } from '../../../definitions/IServerHistory';
|
2020-09-11 17:10:16 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
height: 56,
|
|
|
|
paddingHorizontal: 15,
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center'
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'column'
|
|
|
|
},
|
|
|
|
server: {
|
|
|
|
...sharedStyles.textMedium,
|
|
|
|
fontSize: 16
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-10-20 18:04:15 +00:00
|
|
|
interface IItem {
|
2022-02-01 13:39:09 +00:00
|
|
|
item: TServerHistoryModel;
|
2021-10-20 18:04:15 +00:00
|
|
|
theme: string;
|
|
|
|
onPress(url: string): void;
|
2022-02-01 13:39:09 +00:00
|
|
|
onDelete(item: TServerHistoryModel): void;
|
2021-10-20 18:04:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Item = ({ item, theme, onPress, onDelete }: IItem): JSX.Element => (
|
2021-09-13 20:41:05 +00:00
|
|
|
<Touch style={styles.container} onPress={() => onPress(item.url)} theme={theme} testID={`server-history-${item.url}`}>
|
2020-09-11 17:10:16 +00:00
|
|
|
<View style={styles.content}>
|
2021-09-13 20:41:05 +00:00
|
|
|
<Text numberOfLines={1} style={[styles.server, { color: themes[theme].bodyText }]}>
|
|
|
|
{item.url}
|
|
|
|
</Text>
|
2021-10-20 18:04:15 +00:00
|
|
|
<Text numberOfLines={1} style={{ color: themes[theme].auxiliaryText }}>
|
2021-09-13 20:41:05 +00:00
|
|
|
{item.username}
|
|
|
|
</Text>
|
2020-09-11 17:10:16 +00:00
|
|
|
</View>
|
2021-09-13 20:41:05 +00:00
|
|
|
<BorderlessButton onPress={() => onDelete(item)} testID={`server-history-delete-${item.url}`}>
|
2020-09-11 17:10:16 +00:00
|
|
|
<CustomIcon name='delete' size={24} color={themes[theme].auxiliaryText} />
|
|
|
|
</BorderlessButton>
|
|
|
|
</Touch>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default Item;
|