Skip to content

Commit 3ccb05b

Browse files
author
akhenda
committed
perf(images): start using react-native-fast-image for images
1 parent e4fa2a1 commit 3ccb05b

File tree

14 files changed

+97
-70
lines changed

14 files changed

+97
-70
lines changed

android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ android {
159159
}
160160

161161
dependencies {
162+
implementation project(':react-native-fast-image')
162163
implementation project(':react-native-vector-icons')
163164
implementation project(':react-native-android-location-enabler')
164165
implementation project(':react-native-sentry')

android/app/src/main/java/com/wapi/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.facebook.react.ReactApplication;
6+
import com.dylanvann.fastimage.FastImageViewPackage;
67
import com.oblador.vectoricons.VectorIconsPackage;
78
import com.avishayil.rnrestart.ReactNativeRestartPackage;
89
import com.heanoria.library.reactnative.locationenabler.RNAndroidLocationEnablerPackage;
@@ -33,6 +34,7 @@ public boolean getUseDeveloperSupport() {
3334
protected List<ReactPackage> getPackages() {
3435
return Arrays.<ReactPackage>asList(
3536
new MainReactPackage(),
37+
new FastImageViewPackage(),
3638
new VectorIconsPackage(),
3739
new RNAndroidLocationEnablerPackage(),
3840
new RNSentryPackage(),

android/settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
rootProject.name = 'WAPI'
22

33

4+
include ':react-native-fast-image'
5+
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
6+
47
include ':react-native-vector-icons'
58
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
69

ios/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ target 'WAPI' do
3838
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
3939
pod 'SentryReactNative', :path => '../node_modules/react-native-sentry/SentryReactNative.podspec'
4040
pod 'ReactNativeExceptionHandler', :podspec => '../node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.podspec'
41+
pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image'
4142

4243
target 'WAPITests' do
4344
inherit! :search_paths

ios/Podfile.lock

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ PODS:
33
- BVLinearGradient (2.4.0):
44
- React
55
- DoubleConversion (1.1.5)
6-
- Folly (2016.10.31.00):
6+
- FLAnimatedImage (1.0.12)
7+
- Folly (2016.09.26.00):
78
- boost-for-react-native
89
- DoubleConversion
910
- glog
@@ -21,55 +22,60 @@ PODS:
2122
- RadarSDK (1.3.12)
2223
- RCTRestart (0.0.6):
2324
- React
24-
- React (0.56.0):
25-
- React/Core (= 0.56.0)
26-
- React/Core (0.56.0):
27-
- yoga (= 0.56.0.React)
28-
- React/CxxBridge (0.56.0):
29-
- Folly (= 2016.10.31.00)
25+
- React (0.55.4):
26+
- React/Core (= 0.55.4)
27+
- react-native-fast-image (4.0.14):
28+
- FLAnimatedImage
29+
- React
30+
- SDWebImage/Core
31+
- SDWebImage/GIF
32+
- React/Core (0.55.4):
33+
- yoga (= 0.55.4.React)
34+
- React/CxxBridge (0.55.4):
35+
- Folly (= 2016.09.26.00)
3036
- React/Core
3137
- React/cxxreact
32-
- React/cxxreact (0.56.0):
38+
- React/cxxreact (0.55.4):
3339
- boost-for-react-native (= 1.63.0)
34-
- Folly (= 2016.10.31.00)
40+
- Folly (= 2016.09.26.00)
3541
- React/jschelpers
3642
- React/jsinspector
37-
- React/DevSupport (0.56.0):
43+
- React/DevSupport (0.55.4):
3844
- React/Core
3945
- React/RCTWebSocket
40-
- React/fishhook (0.56.0)
41-
- React/jschelpers (0.56.0):
42-
- Folly (= 2016.10.31.00)
46+
- React/fishhook (0.55.4)
47+
- React/jschelpers (0.55.4):
48+
- Folly (= 2016.09.26.00)
4349
- React/PrivateDatabase
44-
- React/jsinspector (0.56.0)
45-
- React/PrivateDatabase (0.56.0)
46-
- React/RCTActionSheet (0.56.0):
50+
- React/jsinspector (0.55.4)
51+
- React/PrivateDatabase (0.55.4)
52+
- React/RCTActionSheet (0.55.4):
4753
- React/Core
48-
- React/RCTAnimation (0.56.0):
54+
- React/RCTAnimation (0.55.4):
4955
- React/Core
50-
- React/RCTBlob (0.56.0):
56+
- React/RCTBlob (0.55.4):
5157
- React/Core
52-
- React/RCTCameraRoll (0.56.0):
58+
- React/RCTCameraRoll (0.55.4):
5359
- React/Core
5460
- React/RCTImage
55-
- React/RCTGeolocation (0.56.0):
61+
- React/RCTGeolocation (0.55.4):
5662
- React/Core
57-
- React/RCTImage (0.56.0):
63+
- React/RCTImage (0.55.4):
5864
- React/Core
5965
- React/RCTNetwork
60-
- React/RCTLinkingIOS (0.56.0):
66+
- React/RCTLinkingIOS (0.55.4):
6167
- React/Core
62-
- React/RCTNetwork (0.56.0):
68+
- React/RCTNetwork (0.55.4):
6369
- React/Core
64-
- React/RCTPushNotification (0.56.0):
70+
- React/RCTPushNotification (0.55.4):
6571
- React/Core
66-
- React/RCTSettings (0.56.0):
72+
- React/RCTSettings (0.55.4):
6773
- React/Core
68-
- React/RCTText (0.56.0):
74+
- React/RCTText (0.55.4):
6975
- React/Core
70-
- React/RCTVibration (0.56.0):
76+
- React/RCTVibration (0.55.4):
7177
- React/Core
72-
- React/RCTWebSocket (0.56.0):
78+
- React/RCTWebSocket (0.55.4):
7379
- React/Core
7480
- React/fishhook
7581
- React/RCTBlob
@@ -79,6 +85,10 @@ PODS:
7985
- React
8086
- RNVectorIcons (4.5.0):
8187
- React
88+
- SDWebImage/Core (4.4.2)
89+
- SDWebImage/GIF (4.4.2):
90+
- FLAnimatedImage (~> 1.0)
91+
- SDWebImage/Core
8292
- Sentry (3.12.4):
8393
- Sentry/Core (= 3.12.4)
8494
- Sentry/KSCrash (= 3.12.4)
@@ -89,7 +99,7 @@ PODS:
8999
- React
90100
- Sentry (~> 3.12.4)
91101
- Sentry/KSCrash (~> 3.12.4)
92-
- yoga (0.56.0.React)
102+
- yoga (0.55.4.React)
93103

94104
DEPENDENCIES:
95105
- BVLinearGradient (from `../node_modules/react-native-linear-gradient`)
@@ -98,6 +108,7 @@ DEPENDENCIES:
98108
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
99109
- RadarSDK (~> 1.3.0)
100110
- RCTRestart (from `../node_modules/react-native-restart/ios`)
111+
- react-native-fast-image (from `../node_modules/react-native-fast-image`)
101112
- React/Core (from `../node_modules/react-native`)
102113
- React/CxxBridge (from `../node_modules/react-native`)
103114
- React/DevSupport (from `../node_modules/react-native`)
@@ -131,6 +142,8 @@ EXTERNAL SOURCES:
131142
:path: ../node_modules/react-native-restart/ios
132143
React:
133144
:path: ../node_modules/react-native
145+
react-native-fast-image:
146+
:path: ../node_modules/react-native-fast-image
134147
ReactNativeExceptionHandler:
135148
:podspec: ../node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.podspec
136149
RNFS:
@@ -145,20 +158,23 @@ EXTERNAL SOURCES:
145158
SPEC CHECKSUMS:
146159
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
147160
BVLinearGradient: 4b3f3bdf1ac1a52a5ef5e65c9585d793a7c3f825
148-
DoubleConversion: a9706f16e388b53ff12cca34473428ee29746a26
149-
Folly: c89ac2d5c6ab169cd7397ef27485c44f35f742c7
150-
glog: b3b0330915eccea41c5cc9731a77cf564a9be5ea
161+
DoubleConversion: e22e0762848812a87afd67ffda3998d9ef29170c
162+
FLAnimatedImage: 4a0b56255d9b05f18b6dd7ee06871be5d3b89e31
163+
Folly: 211775e49d8da0ca658aebc8eab89d642935755c
164+
glog: 1de0bb937dccdc981596d3b5825ebfb765017ded
151165
KSCrash: 5394936f41e5c1ef7b79cf79b30d53299b0c160e
152166
RadarSDK: e73cfee062b9ab25ce540a42e2556a98cdc0276f
153167
RCTRestart: 2f9ddcfd9abb887f123b6580cec64d72fb6cccaa
154-
React: 1fe0eb13d90b625d94c3b117c274dcfd2e760e11
168+
React: aa2040dbb6f317b95314968021bd2888816e03d5
169+
react-native-fast-image: cba3d9bf9c2cf8ddb643d887a686c53a5dd90a2c
155170
ReactNativeExceptionHandler: 040b33d72849a0aa862d1dcb54008ccef77a935e
156171
RNFS: bbb1a64eb245763daf34aea86f97c97c4e85f74c
157172
RNVectorIcons: c0dbfbf6068fefa240c37b0f71bd03b45dddac44
173+
SDWebImage: 624d6e296c69b244bcede364c72ae0430ac14681
158174
Sentry: 7d3ea7176e5184e9c35c12a5825905345807e8c1
159175
SentryReactNative: 787a08161d641dde91dd36d4c8e76f9b0ba4fc84
160-
yoga: b1ce48b6cf950b98deae82838f5173ea7cf89e85
176+
yoga: a23273df0088bf7f2bb7e5d7b00044ea57a2a54a
161177

162-
PODFILE CHECKSUM: ed7c5f98dffbb4b6381905a2c8bcc45b3cb6e870
178+
PODFILE CHECKSUM: 10e6d2191ae45343eba64d0b71d5e8f11757e583
163179

164180
COCOAPODS: 1.4.0

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"react-native-config": "^0.11.5",
5454
"react-native-datepicker": "^1.7.2",
5555
"react-native-exception-handler": "^2.9.0",
56+
"react-native-fast-image": "^4.0.14",
5657
"react-native-gifted-form": "^0.1.1",
5758
"react-native-google-static-map": "^0.1.12",
5859
"react-native-image-zoom-viewer": "^2.2.13",

src/components/Category.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { TouchableOpacity } from 'react-native';
44
import { View, Text } from 'native-base';
5-
import CacheableImage from 'react-native-cacheable-image';
5+
import FastImage from 'react-native-fast-image';
66

77
import styles from './styles/CategoryStyles';
88

99

1010
const Category = ({
11-
image, title, descritption, titleSize, fallbackImage, onSelectCategory,
11+
image: uri, title, descritption, titleSize, onSelectCategory,
1212
}) => {
1313
return (
1414
<TouchableOpacity style={styles.category} onPress={onSelectCategory}>
1515
<View style={styles.categoryImageContainer}>
16-
<CacheableImage
17-
resizeMode="cover"
18-
source={{ uri: image }}
16+
<FastImage
1917
style={styles.categoryImage}
20-
defaultSource={fallbackImage}
18+
source={{ uri, priority: FastImage.priority.high }}
19+
resizeMode={FastImage.resizeMode.cover}
2120
/>
2221
</View>
2322
<View style={styles.textContainer}>

src/components/ListingItem.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { View, Text, Icon } from 'native-base';
55
import geodist from 'geodist';
66
import StarRating from 'react-native-star-rating';
77
import { Actions } from 'react-native-router-flux';
8-
import CacheableImage from 'react-native-cacheable-image';
8+
import FastImage from 'react-native-fast-image';
99

1010
import { openStatus } from 'src/utils/businessHours';
1111

@@ -37,11 +37,7 @@ const ListingItem = (props) => {
3737
style={styles.large}
3838
onPress={() => Actions.listing({ id, onLeftButton: Actions.pop })}
3939
>
40-
<CacheableImage
41-
resizeMode="cover"
42-
style={styles.largeImage}
43-
source={{ uri: featured_image_url[0] }}
44-
/>
40+
<FastImage style={styles.largeImage} source={{ uri: featured_image_url[0] }} />
4541
<View style={styles.largeImageMask} />
4642
<View style={styles.largeRating}>
4743
<Text style={styles.largeRatingValue}>{listing_rate}</Text>
@@ -83,11 +79,7 @@ const ListingItem = (props) => {
8379
onPress={() => Actions.listing({ id, onLeftButton: Actions.pop })}
8480
>
8581
<View style={styles.compactImageContainer}>
86-
<CacheableImage
87-
resizeMode="cover"
88-
style={styles.compactImage}
89-
source={{ uri: featured_image_url[0] }}
90-
/>
82+
<FastImage style={styles.compactImage} source={{ uri: featured_image_url[0] }} />
9183
</View>
9284
<View style={styles.compactContent}>
9385
<Text style={styles.compactTitle} numberOfLines={1}>{title.rendered}</Text>

src/containers/ListingDetailsScreen.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import ImageViewer from 'react-native-image-zoom-viewer';
88
import GoogleStaticMap from 'react-native-google-static-map';
99
import { web, phonecall, email } from 'react-native-communications';
1010
import {
11-
View, FlatList, TouchableOpacity, ActivityIndicator, Modal, Image,
11+
View, FlatList, TouchableOpacity, ActivityIndicator, Modal,
1212
} from 'react-native';
1313
import {
1414
Container, Text, Fab, Icon,
1515
} from 'native-base';
16+
import FastImage from 'react-native-fast-image';
1617

1718
import { stripHTML } from 'src/utils/strip';
1819
import returnValidURL from 'src/utils/validURL';
@@ -178,11 +179,7 @@ class ListingDetailsScreen extends Component {
178179
renderItem={({ item, index }) => {
179180
return (
180181
<TouchableOpacity onPress={() => this.toggleModal(index)}>
181-
<Image
182-
resizeMode="cover"
183-
source={{ uri: item[0] }}
184-
style={styles.galleryItem}
185-
/>
182+
<FastImage style={styles.galleryItem} source={{ uri: item[0] }} />
186183
</TouchableOpacity>
187184
);
188185
}}

0 commit comments

Comments
 (0)