From 8b8afd69eb7f4195784842d71171ab0bd598813b Mon Sep 17 00:00:00 2001 From: keplyx Date: Sun, 8 Mar 2020 14:43:02 +0100 Subject: [PATCH] Removed unused code and some arrow functions --- components/DashboardItem.js | 107 ++++++++++-------------------------- components/FeedItem.js | 10 +++- 2 files changed, 37 insertions(+), 80 deletions(-) diff --git a/components/DashboardItem.js b/components/DashboardItem.js index fdabb1d..7e61752 100644 --- a/components/DashboardItem.js +++ b/components/DashboardItem.js @@ -7,7 +7,7 @@ import ThemeManager from "../utils/ThemeManager"; import HTML from "react-native-render-html"; import {LinearGradient} from "expo-linear-gradient"; import i18n from "i18n-js"; -import {Avatar, Card, Text, Title} from 'react-native-paper'; +import {Avatar, Card, Text} from 'react-native-paper'; type Props = { isAvailable: boolean, @@ -28,6 +28,13 @@ export default class DashboardItem extends React.Component { displayEvent: undefined, }; + getIcon: Function; + + constructor() { + super(); + this.getIcon = this.getIcon.bind(this); + } + /** * Convert the date string given by in the event list json to a date object * @param dateString @@ -64,18 +71,17 @@ export default class DashboardItem extends React.Component { getEventPreviewContainer() { if (this.props.displayEvent !== undefined && this.props.displayEvent !== null) { const hasImage = this.props.displayEvent['logo'] !== '' && this.props.displayEvent['logo'] !== null; + const getImage = () => ; return ( {hasImage ? - - } + left={getImage} /> : { getIcon() { return ( - + ); } - getText() { - return ( - - - {this.props.title} - - - {this.props.subtitle} - - - ); - } - - getContent() { - if (this.props.isSquare) { - return ( - - - {this.getIcon()} - - {this.getText()} - - ); - } - } - - render() { // console.log("rendering DashboardItem " + this.props.title); let marginRight = 10; @@ -211,28 +173,17 @@ export default class DashboardItem extends React.Component { overflow: 'hidden', }} onPress={this.props.clickAction}> - {this.props.isSquare ? - - {this.getContent()} - - : - - } - /> - - {this.getEventPreviewContainer()} - - } + + + + {this.getEventPreviewContainer()} + ); } diff --git a/components/FeedItem.js b/components/FeedItem.js index a7de279..58294a9 100644 --- a/components/FeedItem.js +++ b/components/FeedItem.js @@ -6,6 +6,13 @@ import i18n from "i18n-js"; const ICON_AMICALE = require('../assets/amicale.png'); +function getAvatar() { + return ( + + ); +} + function FeedItem(props) { const {colors} = props.theme; return ( @@ -13,8 +20,7 @@ function FeedItem(props) { } + left={getAvatar} /> {props.full_picture !== '' && props.full_picture !== undefined ?