import React from 'react'; import { Dimensions, Text, TouchableOpacity, View } from 'react-native'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { ph, SIZE, WEIGHT } from '../../common/common'; import { timeSince } from '../../utils/utils'; import { ActionSheetEvent } from '../DialogManager/recievers'; const w = Dimensions.get('window').width; const h = Dimensions.get('window').height; export default class NoteItem extends React.Component { constructor(props) { super(props); this.cipher = { value: false, }; this.colors = []; this.actionSheet; this.show = null; this.setMenuRef = {}; this.willRefresh = false; } shouldComponentUpdate(nextProps, nextState) { if ( nextProps.item.locked !== this.cipher.value || nextProps.item.colors.length !== this.colors.length || nextProps.selectionMode !== this.props.selectionMode ) { return true; } else { return ( JSON.stringify(nextProps) !== JSON.stringify(this.props) || nextState !== this.state ); } } componentDidUpdate() { this.colors = [...this.props.item.colors]; this.cipher.value = this.props.item.locked ? true : false; } componentWillUnmount() { this.colors = []; this.cipher.value = false; } componentDidMount() { this.colors = []; if (this.props.item.locked) { this.cipher.value = true; } } render() { let {colors, item, customStyle, isTrash} = this.props; return ( {item.title.replace('\n', '')} {item.headline[item.headline.length - 1] === '\n' ? item.headline.slice(0, item.headline.length - 1) : item.headline} {!isTrash ? ( <> {item.colors.length > 0 ? ( {item.colors.map((item) => ( ))} ) : null} {item.locked ? ( ) : null} {item.favorite ? ( ) : null} {timeSince(item.dateCreated)} ) : null} {isTrash ? ( <> {'Deleted on: ' + item && item.dateDeleted ? new Date(item.dateDeleted).toISOString().slice(0, 10) : null + ' '} {item.type[0].toUpperCase() + item.type.slice(1) + ' '} ) : null} {item.conflicted ? ( CONFLICTS ) : null} { ActionSheetEvent( item, isTrash ? false : true, isTrash ? false : true, isTrash ? ['Remove', 'Restore'] : ['Add to', 'Share', 'Export', 'Delete', 'Copy'], isTrash ? [] : ['Pin', 'Favorite', 'Add to Vault'], ); }}> ); } }