diff --git a/__tests__/tests/components/NotificationListItem.js b/__tests__/tests/components/NotificationListItem.js
index 9423a3faf..20ff8c29a 100644
--- a/__tests__/tests/components/NotificationListItem.js
+++ b/__tests__/tests/components/NotificationListItem.js
@@ -61,8 +61,8 @@ describe('', () => {
it('should return the correct icon name', () => {
const wrapper = shallow();
- expect(wrapper.instance().getIconName('commit')).toEqual('git-commit');
- expect(wrapper.instance().getIconName('pullRequest')).toEqual(
+ expect(wrapper.instance().getIconName('Commit')).toEqual('git-commit');
+ expect(wrapper.instance().getIconName('PullRequest')).toEqual(
'git-pull-request'
);
expect(wrapper.instance().getIconName('wrong data')).toEqual(
@@ -92,4 +92,25 @@ describe('', () => {
expect(iconActionMock).toHaveBeenCalledWith(1);
expect(iconActionMock).toHaveBeenCalledTimes(1);
});
+
+ it('should return object empty', () => {
+ const wrapper = shallow();
+
+ expect(wrapper.instance().getTitleComponentProps()).toEqual({});
+ });
+
+ it('should return object with nativeId and onPress', () => {
+ const notification = {
+ subject: {
+ type: 'not a commit',
+ },
+ };
+ const wrapper = shallow(
+
+ );
+
+ const result = wrapper.instance().getTitleComponentProps();
+ expect(result.nativeId).toBe('TitleComponent');
+ expect(result.onPress).toEqual(expect.any(Function));
+ });
});
diff --git a/src/components/notification-list-item.component.js b/src/components/notification-list-item.component.js
index aed9b1f25..c01f9f0aa 100644
--- a/src/components/notification-list-item.component.js
+++ b/src/components/notification-list-item.component.js
@@ -1,10 +1,11 @@
/* eslint-disable no-nested-ternary */
import React, { Component } from 'react';
-import { StyleSheet, View, TouchableOpacity, Text } from 'react-native';
+import styled from 'styled-components/native';
+import { View, TouchableOpacity } from 'react-native';
import { Icon } from 'react-native-elements';
-import { colors, fonts, normalize } from 'config';
+import { colors, styledFonts, normalize } from 'config';
type Props = {
notification: Object,
@@ -12,41 +13,46 @@ type Props = {
navigationAction: Function,
};
-const styles = StyleSheet.create({
- container: {
- borderBottomColor: colors.greyLight,
- borderBottomWidth: 1,
- },
- wrapper: {
- padding: 10,
- flexDirection: 'row',
- },
- notificationInfo: {
- flex: 1,
- flexDirection: 'row',
- alignItems: 'center',
- },
- avatar: {
- backgroundColor: colors.greyLight,
- borderRadius: 17,
- width: 34,
- height: 34,
- },
- titleContainer: {
- flex: 1,
- },
- title: {
- color: colors.black,
- ...fonts.fontPrimary,
- fontSize: normalize(12),
- marginLeft: 10,
- },
- iconContainer: {
- flex: 0.15,
- alignItems: 'flex-end',
- justifyContent: 'center',
- },
-});
+const NotificationListItemContainer = styled.View`
+ border-bottom-color: ${colors.greyLight};
+ border-bottom-width: 1;
+`;
+
+const Wrapper = styled.View`
+ flex-direction: row;
+ padding: 10px;
+`;
+
+const TitleComponent = styled(({ tag, children, ...props }) =>
+ React.createElement(tag, props, children)
+)`
+ flex: 1;
+ flex-direction: row;
+ align-items: center;
+`;
+
+const TitleContainer = styled.View`
+ flex: 1;
+`;
+
+const Title = styled.Text`
+ color: ${colors.black};
+ font-family: ${styledFonts.fontPrimary};
+ font-size: ${normalize(12)};
+ margin-left: 10px;
+`;
+
+const CheckButton = styled.TouchableOpacity`
+ flex: 0.15;
+ align-items: flex-end;
+ justify-content: center;
+`;
+
+const IconStyled = styled(Icon).attrs({
+ color: colors.grey,
+ size: 22,
+ type: 'octicon',
+})``;
export class NotificationListItem extends Component {
props: Props;
@@ -59,52 +65,52 @@ export class NotificationListItem extends Component {
getIconName = type => {
switch (type) {
- case 'commit':
+ case 'Commit':
return 'git-commit';
- case 'pullRequest':
+ case 'PullRequest':
return 'git-pull-request';
default:
return 'issue-opened';
}
};
- render() {
- const { notification, iconAction, navigationAction } = this.props;
+ getTitleComponentProps = () => {
+ const { notification, navigationAction } = this.props;
+
+ return notification.subject.type === 'Commit'
+ ? {}
+ : {
+ onPress: () => navigationAction(notification),
+ nativeId: 'TitleComponent',
+ };
+ };
- const TitleComponent = this.getComponentType();
+ render() {
+ const { notification, iconAction } = this.props;
+ const tag = this.getComponentType();
const iconName = this.getIconName(notification.subject.type);
+ const titleComponentProps = this.getTitleComponentProps();
return (
-
-
- navigationAction(notification)}
- >
-
-
-
- {notification.subject.title}
-
+
+
+
+
+
+ {notification.subject.title}
+
{notification.unread && (
- iconAction(notification.id)}
+ nativeId="notification-unread"
>
-
-
+
+
)}
-
-
+
+
);
}
}