├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ └── ci.yml ├── .gitignore ├── .node-version ├── .prettierignore ├── .yarn └── releases │ └── yarn-1.22.10.js ├── .yarnrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── RNFastImage.podspec ├── ReactNativeFastImageExample ├── .buckconfig ├── .editorconfig ├── .eslintrc.js ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── __tests__ │ └── App-test.tsx ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── reactnativefastimageexample │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── reactnativefastimageexample │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ │ └── xml │ │ │ └── network_security_config.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── Podfile │ ├── ReactNativeFastImageExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── ReactNativeFastImageExample.xcscheme │ ├── ReactNativeFastImageExample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── ReactNativeFastImageExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ └── ReactNativeFastImageExampleTests │ │ ├── Info.plist │ │ └── ReactNativeFastImageExampleTests.m ├── metro.config.js ├── package.json ├── src │ ├── AutoSizeExample.tsx │ ├── BorderRadiusExample.tsx │ ├── BulletText.tsx │ ├── Button.tsx │ ├── DefaultImageGrid.tsx │ ├── ETAGExample.tsx │ ├── FastImageExamples.tsx │ ├── FastImageGrid.tsx │ ├── FeatureText.tsx │ ├── GifExample.tsx │ ├── Icon.tsx │ ├── ImageGrid.tsx │ ├── LocalImagesExample.tsx │ ├── PreloadExample.tsx │ ├── PriorityExample.tsx │ ├── ProgressExample.tsx │ ├── ResizeModeExample.tsx │ ├── Section.tsx │ ├── SectionFlex.tsx │ ├── StatusBarUnderlay.tsx │ ├── TintColorExample.tsx │ ├── images │ │ ├── fields.jpg │ │ ├── fields.ts │ │ ├── fields.webp │ │ ├── jellyfish.gif │ │ ├── jellyfish.webp │ │ └── logo.png │ ├── index.tsx │ └── useCacheBust.tsx ├── tsconfig.json └── yarn.lock ├── ReactNativeFastImageExampleServer ├── index.js ├── package.json ├── pictures │ ├── cat.jpg │ ├── cat2.jpg │ ├── fields.jpg │ ├── forest.jpg │ ├── harbor.jpg │ ├── jellyfish.gif │ ├── jellyfish.webp │ └── plankton.gif └── yarn.lock ├── android ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── objectbox-models │ └── default.json └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── dylanvann │ └── fastimage │ ├── FastImageCacheControl.java │ ├── FastImageGlideModule.java │ ├── FastImageOkHttpProgressGlideModule.java │ ├── FastImageProgressListener.java │ ├── FastImageRequestListener.java │ ├── FastImageSource.java │ ├── FastImageViewConverter.java │ ├── FastImageViewManager.java │ ├── FastImageViewModule.java │ ├── FastImageViewPackage.java │ ├── FastImageViewWithUrl.java │ └── custom │ ├── EtagCallback.java │ ├── EtagRequester.java │ ├── SharedOkHttpClient.java │ └── persistence │ ├── EntityEtagCache.java │ └── ObjectBox.java ├── babel.config.js ├── docs ├── app-glide-module.md ├── assets │ ├── priority.gif │ └── scroll.gif ├── development.md ├── how-is-caching-handled.md ├── other-android-versions.md ├── roadmap.md └── troubleshooting.md ├── ios ├── FastImage.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── FastImage-tvOS.xcscheme └── FastImage │ ├── FFFastImageSource.h │ ├── FFFastImageSource.m │ ├── FFFastImageView.h │ ├── FFFastImageView.m │ ├── FFFastImageViewManager.h │ ├── FFFastImageViewManager.m │ ├── RCTConvert+FFFastImage.h │ └── RCTConvert+FFFastImage.m ├── package.json ├── src ├── __snapshots__ │ └── index.test.tsx.snap ├── index.js.flow ├── index.test.tsx └── index.tsx ├── tsconfig.json └── yarn.lock /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior if possible, or a link to a reproduction repo: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Dependency versions** 27 | 28 | - React Native version: 29 | - React version: 30 | - React Native Fast Image version: 31 | 32 | **Note:** if these are not the latest versions of each I recommend updating as extra effort will not be taken to be backwards compatible, and updating might resolving your issue. 33 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | on: [push, pull_request] 3 | jobs: 4 | build: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v2 8 | - uses: actions/setup-node@v2 9 | - run: yarn --frozen-lockfile 10 | - run: yarn build 11 | - run: yarn test --coverage 12 | - if: github.event.repository.fork == false && github.event_name != 'pull_request' 13 | run: yarn dv-scripts ci 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 17 | - uses: codecov/codecov-action@v2 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # CocoaPods 26 | Podfile.lock 27 | Pods 28 | 29 | # Android/IJ 30 | # 31 | .idea 32 | *.iml 33 | .gradle 34 | local.properties 35 | 36 | # node.js 37 | # 38 | node_modules/ 39 | npm-debug.log 40 | lib/android/src/main/gen 41 | example/android/app/src/main/gen 42 | 43 | # build 44 | react-native-fast-image-*.tgz 45 | dist/ 46 | 47 | # coverage reports 48 | coverage 49 | 50 | # TypeScript incremental compilation cache 51 | *.tsbuildinfo 52 | 53 | ReactNativeFastImageExampleServer/catswap-cdn.sh -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | v15.2.0 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | /ReactNativeFastImageExample/ 2 | /ReactNativeFastImageExampleServer/ 3 | node_modules 4 | coverage 5 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | lastUpdateCheck 1583099103340 6 | save-prefix "^" 7 | yarn-path ".yarn/releases/yarn-1.22.10.js" 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Dylan Vann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 🚩 FastImage 3 |

4 | 5 |
6 | 7 | Performant React Native image component. 8 | 9 | [![Version][version-badge]][package] 10 | [![Downloads][downloads-badge]][npmtrends] 11 | [![Build Status][build-badge]][build] 12 | [![Code Coverage][coverage-badge]][coverage] 13 | 14 | [![Watch on GitHub][github-watch-badge]][github-watch] 15 | [![Star on GitHub][github-star-badge]][github-star] 16 | [![Tweet][twitter-badge]][twitter] 17 | 18 |
19 | 20 |

21 | 22 | 27 | 28 | 29 | 34 | 35 |
36 | FastImage example app. 37 |

38 | 39 | React Native's `Image` component handles image caching like browsers 40 | for the most part. 41 | If the server is returning proper cache control 42 | headers for images you'll generally get the sort of built in 43 | caching behavior you'd have in a browser. 44 | Even so many people have noticed: 45 | 46 | - Flickering. 47 | - Cache misses. 48 | - Low performance loading from cache. 49 | - Low performance in general. 50 | 51 | `FastImage` is an `Image` replacement that solves these issues. 52 | `FastImage` is a wrapper around 53 | [SDWebImage (iOS)](https://github.com/rs/SDWebImage) 54 | and 55 | [Glide (Android)](https://github.com/bumptech/glide). 56 | 57 | ## Features 58 | 59 | - [x] Aggressively cache images. 60 | - [x] Add authorization headers. 61 | - [x] Prioritize images. 62 | - [x] Preload images. 63 | - [x] GIF support. 64 | - [x] Border radius. 65 | 66 | ### Fork features 67 | 68 | This fast-image fork comes with a few more features: 69 | 70 | - [x] Image refreshing (via it's ref's `.refresh()` function) 71 | - [x] ETag support 72 | - [x] Antialiasing for borderRadius on Android 73 | - [x] A bit faster re-renders 74 | 75 | ## Installation 76 | 77 | **Note: You must be using React Native 0.60.0 or higher to use the most recent version of `react-native-fast-image`.** 78 | 79 | ```bash 80 | yarn add @cuvent/react-native-fast-image 81 | // OR: npm i @cuvent/react-native-fast-image 82 | ``` 83 | 84 | ### Extra step for android 85 | 86 | For ETag caching to work we need to persist the ETag with the urls. For that we use ObjectBox. 87 | To enable ObjectBox add the following to your `MainApplication.java`: 88 | 89 | ```java 90 | import com.dylanvann.fastimage.custom.persistence.ObjectBox; 91 | // ... 92 | 93 | public class MainApplication extends Application implements ReactApplication { 94 | @Override 95 | public void onCreate() { 96 | super.onCreate(); 97 | ObjectBox.init(this); // <- ⚠️ Add this 98 | } 99 | 100 | // ... 101 | } 102 | ``` 103 | 104 | ## Usage 105 | 106 | ```jsx 107 | import FastImage from '@cuvent/react-native-fast-image' 108 | 109 | const YourImage = () => ( 110 | 119 | ) 120 | ``` 121 | 122 | ## Are you using Glide already using an AppGlideModule? 123 | 124 | - [Are you using Glide already using an AppGlideModule?](docs/app-glide-module.md) (you might have problems if you don't read this) 125 | 126 | ## Are you using Proguard? 127 | 128 | If you use Proguard you will need to add these lines to `android/app/proguard-rules.pro`: 129 | 130 | ``` 131 | -keep public class com.dylanvann.fastimage.* {*;} 132 | -keep public class com.dylanvann.fastimage.** {*;} 133 | -keep public class * implements com.bumptech.glide.module.GlideModule 134 | -keep public class * extends com.bumptech.glide.module.AppGlideModule 135 | -keep public enum com.bumptech.glide.load.ImageHeaderParser$** { 136 | **[] $VALUES; 137 | public *; 138 | } 139 | ``` 140 | 141 | ## Properties 142 | 143 | ### `source?: object` 144 | 145 | Source for the remote image to load. 146 | 147 | --- 148 | 149 | ### `source.uri?: string` 150 | 151 | Remote url to load the image from. e.g. `'https://facebook.github.io/react/img/logo_og.png'`. 152 | 153 | --- 154 | 155 | ### `source.headers?: object` 156 | 157 | Headers to load the image with. e.g. `{ Authorization: 'someAuthToken' }`. 158 | 159 | --- 160 | 161 | ### `source.priority?: enum` 162 | 163 | - `FastImage.priority.low` - Low Priority. 164 | - `FastImage.priority.normal` **(Default)** - Normal Priority. 165 | - `FastImage.priority.high` - High Priority. 166 | 167 | --- 168 | 169 | ### `source.cache?: enum` 170 | 171 | - `FastImage.cacheControl.immutable` - **(Default)** - Only updates if url changes. 172 | - `FastImage.cacheControl.web` - Use headers and follow normal caching procedures. 173 | - `FastImage.cacheControl.cacheOnly` - Only show images from cache, do not make any network requests. 174 | 175 | --- 176 | 177 | ### `resizeMode?: enum` 178 | 179 | - `FastImage.resizeMode.contain` - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). 180 | - `FastImage.resizeMode.cover` **(Default)** - Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). 181 | - `FastImage.resizeMode.stretch` - Scale width and height independently, This may change the aspect ratio of the src. 182 | - `FastImage.resizeMode.center` - Do not scale the image, keep centered. 183 | 184 | --- 185 | 186 | ### `onLoadStart?: () => void` 187 | 188 | Called when the image starts to load. 189 | 190 | --- 191 | 192 | ### `onProgress?: (event) => void` 193 | 194 | Called when the image is loading. 195 | 196 | e.g. `onProgress={e => console.log(e.nativeEvent.loaded / e.nativeEvent.total)}` 197 | 198 | --- 199 | 200 | ### `onLoad?: (event) => void` 201 | 202 | Called on a successful image fetch. Called with the width and height of the loaded image. 203 | 204 | e.g. `onLoad={e => console.log(e.nativeEvent.width, e.nativeEvent.height)}` 205 | 206 | --- 207 | 208 | ### `onError?: () => void` 209 | 210 | Called on an image fetching error. 211 | 212 | --- 213 | 214 | ### `onLoadEnd?: () => void` 215 | 216 | Called when the image finishes loading, whether it was successful or an error. 217 | 218 | --- 219 | 220 | ### `style` 221 | 222 | A React Native style. Supports using `borderRadius`. 223 | 224 | --- 225 | 226 | ### `fallback: boolean` 227 | 228 | If true will fallback to using `Image`. 229 | In this case the image will still be styled and laid out the same way as `FastImage`. 230 | 231 | --- 232 | 233 | ### `tintColor?: number | string` 234 | 235 | If supplied, changes the color of all the non-transparent pixels to the given color. 236 | 237 | ## Static Methods 238 | 239 | ### `FastImage.preload: (source[]) => void` 240 | 241 | Preload images to display later. e.g. 242 | 243 | ```js 244 | FastImage.preload([ 245 | { 246 | uri: 'https://facebook.github.io/react/img/logo_og.png', 247 | headers: { Authorization: 'someAuthToken' }, 248 | }, 249 | { 250 | uri: 'https://facebook.github.io/react/img/logo_og.png', 251 | headers: { Authorization: 'someAuthToken' }, 252 | }, 253 | ]) 254 | ``` 255 | 256 | ### `FastImage.clearMemoryCache: () => Promise` 257 | 258 | Clear all images from memory cache. 259 | 260 | ### `FastImage.clearDiskCache: () => Promise` 261 | 262 | Clear all images from disk cache. 263 | 264 | ## Troubleshooting 265 | 266 | If you have any problems using this library try the steps in [troubleshooting](docs/troubleshooting.md) and see if they fix it. 267 | 268 | ## Development 269 | 270 | [Follow these instructions to get the example app running.](docs/development.md) 271 | 272 | ## Supported React Native Versions 273 | 274 | This project only aims to support the latest version of React Native.\ 275 | This simplifies the development and the testing of the project. 276 | 277 | If you require new features or bug fixes for older versions you can fork this project. 278 | 279 | ## Credits 280 | 281 | The idea for this modules came from 282 | [vovkasm's](https://github.com/vovkasm) 283 | [react-native-web-image](https://github.com/vovkasm/react-native-web-image) 284 | package. 285 | It also uses Glide and SDWebImage, but didn't have some features I needed (priority, headers). 286 | 287 | Thanks to [@mobinni](https://github.com/mobinni) for helping with the conceptualization 288 | 289 | ## Licenses 290 | 291 | - FastImage - MIT © [DylanVann](https://github.com/DylanVann) 292 | - SDWebImage - `MIT` 293 | - Glide - BSD, part MIT and Apache 2.0. See the [LICENSE](https://github.com/bumptech/glide/blob/master/license) file for details. 294 | 295 | [build-badge]: https://github.com/dylanvann/react-native-fast-image/workflows/CI/badge.svg 296 | [build]: https://github.com/DylanVann/react-native-fast-image/actions?query=workflow%3ACI 297 | [coverage-badge]: https://img.shields.io/codecov/c/github/dylanvann/react-native-fast-image.svg 298 | [coverage]: https://codecov.io/github/dylanvann/react-native-fast-image 299 | [downloads-badge]: https://img.shields.io/npm/dm/react-native-fast-image.svg 300 | [npmtrends]: http://www.npmtrends.com/react-native-fast-image 301 | [package]: https://www.npmjs.com/package/react-native-fast-image 302 | [version-badge]: https://img.shields.io/npm/v/react-native-fast-image.svg 303 | [twitter]: https://twitter.com/home?status=Check%20out%20react-native-fast-image%20by%20%40atomarranger%20https%3A//github.com/DylanVann/react-native-fast-image 304 | [twitter-badge]: https://img.shields.io/twitter/url/https/github.com/DylanVann/react-native-fast-image.svg?style=social 305 | [github-watch-badge]: https://img.shields.io/github/watchers/dylanvann/react-native-fast-image.svg?style=social 306 | [github-watch]: https://github.com/dylanvann/react-native-fast-image/watchers 307 | [github-star-badge]: https://img.shields.io/github/stars/dylanvann/react-native-fast-image.svg?style=social 308 | [github-star]: https://github.com/dylanvann/react-native-fast-image/stargazers 309 | -------------------------------------------------------------------------------- /RNFastImage.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | Pod::Spec.new do |s| 4 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 5 | 6 | s.name = "RNFastImage" 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.authors = { "Dylan Vann" => "dylan@dylanvann.com" } 10 | s.homepage = "https://github.com/DylanVann/react-native-fast-image#readme" 11 | s.license = "MIT" 12 | s.platforms = { :ios => "8.0", :tvos => "9.0" } 13 | s.framework = 'UIKit' 14 | s.requires_arc = true 15 | s.source = { :git => "https://github.com/DylanVann/react-native-fast-image.git", :tag => "v#{s.version}" } 16 | s.source_files = "ios/**/*.{h,m}" 17 | 18 | s.dependency 'React-Core' 19 | s.dependency 'SDWebImage', '~> 5.11.1' 20 | s.dependency 'SDWebImageWebPCoder', '~> 0.8.4' 21 | s.dependency 'SDWebImagePhotosPlugin' 22 | end 23 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | rules: { 5 | semi: ['error', 'never'], 6 | 'react-native/no-inline-styles': 'off', 7 | }, 8 | } 9 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | *.hprof 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | !debug.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | 59 | # CocoaPods 60 | /ios/Pods/ 61 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: false, 3 | singleQuote: true, 4 | trailingComma: 'all', 5 | tabWidth: 4, 6 | } 7 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/__tests__/App-test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native' 6 | import React from 'react' 7 | import App from '../src' 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer' 11 | 12 | it('renders correctly', () => { 13 | renderer.create() 14 | }) 15 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.reactnativefastimageexample", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.reactnativefastimageexample", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation. If none specified and 19 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is 20 | * // default. Can be overridden with ENTRY_FILE environment variable. 21 | * entryFile: "index.android.js", 22 | * 23 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 24 | * bundleCommand: "ram-bundle", 25 | * 26 | * // whether to bundle JS and assets in debug mode 27 | * bundleInDebug: false, 28 | * 29 | * // whether to bundle JS and assets in release mode 30 | * bundleInRelease: true, 31 | * 32 | * // whether to bundle JS and assets in another build variant (if configured). 33 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 34 | * // The configuration property can be in the following formats 35 | * // 'bundleIn${productFlavor}${buildType}' 36 | * // 'bundleIn${buildType}' 37 | * // bundleInFreeDebug: true, 38 | * // bundleInPaidRelease: true, 39 | * // bundleInBeta: true, 40 | * 41 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 42 | * // for example: to disable dev mode in the staging build type (if configured) 43 | * devDisabledInStaging: true, 44 | * // The configuration property can be in the following formats 45 | * // 'devDisabledIn${productFlavor}${buildType}' 46 | * // 'devDisabledIn${buildType}' 47 | * 48 | * // the root of your project, i.e. where "package.json" lives 49 | * root: "../../", 50 | * 51 | * // where to put the JS bundle asset in debug mode 52 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 53 | * 54 | * // where to put the JS bundle asset in release mode 55 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 56 | * 57 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 58 | * // require('./image.png')), in debug mode 59 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 60 | * 61 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 62 | * // require('./image.png')), in release mode 63 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 64 | * 65 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 66 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 67 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 68 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 69 | * // for example, you might want to remove it from here. 70 | * inputExcludes: ["android/**", "ios/**"], 71 | * 72 | * // override which node gets called and with what additional arguments 73 | * nodeExecutableAndArgs: ["node"], 74 | * 75 | * // supply additional arguments to the packager 76 | * extraPackagerArgs: [] 77 | * ] 78 | */ 79 | 80 | project.ext.react = [ 81 | enableHermes: true, // clean and rebuild if changing 82 | ] 83 | 84 | apply from: "../../node_modules/react-native/react.gradle" 85 | 86 | /** 87 | * Set this to true to create two separate APKs instead of one: 88 | * - An APK that only works on ARM devices 89 | * - An APK that only works on x86 devices 90 | * The advantage is the size of the APK is reduced by about 4MB. 91 | * Upload all the APKs to the Play Store and people will download 92 | * the correct one based on the CPU architecture of their device. 93 | */ 94 | def enableSeparateBuildPerCPUArchitecture = false 95 | 96 | /** 97 | * Run Proguard to shrink the Java bytecode in release builds. 98 | */ 99 | def enableProguardInReleaseBuilds = false 100 | 101 | /** 102 | * The preferred build flavor of JavaScriptCore. 103 | * 104 | * For example, to use the international variant, you can use: 105 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 106 | * 107 | * The international variant includes ICU i18n library and necessary data 108 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 109 | * give correct results when using with locales other than en-US. Note that 110 | * this variant is about 6MiB larger per architecture than default. 111 | */ 112 | def jscFlavor = 'org.webkit:android-jsc:+' 113 | 114 | /** 115 | * Whether to enable the Hermes VM. 116 | * 117 | * This should be set on project.ext.react and mirrored here. If it is not set 118 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 119 | * and the benefits of using Hermes will therefore be sharply reduced. 120 | */ 121 | def enableHermes = project.ext.react.get("enableHermes", false); 122 | 123 | /** 124 | * Architectures to build native code for in debug. 125 | */ 126 | def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") 127 | 128 | 129 | android { 130 | ndkVersion rootProject.ext.ndkVersion 131 | 132 | compileSdkVersion rootProject.ext.compileSdkVersion 133 | 134 | defaultConfig { 135 | applicationId "com.reactnativefastimageexample" 136 | minSdkVersion rootProject.ext.minSdkVersion 137 | targetSdkVersion rootProject.ext.targetSdkVersion 138 | versionCode 1 139 | versionName "1.0" 140 | } 141 | splits { 142 | abi { 143 | reset() 144 | enable enableSeparateBuildPerCPUArchitecture 145 | universalApk false // If true, also generate a universal APK 146 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 147 | } 148 | } 149 | signingConfigs { 150 | debug { 151 | storeFile file('debug.keystore') 152 | storePassword 'android' 153 | keyAlias 'androiddebugkey' 154 | keyPassword 'android' 155 | } 156 | } 157 | buildTypes { 158 | debug { 159 | signingConfig signingConfigs.debug 160 | if (nativeArchitectures) { 161 | ndk { 162 | abiFilters nativeArchitectures.split(',') 163 | } 164 | } 165 | } 166 | release { 167 | // Caution! In production, you need to generate your own keystore file. 168 | // see https://reactnative.dev/docs/signed-apk-android. 169 | signingConfig signingConfigs.debug 170 | minifyEnabled enableProguardInReleaseBuilds 171 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 172 | } 173 | } 174 | 175 | // applicationVariants are e.g. debug, release 176 | applicationVariants.all { variant -> 177 | variant.outputs.each { output -> 178 | // For each separate APK per architecture, set a unique version code as described here: 179 | // https://developer.android.com/studio/build/configure-apk-splits.html 180 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. 181 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 182 | def abi = output.getFilter(OutputFile.ABI) 183 | if (abi != null) { // null for the universal-debug, universal-release variants 184 | output.versionCodeOverride = 185 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 186 | } 187 | 188 | } 189 | } 190 | } 191 | 192 | dependencies { 193 | implementation fileTree(dir: "libs", include: ["*.jar"]) 194 | //noinspection GradleDynamicVersion 195 | implementation "com.facebook.react:react-native:+" // From node_modules 196 | 197 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 198 | 199 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 200 | exclude group:'com.facebook.fbjni' 201 | } 202 | 203 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 204 | exclude group:'com.facebook.flipper' 205 | exclude group:'com.squareup.okhttp3', module:'okhttp' 206 | } 207 | 208 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 209 | exclude group:'com.facebook.flipper' 210 | } 211 | 212 | if (enableHermes) { 213 | def hermesPath = "../../node_modules/hermes-engine/android/"; 214 | debugImplementation files(hermesPath + "hermes-debug.aar") 215 | releaseImplementation files(hermesPath + "hermes-release.aar") 216 | } else { 217 | implementation jscFlavor 218 | } 219 | 220 | implementation project(':rnfastimage') 221 | } 222 | 223 | // Run this once to be able to run the application with BUCK 224 | // puts all compile dependencies into folder libs for BUCK to use 225 | task copyDownloadableDepsToLibs(type: Copy) { 226 | from configurations.implementation 227 | into 'libs' 228 | } 229 | 230 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 231 | project.ext.vectoricons = [ 232 | iconFontNames: [ 'Ionicons.ttf'] // Name of the font files you want to copy 233 | ] 234 | 235 | apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" 236 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/debug.keystore -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/debug/java/com/reactnativefastimageexample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.reactnativefastimageexample; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/java/com/reactnativefastimageexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.reactnativefastimageexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "ReactNativeFastImageExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/java/com/reactnativefastimageexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.reactnativefastimageexample; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.dylanvann.fastimage.FastImageViewPackage; 7 | import com.dylanvann.fastimage.custom.persistence.ObjectBox; 8 | import com.facebook.react.PackageList; 9 | import com.facebook.react.ReactApplication; 10 | import com.facebook.react.ReactInstanceManager; 11 | import com.facebook.react.ReactNativeHost; 12 | import com.facebook.react.ReactPackage; 13 | import com.facebook.react.bridge.JSIModulePackage; 14 | import com.facebook.soloader.SoLoader; 15 | import com.swmansion.reanimated.ReanimatedJSIModulePackage; 16 | 17 | import java.lang.reflect.InvocationTargetException; 18 | import java.util.List; 19 | 20 | public class MainApplication extends Application implements ReactApplication { 21 | 22 | private final ReactNativeHost mReactNativeHost = 23 | new ReactNativeHost(this) { 24 | @Override 25 | public boolean getUseDeveloperSupport() { 26 | return BuildConfig.DEBUG; 27 | } 28 | 29 | @Override 30 | protected List getPackages() { 31 | @SuppressWarnings("UnnecessaryLocalVariable") 32 | List packages = new PackageList(this).getPackages(); 33 | // Packages that cannot be autolinked yet can be added manually here, for example: 34 | // packages.add(new MyReactNativePackage()); 35 | packages.add(new FastImageViewPackage()); 36 | return packages; 37 | } 38 | 39 | @Override 40 | protected String getJSMainModuleName() { 41 | return "index"; 42 | } 43 | 44 | @Override 45 | protected JSIModulePackage getJSIModulePackage() { 46 | return new ReanimatedJSIModulePackage(); 47 | } 48 | }; 49 | 50 | @Override 51 | public ReactNativeHost getReactNativeHost() { 52 | return mReactNativeHost; 53 | } 54 | 55 | @Override 56 | public void onCreate() { 57 | super.onCreate(); 58 | SoLoader.init(this, /* native exopackage */ false); 59 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 60 | ObjectBox.init(this); 61 | } 62 | 63 | /** 64 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 65 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 66 | * 67 | * @param context 68 | * @param reactInstanceManager 69 | */ 70 | private static void initializeFlipper( 71 | Context context, ReactInstanceManager reactInstanceManager) { 72 | if (BuildConfig.DEBUG) { 73 | try { 74 | /* 75 | We use reflection here to pick up the class that initializes Flipper, 76 | since Flipper library is not available in release mode 77 | */ 78 | Class aClass = Class.forName("com.reactnativefastimageexample.ReactNativeFlipper"); 79 | aClass 80 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 81 | .invoke(null, context, reactInstanceManager); 82 | } catch (ClassNotFoundException e) { 83 | e.printStackTrace(); 84 | } catch (NoSuchMethodException e) { 85 | e.printStackTrace(); 86 | } catch (IllegalAccessException e) { 87 | e.printStackTrace(); 88 | } catch (InvocationTargetException e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ReactNativeFastImageExample 3 | 4 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | s3.nl-ams.scw.cloud 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "30.0.2" 6 | minSdkVersion = 21 7 | compileSdkVersion = 30 8 | targetSdkVersion = 30 9 | ndkVersion = "21.4.7075529" 10 | } 11 | repositories { 12 | google() 13 | mavenCentral() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:4.2.2") 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | maven { 25 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 26 | url("$rootDir/../node_modules/react-native/android") 27 | } 28 | maven { 29 | // Android JSC is installed from npm 30 | url("$rootDir/../node_modules/jsc-android/dist") 31 | } 32 | mavenCentral { 33 | // We don't want to fetch react-native from Maven Central as there are 34 | // older versions over there. 35 | content { 36 | excludeGroup "com.facebook.react" 37 | } 38 | } 39 | 40 | google() 41 | maven { url 'https://www.jitpack.io' } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.93.0 29 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cuvent/react-native-fast-image/a661be6bb65029b3f1750fed9b2f793949df6152/ReactNativeFastImageExample/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ReactNativeFastImageExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | 5 | include ':rnfastimage' 6 | project(':rnfastimage').projectDir = new File(rootProject.projectDir, '../../android') 7 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ReactNativeFastImageExample", 3 | "displayName": "ReactNativeFastImageExample" 4 | } 5 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const pak = require('../package.json') 3 | 4 | module.exports = { 5 | presets: ['module:metro-react-native-babel-preset'], 6 | plugins: [ 7 | [ 8 | 'module-resolver', 9 | { 10 | extensions: ['.tsx', '.ts', '.js', '.json'], 11 | alias: { 12 | [pak.name]: path.join(__dirname, '..', pak.source), 13 | }, 14 | }, 15 | ], 16 | ], 17 | } 18 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import { AppRegistry } from 'react-native' 6 | import App from './src' 7 | import { name as appName } from './app.json' 8 | 9 | AppRegistry.registerComponent(appName, () => App) 10 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '11.0' 5 | 6 | target 'ReactNativeFastImageExample' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | pod 'RNFastImage', :path => '../..' 16 | 17 | target 'ReactNativeFastImageExampleTests' do 18 | inherit! :complete 19 | # Pods for testing 20 | end 21 | 22 | # Enables Flipper. 23 | # 24 | # Note that if you have use_frameworks! enabled, Flipper will not work and 25 | # you should disable the next line. 26 | use_flipper!() 27 | 28 | post_install do |installer| 29 | react_native_post_install(installer) 30 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 31 | end 32 | end -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample.xcodeproj/xcshareddata/xcschemes/ReactNativeFastImageExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #ifdef FB_SONARKIT_ENABLED 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | static void InitializeFlipper(UIApplication *application) { 16 | FlipperClient *client = [FlipperClient sharedClient]; 17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 20 | [client addPlugin:[FlipperKitReactPlugin new]]; 21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 22 | [client start]; 23 | } 24 | #endif 25 | 26 | @implementation AppDelegate 27 | 28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 29 | { 30 | #ifdef FB_SONARKIT_ENABLED 31 | InitializeFlipper(application); 32 | #endif 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 36 | moduleName:@"ReactNativeFastImageExample" 37 | initialProperties:nil]; 38 | 39 | if (@available(iOS 13.0, *)) { 40 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 41 | } else { 42 | rootView.backgroundColor = [UIColor whiteColor]; 43 | } 44 | 45 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 46 | UIViewController *rootViewController = [UIViewController new]; 47 | rootViewController.view = rootView; 48 | self.window.rootViewController = rootViewController; 49 | [self.window makeKeyAndVisible]; 50 | return YES; 51 | } 52 | 53 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 54 | { 55 | #if DEBUG 56 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 57 | #else 58 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 59 | #endif 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ReactNativeFastImageExample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | NSPhotoLibraryUsageDescription 41 | Need your photos. 42 | UIAppFonts 43 | 44 | Ionicons.ttf 45 | 46 | UILaunchStoryboardName 47 | LaunchScreen 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UIViewControllerBasedStatusBarAppearance 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExample/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/ios/ReactNativeFastImageExampleTests/ReactNativeFastImageExampleTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface ReactNativeFastImageExampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation ReactNativeFastImageExampleTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/metro.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const blacklist = require('metro-config/src/defaults/exclusionList') 3 | const escape = require('escape-string-regexp') 4 | const pak = require('../package.json') 5 | 6 | const root = path.resolve(__dirname, '..') 7 | 8 | const modules = Object.keys({ 9 | ...pak.peerDependencies, 10 | }) 11 | 12 | module.exports = { 13 | projectRoot: __dirname, 14 | watchFolders: [root], 15 | 16 | // We need to make sure that only one version is loaded for peerDependencies 17 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 18 | resolver: { 19 | blacklistRE: blacklist( 20 | modules.map( 21 | (m) => 22 | new RegExp( 23 | `^${escape(path.join(root, 'node_modules', m))}\\/.*$`, 24 | ), 25 | ), 26 | ), 27 | 28 | extraNodeModules: modules.reduce((acc, name) => { 29 | acc[name] = path.join(__dirname, 'node_modules', name) 30 | return acc 31 | }, {}), 32 | }, 33 | 34 | transformer: { 35 | getTransformOptions: async () => ({ 36 | transform: { 37 | experimentalImportSupport: false, 38 | inlineRequires: true, 39 | }, 40 | }), 41 | }, 42 | } 43 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactnativefastimageexample", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx", 11 | "ts": "tsc --skipLibCheck" 12 | }, 13 | "jest": { 14 | "moduleFileExtensions": [ 15 | "ts", 16 | "tsx", 17 | "js", 18 | "jsx", 19 | "json", 20 | "node" 21 | ], 22 | "preset": "react-native" 23 | }, 24 | "resolutions": { 25 | "@types/react": "^17" 26 | }, 27 | "dependencies": { 28 | "@react-native-community/masked-view": "^0.1.11", 29 | "@react-navigation/bottom-tabs": "^6.2.0", 30 | "@react-navigation/native": "^6.0.8", 31 | "@react-navigation/stack": "^6.1.1", 32 | "react": "17.0.2", 33 | "react-native": "0.67.2", 34 | "react-native-gesture-handler": "^2.2.0", 35 | "react-native-image-picker": "^4.7.3", 36 | "react-native-image-progress": "^1.2.0", 37 | "react-native-reanimated": "2.3.0", 38 | "react-native-safe-area-context": "^3.3.2", 39 | "react-native-screens": "^3.10.2", 40 | "react-native-status-bar-height": "^2.6.0", 41 | "react-native-vector-icons": "^8.1.0" 42 | }, 43 | "devDependencies": { 44 | "@babel/core": "^7.12.9", 45 | "@babel/runtime": "^7.12.5", 46 | "@react-native-community/eslint-config": "^2.0.0", 47 | "@types/jest": "^26.0.23", 48 | "@types/react-native": "^0.66.15", 49 | "@types/react-test-renderer": "^17.0.1", 50 | "babel-jest": "^26.6.3", 51 | "babel-plugin-module-resolver": "^4.1.0", 52 | "eslint": "^7.14.0", 53 | "jest": "^26.6.3", 54 | "metro-react-native-babel-preset": "^0.66.2", 55 | "react-test-renderer": "17.0.2", 56 | "typescript": "^4.5.5" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/src/AutoSizeExample.tsx: -------------------------------------------------------------------------------- 1 | import React, { useCallback, useMemo, useState } from 'react' 2 | import { StyleSheet, View } from 'react-native' 3 | import SectionFlex from './SectionFlex' 4 | import FastImage, { FastImageProps } from '@cuvent/react-native-fast-image' 5 | import Section from './Section' 6 | import FeatureText from './FeatureText' 7 | import { useCacheBust } from './useCacheBust' 8 | 9 | const GIF_URL = 10 | 'https://cdn-images-1.medium.com/max/1600/1*-CY5bU4OqiJRox7G00sftw.gif' 11 | 12 | interface AutoSizingImageProps extends FastImageProps { 13 | onLoad?: (event: any) => void 14 | defaultHeight?: number 15 | width: number 16 | style?: any 17 | } 18 | 19 | const AutoSizingImage = (props: AutoSizingImageProps) => { 20 | const [dimensions, setDimensions] = useState({ 21 | height: 0, 22 | width: 0, 23 | }) 24 | 25 | const propsOnLoad = props.onLoad 26 | const onLoad = useCallback( 27 | (e: any) => { 28 | const { 29 | nativeEvent: { width, height }, 30 | } = e 31 | setDimensions({ width, height }) 32 | if (propsOnLoad) { 33 | propsOnLoad(e) 34 | } 35 | }, 36 | [propsOnLoad], 37 | ) 38 | 39 | const height = useMemo(() => { 40 | if (!dimensions.height) { 41 | return props.defaultHeight === undefined ? 300 : props.defaultHeight 42 | } 43 | const ratio = dimensions.height / dimensions.width 44 | return props.width * ratio 45 | }, [dimensions.height, dimensions.width, props.defaultHeight, props.width]) 46 | return ( 47 | 52 | ) 53 | } 54 | 55 | export const AutoSizeExample = () => { 56 | const { bust, url } = useCacheBust(GIF_URL) 57 | return ( 58 | 59 |

60 | 61 |
62 | 63 | 68 | 69 | 70 | ) 71 | } 72 | 73 | const styles = StyleSheet.create({ 74 | image: { 75 | backgroundColor: '#ddd', 76 | margin: 20, 77 | flex: 0, 78 | }, 79 | }) 80 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/src/BorderRadiusExample.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { StyleSheet, View } from 'react-native' 3 | import SectionFlex from './SectionFlex' 4 | import FastImage from '@cuvent/react-native-fast-image' 5 | import Section from './Section' 6 | import FeatureText from './FeatureText' 7 | import { useCacheBust } from './useCacheBust' 8 | 9 | const IMAGE_URL = 'https://media.giphy.com/media/GEsoqZDGVoisw/giphy.gif' 10 | 11 | export const BorderRadiusExample = () => { 12 | const { query, bust } = useCacheBust('') 13 | return ( 14 | 15 |
16 | 17 |
18 | 19 | 25 | 31 | 32 |
33 | ) 34 | } 35 | 36 | const styles = StyleSheet.create({ 37 | imageSquare: { 38 | borderRadius: 50, 39 | height: 100, 40 | backgroundColor: '#ddd', 41 | margin: 20, 42 | width: 100, 43 | flex: 0, 44 | }, 45 | imageRectangular: { 46 | borderRadius: 50, 47 | borderTopLeftRadius: 10, 48 | borderBottomRightRadius: 10, 49 | height: 100, 50 | backgroundColor: '#ddd', 51 | margin: 20, 52 | flex: 1, 53 | }, 54 | plus: { 55 | width: 30, 56 | height: 30, 57 | position: 'absolute', 58 | bottom: 0, 59 | right: 0, 60 | }, 61 | }) 62 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/src/BulletText.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import FeatureText from './FeatureText' 3 | 4 | interface BulletTextProps { 5 | text?: string 6 | children?: any 7 | } 8 | 9 | const BulletText = ({ text, children }: BulletTextProps) => ( 10 | 11 | ) 12 | 13 | export default BulletText 14 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/src/Button.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { StyleSheet, Text, TouchableOpacity, View } from 'react-native' 3 | 4 | interface ButtonProps { 5 | text: string 6 | onPress: () => void 7 | } 8 | 9 | const Button = ({ text, onPress }: ButtonProps) => ( 10 | 11 | 12 | {text} 13 | 14 | 15 | ) 16 | 17 | const styles = StyleSheet.create({ 18 | button: { 19 | backgroundColor: 'black', 20 | margin: 10, 21 | height: 44, 22 | paddingLeft: 10, 23 | paddingRight: 10, 24 | borderRadius: 10, 25 | alignItems: 'center', 26 | justifyContent: 'center', 27 | }, 28 | text: { 29 | color: 'white', 30 | }, 31 | }) 32 | 33 | export default Button 34 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/src/DefaultImageGrid.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { Image } from 'react-native' 3 | import { ImageGrid } from './ImageGrid' 4 | 5 | const DefaultImageGrid = () => 6 | 7 | export default DefaultImageGrid 8 | -------------------------------------------------------------------------------- /ReactNativeFastImageExample/src/ETAGExample.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Dimensions, StatusBar, StyleSheet, View } from 'react-native' 2 | import React, { useRef } from 'react' 3 | import FastImage from '@cuvent/react-native-fast-image' 4 | 5 | export const ETAGExample = () => { 6 | const ref = useRef(null) 7 | 8 | return ( 9 | 10 | 15 | 16 | 24 | 25 |