mirror of https://github.com/Radarr/Radarr
159 lines
4.2 KiB
JavaScript
159 lines
4.2 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import TextTruncate from 'react-text-truncate';
|
|
import dimensions from 'Styles/Variables/dimensions';
|
|
import fonts from 'Styles/Variables/fonts';
|
|
import MoviePoster from 'Movie/MoviePoster';
|
|
import Link from 'Components/Link/Link';
|
|
import AddNewMovieModal from 'AddMovie/AddNewMovie/AddNewMovieModal';
|
|
import styles from './AddListMovieOverview.css';
|
|
|
|
const columnPadding = parseInt(dimensions.movieIndexColumnPadding);
|
|
const columnPaddingSmallScreen = parseInt(dimensions.movieIndexColumnPaddingSmallScreen);
|
|
const defaultFontSize = parseInt(fonts.defaultFontSize);
|
|
const lineHeight = parseFloat(fonts.lineHeight);
|
|
|
|
// Hardcoded height beased on line-height of 32 + bottom margin of 10.
|
|
// Less side-effecty than using react-measure.
|
|
const titleRowHeight = 42;
|
|
|
|
function getContentHeight(rowHeight, isSmallScreen) {
|
|
const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding;
|
|
|
|
return rowHeight - padding;
|
|
}
|
|
|
|
class AddListMovieOverview extends Component {
|
|
|
|
//
|
|
// Lifecycle
|
|
|
|
constructor(props, context) {
|
|
super(props, context);
|
|
|
|
this.state = {
|
|
isNewAddMovieModalOpen: false
|
|
};
|
|
}
|
|
|
|
//
|
|
// Listeners
|
|
|
|
onPress = () => {
|
|
this.setState({ isNewAddMovieModalOpen: true });
|
|
}
|
|
|
|
onAddMovieModalClose = () => {
|
|
this.setState({ isNewAddMovieModalOpen: false });
|
|
}
|
|
|
|
//
|
|
// Render
|
|
|
|
render() {
|
|
const {
|
|
style,
|
|
tmdbId,
|
|
title,
|
|
titleSlug,
|
|
folder,
|
|
year,
|
|
overview,
|
|
images,
|
|
posterWidth,
|
|
posterHeight,
|
|
rowHeight,
|
|
isSmallScreen,
|
|
isExistingMovie
|
|
} = this.props;
|
|
|
|
const {
|
|
isNewAddMovieModalOpen
|
|
} = this.state;
|
|
|
|
const elementStyle = {
|
|
width: `${posterWidth}px`,
|
|
height: `${posterHeight}px`
|
|
};
|
|
|
|
const linkProps = isExistingMovie ? { to: `/movie/${titleSlug}` } : { onPress: this.onPress };
|
|
|
|
const contentHeight = getContentHeight(rowHeight, isSmallScreen);
|
|
const overviewHeight = contentHeight - titleRowHeight;
|
|
|
|
return (
|
|
<div className={styles.container} style={style}>
|
|
<Link
|
|
className={styles.content}
|
|
{...linkProps}
|
|
>
|
|
<div className={styles.poster}>
|
|
<div className={styles.posterContainer}>
|
|
|
|
<MoviePoster
|
|
className={styles.poster}
|
|
style={elementStyle}
|
|
images={images}
|
|
size={250}
|
|
lazy={false}
|
|
overflow={true}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div className={styles.info} style={{ maxHeight: contentHeight }}>
|
|
<div className={styles.titleRow}>
|
|
{title} ({year})
|
|
</div>
|
|
|
|
<div className={styles.details}>
|
|
<TextTruncate
|
|
line={Math.floor(overviewHeight / (defaultFontSize * lineHeight))}
|
|
text={overview}
|
|
/>
|
|
|
|
</div>
|
|
</div>
|
|
</Link>
|
|
|
|
<AddNewMovieModal
|
|
isOpen={isNewAddMovieModalOpen && !isExistingMovie}
|
|
tmdbId={tmdbId}
|
|
title={title}
|
|
year={year}
|
|
overview={overview}
|
|
folder={folder}
|
|
images={images}
|
|
onModalClose={this.onAddMovieModalClose}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
AddListMovieOverview.propTypes = {
|
|
style: PropTypes.object.isRequired,
|
|
tmdbId: PropTypes.number.isRequired,
|
|
title: PropTypes.string.isRequired,
|
|
folder: PropTypes.string.isRequired,
|
|
year: PropTypes.number.isRequired,
|
|
overview: PropTypes.string.isRequired,
|
|
monitored: PropTypes.bool.isRequired,
|
|
status: PropTypes.string.isRequired,
|
|
titleSlug: PropTypes.string.isRequired,
|
|
images: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
posterWidth: PropTypes.number.isRequired,
|
|
posterHeight: PropTypes.number.isRequired,
|
|
rowHeight: PropTypes.number.isRequired,
|
|
overviewOptions: PropTypes.object.isRequired,
|
|
showRelativeDates: PropTypes.bool.isRequired,
|
|
shortDateFormat: PropTypes.string.isRequired,
|
|
longDateFormat: PropTypes.string.isRequired,
|
|
timeFormat: PropTypes.string.isRequired,
|
|
isSmallScreen: PropTypes.bool.isRequired,
|
|
isExistingMovie: PropTypes.bool.isRequired,
|
|
isExclusionMovie: PropTypes.bool.isRequired
|
|
};
|
|
|
|
export default AddListMovieOverview;
|