vn-verdnaturachat/app/views/RoomView/Separator.tsx

66 lines
1.8 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import moment from 'moment';
2019-03-29 19:36:07 +00:00
import I18n from '../../i18n';
2019-03-29 19:36:07 +00:00
import sharedStyles from '../Styles';
import { themes } from '../../lib/constants';
import { useTheme } from '../../theme';
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
alignItems: 'center',
2019-03-27 20:06:57 +00:00
marginTop: 16,
marginBottom: 4,
marginHorizontal: 14
},
line: {
height: 1,
flex: 1
},
text: {
fontSize: 14,
2019-12-04 16:39:53 +00:00
...sharedStyles.textMedium
},
marginRight: {
2019-03-29 19:36:07 +00:00
marginRight: 14
},
marginHorizontal: {
2019-03-29 19:36:07 +00:00
marginHorizontal: 14
}
});
const DateSeparator = ({ ts, unread }: { ts: Date | string | null; unread: boolean }): React.ReactElement => {
const { theme } = useTheme();
[NEW] Threads (#2567) * [IMPROVEMENT] Mentions layout without background * Fix RoomItem * Fix tests * Smaller messagebox * Messagebox colors tweak * Beginning header buttons refactor * Add HeaderButtons * item with title * Refactor * Remove lib * Refactor * Update snapshot * Send to channel on messagebox * Add tshow * Add showMessageInMainThread to login.user reducer * Filter threads on main channel based on user setting * Send tshow * Add tunread * Move unread colors logic away from UnreadBadge component so it can be used on other components * Export UnreadBadge on index * Add empty test * Refactor * Update tests * Lint * Thread unread user and group on RoomItem * Thread badge working * Started ThreadMessagesView.Item * Fix separator * Reactivity working * Lint * custom emojis aren't necessary * Basic filter layout * Filtering layout * Refactor * apply filter * DropdownItemHeader * default all * few fixes * No data found * Fixes list performance issues * Use locale on date formats * Fixed minor styles * Thread badge * Refactor getBadgeColor * Fix send to channel background color * starting search threads * Fix lint and tests * Bump to 4.12.0 just for testing :) * Search input layout * query * starting threads header * fix unnecessary tlm on tmid messages * Fix thread header * lint * Fix thread header on ShareView * Add e2e tests * Fix subscriptions sort * Update stories and minor fixes * Fix button sizes on Messagebox * Remove comment * Unnecessary conditional * Add showMessageInMainThread to user collection * Fix thread header * Fix thread messages not working on tablet * Reset Messagebox.tshow after sending a message * Allow to send to channel when replying to a thread from main channel * Unnecessary theme prop * Address comments * Remove re-render * Fix scroll indicator bug * Fix style * Minor i18n fix * Fix dropdown height * I18n ptbr * I18n
2020-10-30 17:35:07 +00:00
const date = ts ? moment(ts).format('LL') : null;
2019-12-04 16:39:53 +00:00
const unreadLine = { backgroundColor: themes[theme].dangerColor };
const unreadText = { color: themes[theme].dangerColor };
if (ts && unread) {
return (
<View style={styles.container}>
2019-12-04 16:39:53 +00:00
<Text style={[styles.text, unreadText]}>{I18n.t('unread_messages')}</Text>
<View style={[styles.line, unreadLine, styles.marginHorizontal]} />
<Text style={[styles.text, unreadText]}>{date}</Text>
</View>
);
}
if (ts) {
return (
<View style={styles.container}>
2019-12-04 16:39:53 +00:00
<View style={[styles.line, { backgroundColor: themes[theme].borderColor }]} />
<Text style={[styles.text, { color: themes[theme].auxiliaryText }, styles.marginHorizontal]}>{date}</Text>
<View style={[styles.line, { backgroundColor: themes[theme].borderColor }]} />
</View>
);
}
return (
<View style={styles.container}>
2019-12-04 16:39:53 +00:00
<Text style={[styles.text, unreadText, styles.marginRight]}>{I18n.t('unread_messages')}</Text>
<View style={[styles.line, unreadLine]} />
</View>
);
};
export default DateSeparator;