[IMPROVE] - migrate UnreadBadge presentation layer
This commit is contained in:
parent
601a45a194
commit
9d312bd9a6
|
@ -2,7 +2,7 @@ import { themes } from '../../constants/colors';
|
||||||
|
|
||||||
export const getUnreadStyle = ({
|
export const getUnreadStyle = ({
|
||||||
unread, userMentions, groupMentions, theme, tunread, tunreadUser, tunreadGroup
|
unread, userMentions, groupMentions, theme, tunread, tunreadUser, tunreadGroup
|
||||||
}) => {
|
}: any) => {
|
||||||
if ((!unread || unread <= 0) && (!tunread?.length)) {
|
if ((!unread || unread <= 0) && (!tunread?.length)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { View, Text, StyleSheet } from 'react-native';
|
import { View, Text, StyleSheet } from 'react-native';
|
||||||
|
|
||||||
import sharedStyles from '../../views/Styles';
|
import sharedStyles from '../../views/Styles';
|
||||||
|
@ -30,9 +29,21 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface IUnreadBadge {
|
||||||
|
theme: string;
|
||||||
|
unread: number;
|
||||||
|
userMentions: number;
|
||||||
|
groupMentions: number;
|
||||||
|
style: object;
|
||||||
|
tunread: [];
|
||||||
|
tunreadUser: [];
|
||||||
|
tunreadGroup: [];
|
||||||
|
small: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
const UnreadBadge = React.memo(({
|
const UnreadBadge = React.memo(({
|
||||||
theme, unread, userMentions, groupMentions, style, tunread, tunreadUser, tunreadGroup, small
|
theme, unread, userMentions, groupMentions, style, tunread, tunreadUser, tunreadGroup, small
|
||||||
}) => {
|
}: IUnreadBadge) => {
|
||||||
if ((!unread || unread <= 0) && (!tunread?.length)) {
|
if ((!unread || unread <= 0) && (!tunread?.length)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +54,7 @@ const UnreadBadge = React.memo(({
|
||||||
if (!backgroundColor) {
|
if (!backgroundColor) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let text = unread || tunread?.length;
|
let text: any = unread || tunread?.length;
|
||||||
if (small && text >= 100) {
|
if (small && text >= 100) {
|
||||||
text = '+99';
|
text = '+99';
|
||||||
}
|
}
|
||||||
|
@ -78,16 +89,4 @@ const UnreadBadge = React.memo(({
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
UnreadBadge.propTypes = {
|
|
||||||
theme: PropTypes.string,
|
|
||||||
unread: PropTypes.number,
|
|
||||||
userMentions: PropTypes.number,
|
|
||||||
groupMentions: PropTypes.number,
|
|
||||||
style: PropTypes.object,
|
|
||||||
tunread: PropTypes.array,
|
|
||||||
tunreadUser: PropTypes.array,
|
|
||||||
tunreadGroup: PropTypes.array,
|
|
||||||
small: PropTypes.bool
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withTheme(UnreadBadge);
|
export default withTheme(UnreadBadge);
|
Loading…
Reference in New Issue