Fix eslint errors

This commit is contained in:
Arnaud Vergnet 2020-08-10 12:46:26 +02:00
parent 0356736d14
commit 6441865b09
2 changed files with 20 additions and 22 deletions

View file

@ -45,18 +45,18 @@ class FeedItem extends React.Component<PropsType> {
}; };
render(): React.Node { render(): React.Node {
const {props} = this; const {item, height, navigation} = this.props;
const {item} = props; const image = item.image !== '' && item.image != null ? item.image : null;
const hasImage = item.image !== '' && item.image != null;
const pageSource: NewsSourceType = NewsSourcesConstants[item.page_id]; const pageSource: NewsSourceType = NewsSourcesConstants[item.page_id];
const cardMargin = 10; const cardMargin = 10;
const cardHeight = props.height - 2 * cardMargin; const cardHeight = height - 2 * cardMargin;
const imageSize = 250; const imageSize = 250;
const titleHeight = 80; const titleHeight = 80;
const actionsHeight = 60; const actionsHeight = 60;
const textHeight = hasImage const textHeight =
? cardHeight - titleHeight - actionsHeight - imageSize image != null
: cardHeight - titleHeight - actionsHeight; ? cardHeight - titleHeight - actionsHeight - imageSize
: cardHeight - titleHeight - actionsHeight;
return ( return (
<Card <Card
style={{ style={{
@ -80,17 +80,17 @@ class FeedItem extends React.Component<PropsType> {
)} )}
style={{height: titleHeight}} style={{height: titleHeight}}
/> />
{hasImage ? ( {image != null ? (
<View style={{marginLeft: 'auto', marginRight: 'auto'}}> <ImageGalleryButton
<ImageGalleryButton navigation={navigation}
navigation={props.navigation} images={[{url: image}]}
images={[{url: item.image}]} style={{
style={{ width: imageSize,
width: imageSize, height: imageSize,
height: imageSize, marginLeft: 'auto',
}} marginRight: 'auto',
/> }}
</View> />
) : null} ) : null}
<Card.Content> <Card.Content>
{item.message !== undefined ? ( {item.message !== undefined ? (

View file

@ -1,16 +1,14 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {TouchableRipple, withTheme} from 'react-native-paper'; import {TouchableRipple} from 'react-native-paper';
import {StackNavigationProp} from '@react-navigation/stack'; import {StackNavigationProp} from '@react-navigation/stack';
import {Image} from 'react-native-animatable'; import {Image} from 'react-native-animatable';
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
import type {CustomThemeType} from '../../managers/ThemeManager';
type PropsType = { type PropsType = {
navigation: StackNavigationProp, navigation: StackNavigationProp,
images: Array<{url: string}>, images: Array<{url: string}>,
theme: CustomThemeType,
style: ViewStyleProp, style: ViewStyleProp,
}; };
@ -37,4 +35,4 @@ class ImageGalleryButton extends React.Component<PropsType> {
} }
} }
export default withTheme(ImageGalleryButton); export default ImageGalleryButton;