-
Notifications
You must be signed in to change notification settings - Fork 785
/
Copy pathnotification-icon.component.js
53 lines (43 loc) · 1.2 KB
/
notification-icon.component.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// @flow
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { View } from 'react-native';
import styled from 'styled-components';
import { Icon } from 'react-native-elements';
import { Badge } from 'components';
import { colors } from 'config';
const BadgeContainer = styled.View`
position: absolute;
right: -1;
top: -1;
`;
const mapStateToProps = state => ({
notificationsCount: state.notifications.notificationsCount,
});
export class NotificationIconComponent extends Component {
props: {
iconColor: string,
notificationsCount: number,
};
render() {
const { iconColor, notificationsCount } = this.props;
return (
<View>
<Icon color={iconColor} name="notifications" size={33} />
{!!notificationsCount && (
<BadgeContainer>
<Badge
color={colors.white}
backgroundColor={colors.darkerRed}
text={notificationsCount > 99 ? '99+' : notificationsCount}
largeText={notificationsCount <= 99}
/>
</BadgeContainer>
)}
</View>
);
}
}
export const NotificationIcon = connect(mapStateToProps)(
NotificationIconComponent
);