Browse Source

Fix eslint errors

Arnaud Vergnet 3 years ago
parent
commit
6441865b09
2 changed files with 20 additions and 22 deletions
  1. 18
    18
      src/components/Home/FeedItem.js
  2. 2
    4
      src/components/Media/ImageGalleryButton.js

+ 18
- 18
src/components/Home/FeedItem.js View File

45
   };
45
   };
46
 
46
 
47
   render(): React.Node {
47
   render(): React.Node {
48
-    const {props} = this;
49
-    const {item} = props;
50
-    const hasImage = item.image !== '' && item.image != null;
48
+    const {item, height, navigation} = this.props;
49
+    const image = item.image !== '' && item.image != null ? item.image : null;
51
     const pageSource: NewsSourceType = NewsSourcesConstants[item.page_id];
50
     const pageSource: NewsSourceType = NewsSourcesConstants[item.page_id];
52
     const cardMargin = 10;
51
     const cardMargin = 10;
53
-    const cardHeight = props.height - 2 * cardMargin;
52
+    const cardHeight = height - 2 * cardMargin;
54
     const imageSize = 250;
53
     const imageSize = 250;
55
     const titleHeight = 80;
54
     const titleHeight = 80;
56
     const actionsHeight = 60;
55
     const actionsHeight = 60;
57
-    const textHeight = hasImage
58
-      ? cardHeight - titleHeight - actionsHeight - imageSize
59
-      : cardHeight - titleHeight - actionsHeight;
56
+    const textHeight =
57
+      image != null
58
+        ? cardHeight - titleHeight - actionsHeight - imageSize
59
+        : cardHeight - titleHeight - actionsHeight;
60
     return (
60
     return (
61
       <Card
61
       <Card
62
         style={{
62
         style={{
80
               )}
80
               )}
81
               style={{height: titleHeight}}
81
               style={{height: titleHeight}}
82
             />
82
             />
83
-            {hasImage ? (
84
-              <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
85
-                <ImageGalleryButton
86
-                  navigation={props.navigation}
87
-                  images={[{url: item.image}]}
88
-                  style={{
89
-                    width: imageSize,
90
-                    height: imageSize,
91
-                  }}
92
-                />
93
-              </View>
83
+            {image != null ? (
84
+              <ImageGalleryButton
85
+                navigation={navigation}
86
+                images={[{url: image}]}
87
+                style={{
88
+                  width: imageSize,
89
+                  height: imageSize,
90
+                  marginLeft: 'auto',
91
+                  marginRight: 'auto',
92
+                }}
93
+              />
94
             ) : null}
94
             ) : null}
95
             <Card.Content>
95
             <Card.Content>
96
               {item.message !== undefined ? (
96
               {item.message !== undefined ? (

+ 2
- 4
src/components/Media/ImageGalleryButton.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import * as React from 'react';
3
 import * as React from 'react';
4
-import {TouchableRipple, withTheme} from 'react-native-paper';
4
+import {TouchableRipple} from 'react-native-paper';
5
 import {StackNavigationProp} from '@react-navigation/stack';
5
 import {StackNavigationProp} from '@react-navigation/stack';
6
 import {Image} from 'react-native-animatable';
6
 import {Image} from 'react-native-animatable';
7
 import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
7
 import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
8
-import type {CustomThemeType} from '../../managers/ThemeManager';
9
 
8
 
10
 type PropsType = {
9
 type PropsType = {
11
   navigation: StackNavigationProp,
10
   navigation: StackNavigationProp,
12
   images: Array<{url: string}>,
11
   images: Array<{url: string}>,
13
-  theme: CustomThemeType,
14
   style: ViewStyleProp,
12
   style: ViewStyleProp,
15
 };
13
 };
16
 
14
 
37
   }
35
   }
38
 }
36
 }
39
 
37
 
40
-export default withTheme(ImageGalleryButton);
38
+export default ImageGalleryButton;

Loading…
Cancel
Save