verdnatura-chat/app/containers/UserItem.tsx

77 lines
1.8 KiB
TypeScript
Raw Permalink Normal View History

import React from 'react';
import { Pressable, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';
import Avatar from './Avatar';
import { CustomIcon, TIconsName } from './CustomIcon';
2019-03-29 19:36:07 +00:00
import sharedStyles from '../views/Styles';
import { isIOS } from '../lib/methods/helpers';
import { useTheme } from '../theme';
const styles = StyleSheet.create({
button: {
2019-12-04 16:39:53 +00:00
height: 54
},
container: {
flexDirection: 'row'
},
avatar: {
marginHorizontal: 15,
marginVertical: 12
},
textContainer: {
flex: 1,
2019-03-29 19:36:07 +00:00
flexDirection: 'column',
justifyContent: 'center',
marginRight: 15
},
name: {
fontSize: 16,
2019-12-04 16:39:53 +00:00
...sharedStyles.textMedium
},
icon: {
marginHorizontal: 15,
2019-12-04 16:39:53 +00:00
alignSelf: 'center'
}
});
interface IUserItem {
name: string;
username: string;
onPress(): void;
testID: string;
onLongPress?: () => void;
style?: StyleProp<ViewStyle>;
icon?: TIconsName | null;
iconColor?: string;
}
const UserItem = ({ name, username, onPress, testID, onLongPress, style, icon, iconColor }: IUserItem) => {
const { colors } = useTheme();
return (
<Pressable
onPress={onPress}
onLongPress={onLongPress}
testID={testID}
android_ripple={{
Merge branch 'new.semantic-colors' into new.semantic-colors-2 # Conflicts: # app/containers/ActionSheet/BottomSheetContent.tsx # app/containers/ActionSheet/Item.tsx # app/containers/EmojiPicker/index.tsx # app/containers/MessageActions/Header.tsx # app/containers/MessageBox/buttons/BaseButton.tsx # app/containers/RoomItem/Touchable.tsx # app/containers/ServerItem/index.tsx # app/containers/UIKit/DatePicker.tsx # app/containers/UIKit/MultiSelect/Chips.tsx # app/containers/UIKit/MultiSelect/Input.tsx # app/containers/UIKit/MultiSelect/MultiSelectContent.tsx # app/containers/UIKit/Overflow.tsx # app/containers/UserItem.tsx # app/containers/markdown/index.tsx # app/containers/message/Audio.tsx # app/containers/message/Components/CollapsibleQuote/index.tsx # app/containers/message/Image.tsx # app/containers/message/Reactions.tsx # app/containers/message/Reply.tsx # app/containers/message/Urls.tsx # app/containers/message/Video.tsx # app/lib/constants/colors.ts # app/lib/methods/helpers/touch.tsx # app/views/AddExistingChannelView.tsx # app/views/CreateChannelView.tsx # app/views/E2ESaveYourPasswordView.tsx # app/views/InviteUsersView/index.tsx # app/views/ModalBlockView.tsx # app/views/NewMessageView.tsx # app/views/NotificationPreferencesView/index.tsx # app/views/ReadReceiptView/index.tsx # app/views/RegisterView.tsx # app/views/RoomInfoView/index.tsx # app/views/RoomMembersView/index.tsx # app/views/RoomView/Banner.tsx # app/views/SelectListView.tsx # app/views/SetUsernameView.tsx # app/views/ShareListView/Header/SearchBox.tsx # app/views/ShareView/Preview.tsx # app/views/ShareView/Thumbs.tsx # app/views/SidebarView/index.tsx # app/views/UserNotificationPreferencesView/index.tsx # ios/Podfile.lock # ios/RocketChatRN.xcodeproj/project.pbxproj
2022-12-15 19:19:00 +00:00
color: colors.buttonBackgroundSecondaryPress
}}
style={({ pressed }: any) => ({
Merge branch 'new.semantic-colors' into new.semantic-colors-2 # Conflicts: # app/containers/ActionSheet/BottomSheetContent.tsx # app/containers/ActionSheet/Item.tsx # app/containers/EmojiPicker/index.tsx # app/containers/MessageActions/Header.tsx # app/containers/MessageBox/buttons/BaseButton.tsx # app/containers/RoomItem/Touchable.tsx # app/containers/ServerItem/index.tsx # app/containers/UIKit/DatePicker.tsx # app/containers/UIKit/MultiSelect/Chips.tsx # app/containers/UIKit/MultiSelect/Input.tsx # app/containers/UIKit/MultiSelect/MultiSelectContent.tsx # app/containers/UIKit/Overflow.tsx # app/containers/UserItem.tsx # app/containers/markdown/index.tsx # app/containers/message/Audio.tsx # app/containers/message/Components/CollapsibleQuote/index.tsx # app/containers/message/Image.tsx # app/containers/message/Reactions.tsx # app/containers/message/Reply.tsx # app/containers/message/Urls.tsx # app/containers/message/Video.tsx # app/lib/constants/colors.ts # app/lib/methods/helpers/touch.tsx # app/views/AddExistingChannelView.tsx # app/views/CreateChannelView.tsx # app/views/E2ESaveYourPasswordView.tsx # app/views/InviteUsersView/index.tsx # app/views/ModalBlockView.tsx # app/views/NewMessageView.tsx # app/views/NotificationPreferencesView/index.tsx # app/views/ReadReceiptView/index.tsx # app/views/RegisterView.tsx # app/views/RoomInfoView/index.tsx # app/views/RoomMembersView/index.tsx # app/views/RoomView/Banner.tsx # app/views/SelectListView.tsx # app/views/SetUsernameView.tsx # app/views/ShareListView/Header/SearchBox.tsx # app/views/ShareView/Preview.tsx # app/views/ShareView/Thumbs.tsx # app/views/SidebarView/index.tsx # app/views/UserNotificationPreferencesView/index.tsx # ios/Podfile.lock # ios/RocketChatRN.xcodeproj/project.pbxproj
2022-12-15 19:19:00 +00:00
backgroundColor: isIOS && pressed ? colors.buttonBackgroundSecondaryPress : 'transparent'
})}
>
<View style={[styles.container, styles.button, style]}>
<Avatar text={username} size={30} style={styles.avatar} />
<View style={styles.textContainer}>
<Text style={[styles.name, { color: colors.bodyText }]} numberOfLines={1}>
{name}
</Text>
</View>
Merge branch 'new.semantic-colors' into new.semantic-colors-2 # Conflicts: # app/containers/ActionSheet/BottomSheetContent.tsx # app/containers/ActionSheet/Item.tsx # app/containers/EmojiPicker/index.tsx # app/containers/MessageActions/Header.tsx # app/containers/MessageBox/buttons/BaseButton.tsx # app/containers/RoomItem/Touchable.tsx # app/containers/ServerItem/index.tsx # app/containers/UIKit/DatePicker.tsx # app/containers/UIKit/MultiSelect/Chips.tsx # app/containers/UIKit/MultiSelect/Input.tsx # app/containers/UIKit/MultiSelect/MultiSelectContent.tsx # app/containers/UIKit/Overflow.tsx # app/containers/UserItem.tsx # app/containers/markdown/index.tsx # app/containers/message/Audio.tsx # app/containers/message/Components/CollapsibleQuote/index.tsx # app/containers/message/Image.tsx # app/containers/message/Reactions.tsx # app/containers/message/Reply.tsx # app/containers/message/Urls.tsx # app/containers/message/Video.tsx # app/lib/constants/colors.ts # app/lib/methods/helpers/touch.tsx # app/views/AddExistingChannelView.tsx # app/views/CreateChannelView.tsx # app/views/E2ESaveYourPasswordView.tsx # app/views/InviteUsersView/index.tsx # app/views/ModalBlockView.tsx # app/views/NewMessageView.tsx # app/views/NotificationPreferencesView/index.tsx # app/views/ReadReceiptView/index.tsx # app/views/RegisterView.tsx # app/views/RoomInfoView/index.tsx # app/views/RoomMembersView/index.tsx # app/views/RoomView/Banner.tsx # app/views/SelectListView.tsx # app/views/SetUsernameView.tsx # app/views/ShareListView/Header/SearchBox.tsx # app/views/ShareView/Preview.tsx # app/views/ShareView/Thumbs.tsx # app/views/SidebarView/index.tsx # app/views/UserNotificationPreferencesView/index.tsx # ios/Podfile.lock # ios/RocketChatRN.xcodeproj/project.pbxproj
2022-12-15 19:19:00 +00:00
{icon ? <CustomIcon name={icon} size={22} color={iconColor || colors.tintColor} style={styles.icon} /> : null}
</View>
</Pressable>
);
};
export default UserItem;