import React from 'react';
import PropTypes from 'prop-types';
import Icon from 'stremio-icons/dom';
import colors from 'stremio-colors';
import styles from './styles';
const renderLogo = (logo, sourceName) => {
if (logo) {
return (
);
}
return (
{sourceName}
);
}
const renderTitle = (title) => {
if (title.length === 0) {
return null;
}
return (
{title}
);
}
const getClassName = (isFree, isSubscription, title, subtitle) => {
if (isFree) return 'free-subtitle';
if (title.length > 0 && subtitle.length === 0 && !isSubscription) return 'with-title';
if (title.length === 0 && subtitle.length > 0) return 'with-subtitle';
return 'text-container';
}
const renderSubtitle = (isFree, isSubscription, subtitle) => {
if (isFree) {
return (
FREE
);
}
if (isSubscription) {
return (
SUBSCRIPTION
);
}
if (subtitle) {
return (
{subtitle}
);
}
return null;
}
const renderProgress = (progress) => {
if (progress <= 0) {
return null;
}
return (
);
}
const Stream = (props) => {
return (
{renderLogo(props.logo, props.sourceName)}
{renderTitle(props.title)}
{renderSubtitle(props.isFree, props.isSubscription, props.subtitle)}
{renderProgress(props.progress)}
);
}
Stream.propTypes = {
logo: PropTypes.string.isRequired,
sourceName: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
subtitle: PropTypes.string.isRequired,
isFree: PropTypes.bool.isRequired,
isSubscription: PropTypes.bool.isRequired,
progress: PropTypes.number.isRequired,
play: PropTypes.func
};
Stream.defaultProps = {
logo: '',
sourceName: '',
title: '',
subtitle: '',
isFree: false,
isSubscription: false,
progress: 0
};
export default Stream;