// @flow import * as React from 'react'; import {Badge, TouchableRipple, withTheme} from 'react-native-paper'; import {Dimensions, Image, View} from 'react-native'; import * as Animatable from 'react-native-animatable'; import type {CustomTheme} from '../../managers/ThemeManager'; type PropsType = { image: string | null, onPress: () => void | null, badgeCount: number | null, theme: CustomTheme, }; const AnimatableBadge = Animatable.createAnimatableComponent(Badge); /** * Component used to render a small dashboard item */ class SmallDashboardItem extends React.Component { itemSize: number; constructor(props: PropsType) { super(props); this.itemSize = Dimensions.get('window').width / 8; } shouldComponentUpdate(nextProps: PropsType): boolean { const {props} = this; return ( nextProps.theme.dark !== props.theme.dark || nextProps.badgeCount !== props.badgeCount ); } render(): React.Node { const {props} = this; return ( {props.badgeCount != null && props.badgeCount > 0 ? ( {props.badgeCount} ) : null} ); } } export default withTheme(SmallDashboardItem);