Rocket.Chat.ReactNative/app/containers/ThreadDetails.tsx

99 lines
2.4 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { StyleSheet, Text, View, ViewStyle } from 'react-native';
import Touchable from 'react-native-platform-touchable';
import { CustomIcon } from './CustomIcon';
import { themes } from '../lib/constants';
import sharedStyles from '../views/Styles';
import { useTheme } from '../theme';
import { TThreadModel } from '../definitions/IThread';
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
alignItems: 'center'
},
detailsContainer: {
flex: 1,
flexDirection: 'row'
},
detailContainer: {
flexDirection: 'row',
alignItems: 'center',
marginRight: 8
},
detailText: {
fontSize: 10,
marginLeft: 2,
...sharedStyles.textSemibold
},
badgeContainer: {
flexDirection: 'row',
alignItems: 'center'
},
badge: {
width: 8,
height: 8,
borderRadius: 4,
marginRight: 8
}
});
interface IThreadDetails {
item: Pick<TThreadModel, 'tcount' | 'replies' | 'id'>;
user: {
id: string;
};
2022-01-17 14:18:32 +00:00
badgeColor?: string;
toggleFollowThread: Function;
style: ViewStyle;
}
2022-01-17 14:18:32 +00:00
const ThreadDetails = ({ item, user, badgeColor, toggleFollowThread, style }: IThreadDetails): JSX.Element => {
const { theme } = useTheme();
let count: string | number | undefined | null = item.tcount;
if (count && count >= 1000) {
count = '+999';
}
let replies: number | string = item?.replies?.length ?? 0;
if (replies >= 1000) {
replies = '+999';
}
const isFollowing = item.replies?.find((u: string) => u === user?.id);
return (
<View style={[styles.container, style]}>
<View style={styles.detailsContainer}>
<View style={styles.detailContainer}>
feat: mobile color normalization (#5616) * chore: remove auxiliaryText color * chore: remove titleText * chore: password colors change * chore: use fontDefault on ActionSheet item * wip: type * chore: set custom icon default color * remove tintActive color * only set color when checked * remove icon color * remove tintActive * chore: remove STATUS_COLORS * chore: remove mentions colors * chore: remove switch color * chore: background color * chore: auxiliaryBackground * chore: one local colors * wip: some colors * wip: colors * wip: colors * wip: end colors * test: update * chore: fix some colors * chore: fix lint * chore: back to text props * chore: fix ts errors * revert * chore: fix lint * test: update snapshot * update storybook * cocoapods * fix app theme color * remove unused color * fix login service button color * remove unused color * unused backgroundColor * fix background color * fix transparent color * fix background color * wip: key * fix color * chore: revert to 1 tick * test: update * chore: use same color as front end * test: update * fix radius * fix background color * fix wrong color * change some colors * chore: update stories * chore: fix button style * chore: fix item color * lint * update snapshot * link * remove background color * change send to channel color * call icons * video conf colors * fix app default color * bottom sheet * remove background * two factor color * update tests * feat: add force-logout stream listener * remove icon colors * improve badge color * update tests * fix header colors * fix collapsible icon color * imagePreview color * wip * update test * lint --------- Co-authored-by: Diego Mello <diegolmello@gmail.com>
2024-04-18 10:19:54 +00:00
<CustomIcon name='threads' size={24} />
<Text
testID={`thread-count-${count}`}
feat: mobile color normalization (#5616) * chore: remove auxiliaryText color * chore: remove titleText * chore: password colors change * chore: use fontDefault on ActionSheet item * wip: type * chore: set custom icon default color * remove tintActive color * only set color when checked * remove icon color * remove tintActive * chore: remove STATUS_COLORS * chore: remove mentions colors * chore: remove switch color * chore: background color * chore: auxiliaryBackground * chore: one local colors * wip: some colors * wip: colors * wip: colors * wip: end colors * test: update * chore: fix some colors * chore: fix lint * chore: back to text props * chore: fix ts errors * revert * chore: fix lint * test: update snapshot * update storybook * cocoapods * fix app theme color * remove unused color * fix login service button color * remove unused color * unused backgroundColor * fix background color * fix transparent color * fix background color * wip: key * fix color * chore: revert to 1 tick * test: update * chore: use same color as front end * test: update * fix radius * fix background color * fix wrong color * change some colors * chore: update stories * chore: fix button style * chore: fix item color * lint * update snapshot * link * remove background color * change send to channel color * call icons * video conf colors * fix app default color * bottom sheet * remove background * two factor color * update tests * feat: add force-logout stream listener * remove icon colors * improve badge color * update tests * fix header colors * fix collapsible icon color * imagePreview color * wip * update test * lint --------- Co-authored-by: Diego Mello <diegolmello@gmail.com>
2024-04-18 10:19:54 +00:00
style={[styles.detailText, { color: themes[theme].fontSecondaryInfo }]}
numberOfLines={1}
>
{count}
</Text>
</View>
2021-09-17 20:22:02 +00:00
<View style={styles.detailContainer}>
feat: mobile color normalization (#5616) * chore: remove auxiliaryText color * chore: remove titleText * chore: password colors change * chore: use fontDefault on ActionSheet item * wip: type * chore: set custom icon default color * remove tintActive color * only set color when checked * remove icon color * remove tintActive * chore: remove STATUS_COLORS * chore: remove mentions colors * chore: remove switch color * chore: background color * chore: auxiliaryBackground * chore: one local colors * wip: some colors * wip: colors * wip: colors * wip: end colors * test: update * chore: fix some colors * chore: fix lint * chore: back to text props * chore: fix ts errors * revert * chore: fix lint * test: update snapshot * update storybook * cocoapods * fix app theme color * remove unused color * fix login service button color * remove unused color * unused backgroundColor * fix background color * fix transparent color * fix background color * wip: key * fix color * chore: revert to 1 tick * test: update * chore: use same color as front end * test: update * fix radius * fix background color * fix wrong color * change some colors * chore: update stories * chore: fix button style * chore: fix item color * lint * update snapshot * link * remove background color * change send to channel color * call icons * video conf colors * fix app default color * bottom sheet * remove background * two factor color * update tests * feat: add force-logout stream listener * remove icon colors * improve badge color * update tests * fix header colors * fix collapsible icon color * imagePreview color * wip * update test * lint --------- Co-authored-by: Diego Mello <diegolmello@gmail.com>
2024-04-18 10:19:54 +00:00
<CustomIcon name='user' size={24} />
<Text style={[styles.detailText, { color: themes[theme].fontSecondaryInfo }]} numberOfLines={1}>
{replies}
2021-09-17 20:22:02 +00:00
</Text>
</View>
</View>
<View style={styles.badgeContainer}>
{badgeColor ? <View style={[styles.badge, { backgroundColor: badgeColor }]} /> : null}
<Touchable onPress={() => toggleFollowThread?.(isFollowing, item.id)}>
feat: mobile color normalization (#5616) * chore: remove auxiliaryText color * chore: remove titleText * chore: password colors change * chore: use fontDefault on ActionSheet item * wip: type * chore: set custom icon default color * remove tintActive color * only set color when checked * remove icon color * remove tintActive * chore: remove STATUS_COLORS * chore: remove mentions colors * chore: remove switch color * chore: background color * chore: auxiliaryBackground * chore: one local colors * wip: some colors * wip: colors * wip: colors * wip: end colors * test: update * chore: fix some colors * chore: fix lint * chore: back to text props * chore: fix ts errors * revert * chore: fix lint * test: update snapshot * update storybook * cocoapods * fix app theme color * remove unused color * fix login service button color * remove unused color * unused backgroundColor * fix background color * fix transparent color * fix background color * wip: key * fix color * chore: revert to 1 tick * test: update * chore: use same color as front end * test: update * fix radius * fix background color * fix wrong color * change some colors * chore: update stories * chore: fix button style * chore: fix item color * lint * update snapshot * link * remove background color * change send to channel color * call icons * video conf colors * fix app default color * bottom sheet * remove background * two factor color * update tests * feat: add force-logout stream listener * remove icon colors * improve badge color * update tests * fix header colors * fix collapsible icon color * imagePreview color * wip * update test * lint --------- Co-authored-by: Diego Mello <diegolmello@gmail.com>
2024-04-18 10:19:54 +00:00
<CustomIcon size={24} name={isFollowing ? 'notification' : 'notification-disabled'} />
</Touchable>
</View>
</View>
);
};
export default ThreadDetails;