├── example ├── .ruby-version ├── .bundle │ └── config ├── app.json ├── android │ ├── app │ │ ├── debug.keystore │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── 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 │ │ │ │ │ └── drawable │ │ │ │ │ │ └── rn_edit_text_material.xml │ │ │ │ ├── jni │ │ │ │ │ ├── MainApplicationModuleProvider.h │ │ │ │ │ ├── OnLoad.cpp │ │ │ │ │ ├── MainApplicationModuleProvider.cpp │ │ │ │ │ ├── MainComponentsRegistry.h │ │ │ │ │ ├── MainApplicationTurboModuleManagerDelegate.h │ │ │ │ │ ├── MainApplicationTurboModuleManagerDelegate.cpp │ │ │ │ │ ├── Android.mk │ │ │ │ │ └── MainComponentsRegistry.cpp │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── newarchitecture │ │ │ │ │ ├── newarchitecture │ │ │ │ │ ├── components │ │ │ │ │ │ └── MainComponentsRegistry.java │ │ │ │ │ ├── modules │ │ │ │ │ │ └── MainApplicationTurboModuleManagerDelegate.java │ │ │ │ │ └── MainApplicationReactNativeHost.java │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ └── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── newarchitecture │ │ │ │ └── ReactNativeFlipper.java │ │ ├── proguard-rules.pro │ │ ├── build_defs.bzl │ │ ├── _BUCK │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── gradle.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── NewArchitecture │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Info.plist │ │ ├── AppDelegate.mm │ │ └── LaunchScreen.storyboard │ ├── NewArchitecture.xcworkspace │ │ └── contents.xcworkspacedata │ ├── NewArchitectureTests │ │ ├── Info.plist │ │ └── NewArchitectureTests.m │ ├── Podfile │ └── NewArchitecture.xcodeproj │ │ └── project.pbxproj ├── .buckconfig ├── .prettierrc.js ├── Gemfile ├── index.js ├── src │ ├── screens │ │ ├── PerformanceLottieScreen.tsx │ │ ├── PerformanceRLottieScreen.tsx │ │ ├── SimpleViewScreen.tsx │ │ ├── HomeScreen.tsx │ │ └── ManualControlScreen.tsx │ └── components │ │ ├── Item.tsx │ │ └── PerformanceScreen.tsx ├── __tests__ │ └── App-test.tsx ├── .eslintrc.js ├── babel.config.js ├── .gitignore ├── metro.config.js ├── App.tsx └── package.json ├── tsconfig.build.json ├── babel.config.js ├── _img └── android_metrics.png ├── android ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── nl │ │ │ └── skillnation │ │ │ └── rlottie │ │ │ ├── RLottiePackage.java │ │ │ ├── RLottieViewManagerImpl.java │ │ │ └── RLottieView.java │ ├── oldarch │ │ └── java │ │ │ └── nl │ │ │ └── skillnation │ │ │ └── rlottie │ │ │ └── RLottieViewManager.java │ └── newarch │ │ └── java │ │ └── nl │ │ └── skillnation │ │ └── rlottie │ │ └── RLottieViewManager.java └── build.gradle ├── .gitignore ├── ios ├── RNLottieView.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── project.pbxproj └── RNLottieView │ ├── RNLottieViewManager.mm │ ├── RLottieView.h │ ├── LottieTypes.h │ └── RLottieView.mm ├── tsconfig.json ├── src ├── RLottieViewNativeComponent.js └── index.tsx ├── react-native-rlottie.podspec ├── package.json └── README.md /example/.ruby-version: -------------------------------------------------------------------------------- 1 | 2.7.4 2 | -------------------------------------------------------------------------------- /example/.bundle/config: -------------------------------------------------------------------------------- 1 | BUNDLE_PATH: "vendor/bundle" 2 | BUNDLE_FORCE_RUBY_PLATFORM: 1 3 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "exclude": ["example"] 4 | } -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NewArchitecture", 3 | "displayName": "NewArchitecture" 4 | } -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /_img/android_metrics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/_img/android_metrics.png -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | NewArchitecture 3 | 4 | -------------------------------------------------------------------------------- /example/ios/NewArchitecture/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | arrowParens: 'avoid', 3 | bracketSameLine: true, 4 | bracketSpacing: false, 5 | singleQuote: true, 6 | trailingComma: 'all', 7 | }; 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannojg/react-native-rlottie/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version 4 | ruby '2.7.4' 5 | 6 | gem 'cocoapods', '~> 1.11', '>= 1.11.2' 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/xcshareddata/* 2 | **/xcuserdata/* 3 | .DS_Store 4 | **/.DS_Store 5 | **/constents.xcworkspacedata 6 | node_modules/ 7 | build/ 8 | .gradle/ 9 | .vscode 10 | # generated by bob 11 | lib/ 12 | -------------------------------------------------------------------------------- /ios/RNLottieView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /example/ios/NewArchitecture/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/ios/NewArchitecture/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | @autoreleasepool { 8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example/src/screens/PerformanceLottieScreen.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {PerformanceScreen} from '../components/PerformanceScreen'; 3 | import LottieView from 'lottie-react-native'; 4 | 5 | export const PerformanceLottieScreen = () => { 6 | return ; 7 | }; 8 | -------------------------------------------------------------------------------- /example/src/screens/PerformanceRLottieScreen.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import RLottieView from 'react-native-rlottie'; 3 | import {PerformanceScreen} from '../components/PerformanceScreen'; 4 | 5 | export const PerformanceRLottieScreen = () => { 6 | return ; 7 | }; 8 | -------------------------------------------------------------------------------- /example/ios/NewArchitecture.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/__tests__/App-test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 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 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /android/src/oldarch/java/nl/skillnation/rlottie/RLottieViewManager.java: -------------------------------------------------------------------------------- 1 | package nl.skillnation.rlottie; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | 5 | public class RLottieViewManager extends RLottieViewManagerImpl { 6 | public RLottieViewManager(ReactApplicationContext reactContext) { 7 | super(reactContext); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | parser: '@typescript-eslint/parser', 5 | plugins: ['@typescript-eslint'], 6 | overrides: [ 7 | { 8 | files: ['*.ts', '*.tsx'], 9 | rules: { 10 | '@typescript-eslint/no-shadow': ['error'], 11 | 'no-shadow': 'off', 12 | 'no-undef': 'off', 13 | }, 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainApplicationModuleProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace facebook { 9 | namespace react { 10 | 11 | std::shared_ptr MainApplicationModuleProvider( 12 | const std::string moduleName, 13 | const JavaTurboModule::InitParams ¶ms); 14 | 15 | } // namespace react 16 | } // namespace facebook 17 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/OnLoad.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MainApplicationTurboModuleManagerDelegate.h" 3 | #include "MainComponentsRegistry.h" 4 | 5 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { 6 | return facebook::jni::initialize(vm, [] { 7 | facebook::react::MainApplicationTurboModuleManagerDelegate:: 8 | registerNatives(); 9 | facebook::react::MainComponentsRegistry::registerNatives(); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'NewArchitecture' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | includeBuild('../node_modules/react-native-gradle-plugin') 5 | 6 | if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") { 7 | include(":ReactAndroid") 8 | project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid') 9 | } 10 | -------------------------------------------------------------------------------- /ios/RNLottieView/RNLottieViewManager.mm: -------------------------------------------------------------------------------- 1 | // 2 | // RLottieViewManager.m 3 | // animationperftests 4 | // 5 | // Created by Hanno Gödecke on 31.05.22. 6 | // 7 | 8 | #import 9 | 10 | #import "RLottieView.h" 11 | 12 | @interface RNLottieViewManager : RCTViewManager 13 | @end 14 | 15 | @implementation RNLottieViewManager 16 | 17 | RCT_EXPORT_MODULE(RLottieView) 18 | RCT_EXPORT_VIEW_PROPERTY(src, NSString); 19 | 20 | - (UIView *)view 21 | { 22 | return [[RLottieView alloc] init]; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/src/screens/SimpleViewScreen.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {View, StyleSheet, Dimensions} from 'react-native'; 3 | import RLottieView from 'react-native-rlottie'; 4 | 5 | const anim = require('../../assets/icon_trophy.json'); 6 | 7 | export const SimpleViewScreen = () => ( 8 | 9 | 10 | 11 | ); 12 | 13 | const styles = StyleSheet.create({ 14 | container: { 15 | flex: 1, 16 | justifyContent: 'center', 17 | alignItems: 'center', 18 | }, 19 | anim: { 20 | width: Dimensions.get('window').width, 21 | height: Dimensions.get('window').width, 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /ios/RNLottieView/RLottieView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RLottieView.h 3 | // animationperftests 4 | // 5 | // Created by Hanno Gödecke on 31.05.22. 6 | // 7 | 8 | #ifndef RLottieView_h 9 | #define RLottieView_h 10 | 11 | #pragma New architecture 12 | // This guard prevent this file to be compiled in the old architecture. 13 | #ifdef RCT_NEW_ARCH_ENABLED 14 | #import 15 | #import 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | @interface RLottieView : RCTViewComponentView 20 | @end 21 | 22 | NS_ASSUME_NONNULL_END 23 | 24 | #endif /* RCT_NEW_ARCH_ENABLED */ 25 | 26 | 27 | #pragma Old architecture 28 | #ifndef RCT_NEW_ARCH_ENABLED 29 | #import 30 | 31 | @interface RLottieView : UIImageView 32 | 33 | @end 34 | #endif /* RCT_NEW_ARCH_ENABLED */ 35 | 36 | #endif /* RLottieView_h */ 37 | -------------------------------------------------------------------------------- /example/ios/NewArchitectureTests/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 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "paths": { 5 | "react-native-rlottie": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "importsNotUsedAsValues": "error", 11 | "forceConsistentCasingInFileNames": true, 12 | "jsx": "react", 13 | "lib": ["esnext"], 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "noFallthroughCasesInSwitch": true, 17 | "noImplicitReturns": true, 18 | "noImplicitUseStrict": false, 19 | "noStrictGenericChecks": false, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "resolveJsonModule": true, 23 | "skipLibCheck": true, 24 | "strict": true, 25 | "target": "esnext" 26 | } 27 | } -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainApplicationModuleProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "MainApplicationModuleProvider.h" 2 | 3 | #include 4 | #include 5 | 6 | namespace facebook { 7 | namespace react { 8 | 9 | std::shared_ptr MainApplicationModuleProvider( 10 | const std::string moduleName, 11 | const JavaTurboModule::InitParams ¶ms) { 12 | // Here you can provide your own module provider for TurboModules coming from 13 | // either your application or from external libraries. The approach to follow 14 | // is similar to the following (for a library called `samplelibrary`: 15 | // 16 | auto module = performancestats_ModuleProvider(moduleName, params); 17 | if (module != nullptr) { 18 | return module; 19 | } 20 | 21 | return rncore_ModuleProvider(moduleName, params); 22 | } 23 | 24 | } // namespace react 25 | } // namespace facebook 26 | -------------------------------------------------------------------------------- /example/src/components/Item.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {StyleSheet, Text, Pressable} from 'react-native'; 3 | import Icon from 'react-native-vector-icons/FontAwesome'; 4 | 5 | export function Item(props: {title: string; onPress: () => void}) { 6 | return ( 7 | 8 | {props.title} 9 | 10 | 11 | ); 12 | } 13 | 14 | const styles = StyleSheet.create({ 15 | item: { 16 | width: '100%', 17 | paddingHorizontal: 20, 18 | height: 65, 19 | backgroundColor: '#fff', 20 | justifyContent: 'space-between', 21 | flexDirection: 'row', 22 | alignItems: 'center', 23 | borderBottomWidth: StyleSheet.hairlineWidth, 24 | borderBottomColor: '#ccc', 25 | }, 26 | bold: { 27 | fontWeight: 'bold', 28 | width: '85%', 29 | }, 30 | }); 31 | -------------------------------------------------------------------------------- /android/src/main/java/nl/skillnation/rlottie/RLottiePackage.java: -------------------------------------------------------------------------------- 1 | package nl.skillnation.rlottie; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.ReactPackage; 6 | import com.facebook.react.bridge.NativeModule; 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.uimanager.ViewManager; 9 | 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class RLottiePackage implements ReactPackage { 14 | @NonNull 15 | @Override 16 | public List createNativeModules(@NonNull ReactApplicationContext reactContext) { 17 | return Collections.emptyList(); 18 | } 19 | 20 | @NonNull 21 | @Override 22 | public List createViewManagers(@NonNull ReactApplicationContext reactContext) { 23 | return Collections.singletonList( 24 | new RLottieViewManager(reactContext) 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/RLottieViewNativeComponent.js: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | /** 3 | * @flow strict-local 4 | */ 5 | 6 | import type { HostComponent } from 'react-native'; 7 | import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; 8 | import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes'; 9 | import type { Float } from 'react-native/Libraries/Types/CodegenTypes'; 10 | 11 | type NativeProps = $ReadOnly<{| 12 | ...ViewProps, 13 | src: string, 14 | /** 15 | * @default false 16 | */ 17 | isAutoPlay?: boolean, 18 | /** 19 | * @default 1.0 20 | */ 21 | speed?: Float, 22 | /** 23 | * @default "contain" 24 | */ 25 | resizeMode?: string, 26 | /** 27 | * @default false 28 | */ 29 | autoSize?: boolean, 30 | /** 31 | * @default true 32 | */ 33 | loop?: boolean, 34 | progress?: Float, 35 | decodeWidth?: Float, 36 | decodeHeight?: Float, 37 | |}>; 38 | 39 | export default (codegenNativeComponent( 40 | 'RLottieView' 41 | ): HostComponent); 42 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainComponentsRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace facebook { 9 | namespace react { 10 | 11 | class MainComponentsRegistry 12 | : public facebook::jni::HybridClass { 13 | public: 14 | // Adapt it to the package you used for your Java class. 15 | constexpr static auto kJavaDescriptor = 16 | "Lcom/newarchitecture/newarchitecture/components/MainComponentsRegistry;"; 17 | 18 | static void registerNatives(); 19 | 20 | MainComponentsRegistry(ComponentFactory *delegate); 21 | 22 | private: 23 | static std::shared_ptr 24 | sharedProviderRegistry(); 25 | 26 | static jni::local_ref initHybrid( 27 | jni::alias_ref, 28 | ComponentFactory *delegate); 29 | }; 30 | 31 | } // namespace react 32 | } // namespace facebook 33 | -------------------------------------------------------------------------------- /example/.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 | # Ruby / CocoaPods 60 | /ios/Pods/ 61 | /vendor/bundle/ 62 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/NewArchitecture/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "scale" : "1x", 46 | "size" : "1024x1024" 47 | } 48 | ], 49 | "info" : { 50 | "author" : "xcode", 51 | "version" : 1 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /example/src/screens/HomeScreen.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {ScrollView} from 'react-native'; 3 | import {Item} from '../components/Item'; 4 | import type {NativeStackHeaderProps} from '@react-navigation/native-stack'; 5 | import {Platform} from 'react-native'; 6 | 7 | export const HomeScreen = ({navigation}: NativeStackHeaderProps) => { 8 | return ( 9 | 10 | navigation.navigate('SimpleViewScreen')} 13 | /> 14 | navigation.navigate('ManualControlScreen')} 17 | /> 18 | navigation.navigate('PerformanceRLottieScreen')} 21 | /> 22 | navigation.navigate('PerformanceLottieScreen')} 28 | /> 29 | 30 | ); 31 | }; 32 | -------------------------------------------------------------------------------- /example/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 => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`), 22 | ), 23 | ), 24 | 25 | extraNodeModules: modules.reduce((acc, name) => { 26 | acc[name] = path.join(__dirname, 'node_modules', name); 27 | return acc; 28 | }, {}), 29 | }, 30 | 31 | transformer: { 32 | getTransformOptions: async () => ({ 33 | transform: { 34 | experimentalImportSupport: true, 35 | inlineRequires: true, 36 | }, 37 | }), 38 | }, 39 | }; 40 | -------------------------------------------------------------------------------- /example/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 | install! 'cocoapods', :deterministic_uuids => false 6 | 7 | target 'NewArchitecture' do 8 | config = use_native_modules! 9 | 10 | # Flags change depending on the env values. 11 | flags = get_default_flags() 12 | 13 | use_react_native!( 14 | :path => config[:reactNativePath], 15 | # to enable hermes on iOS, change `false` to `true` and then install pods 16 | :hermes_enabled => true, 17 | :fabric_enabled => flags[:fabric_enabled], 18 | # An absolute path to your application root. 19 | :app_path => "#{Pod::Config.instance.installation_root}/.." 20 | ) 21 | 22 | pod 'react-native-rlottie', :path => '../..' 23 | 24 | target 'NewArchitectureTests' do 25 | inherit! :complete 26 | # Pods for testing 27 | end 28 | 29 | # Enables Flipper. 30 | # 31 | # Note that if you have use_frameworks! enabled, Flipper will not work and 32 | # you should disable the next line. 33 | # use_flipper!() 34 | 35 | post_install do |installer| 36 | react_native_post_install(installer) 37 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /example/App.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {NavigationContainer} from '@react-navigation/native'; 3 | import {createNativeStackNavigator} from '@react-navigation/native-stack'; 4 | import {HomeScreen} from './src/screens/HomeScreen'; 5 | import {SimpleViewScreen} from './src/screens/SimpleViewScreen'; 6 | import {ManualControlScreen} from './src/screens/ManualControlScreen'; 7 | import {PerformanceRLottieScreen} from './src/screens/PerformanceRLottieScreen'; 8 | import {PerformanceLottieScreen} from './src/screens/PerformanceLottieScreen'; 9 | 10 | const Stack = createNativeStackNavigator(); 11 | 12 | const App = () => { 13 | return ( 14 | 15 | 16 | 17 | 18 | 22 | 26 | 30 | 31 | 32 | ); 33 | }; 34 | export default App; 35 | -------------------------------------------------------------------------------- /example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | namespace facebook { 8 | namespace react { 9 | 10 | class MainApplicationTurboModuleManagerDelegate 11 | : public jni::HybridClass< 12 | MainApplicationTurboModuleManagerDelegate, 13 | TurboModuleManagerDelegate> { 14 | public: 15 | // Adapt it to the package you used for your Java class. 16 | static constexpr auto kJavaDescriptor = 17 | "Lcom/newarchitecture/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;"; 18 | 19 | static jni::local_ref initHybrid(jni::alias_ref); 20 | 21 | static void registerNatives(); 22 | 23 | std::shared_ptr getTurboModule( 24 | const std::string name, 25 | const std::shared_ptr jsInvoker) override; 26 | std::shared_ptr getTurboModule( 27 | const std::string name, 28 | const JavaTurboModule::InitParams ¶ms) override; 29 | 30 | /** 31 | * Test-only method. Allows user to verify whether a TurboModule can be 32 | * created by instances of this class. 33 | */ 34 | bool canCreateTurboModule(std::string name); 35 | }; 36 | 37 | } // namespace react 38 | } // namespace facebook 39 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/newarchitecture/newarchitecture/components/MainComponentsRegistry.java: -------------------------------------------------------------------------------- 1 | package com.newarchitecture.newarchitecture.components; 2 | 3 | import com.facebook.jni.HybridData; 4 | import com.facebook.proguard.annotations.DoNotStrip; 5 | import com.facebook.react.fabric.ComponentFactory; 6 | import com.facebook.soloader.SoLoader; 7 | 8 | /** 9 | * Class responsible to load the custom Fabric Components. This class has native methods and needs a 10 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/ 11 | * folder for you). 12 | * 13 | *

Please note that this class is used ONLY if you opt-in for the New Architecture (see the 14 | * `newArchEnabled` property). Is ignored otherwise. 15 | */ 16 | @DoNotStrip 17 | public class MainComponentsRegistry { 18 | static { 19 | SoLoader.loadLibrary("fabricjni"); 20 | } 21 | 22 | @DoNotStrip private final HybridData mHybridData; 23 | 24 | @DoNotStrip 25 | private native HybridData initHybrid(ComponentFactory componentFactory); 26 | 27 | @DoNotStrip 28 | private MainComponentsRegistry(ComponentFactory componentFactory) { 29 | mHybridData = initHybrid(componentFactory); 30 | } 31 | 32 | @DoNotStrip 33 | public static MainComponentsRegistry register(ComponentFactory componentFactory) { 34 | return new MainComponentsRegistry(componentFactory); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ios/RNLottieView/LottieTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // LottieTypes.h 3 | // animationperftests 4 | // 5 | // Created by Hanno Gödecke on 31.05.22. 6 | // 7 | 8 | #ifndef LottieTypes_h 9 | #define LottieTypes_h 10 | 11 | typedef struct LottieWrapper{ 12 | public: 13 | static void convertToCanvasFormat(rlottie::Surface &s); 14 | }; 15 | 16 | typedef struct LottieInfo{ 17 | ~LottieInfo() { 18 | if (decompressBuffer != nullptr) { 19 | delete[]decompressBuffer; 20 | decompressBuffer = nullptr; 21 | } 22 | } 23 | 24 | public: 25 | std::unique_ptr animation; 26 | size_t frameCount = 0; 27 | int32_t fps = 30; 28 | double_t duration = 0; 29 | bool precache = false; 30 | bool createCache = false; 31 | bool limitFps = false; 32 | std::string path; 33 | std::string cacheFile; 34 | uint8_t *decompressBuffer = nullptr; 35 | uint32_t decompressBufferSize = 0; 36 | volatile uint32_t maxFrameSize = 0; 37 | uint32_t imageSize = 0; 38 | uint32_t fileOffset = 0; 39 | bool nextFrameIsCacheFrame = false; 40 | 41 | FILE *precacheFile = nullptr; 42 | char *compressBuffer = nullptr; 43 | const char *buffer = nullptr; 44 | bool firstFrame = false; 45 | int bufferSize; 46 | int compressBound; 47 | int firstFrameSize; 48 | volatile uint32_t framesAvailableInCache = 0; 49 | }; 50 | 51 | #endif /* LottieTypes_h */ 52 | -------------------------------------------------------------------------------- /android/src/newarch/java/nl/skillnation/rlottie/RLottieViewManager.java: -------------------------------------------------------------------------------- 1 | package nl.skillnation.rlottie; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import com.facebook.react.bridge.ReactApplicationContext; 6 | import com.facebook.react.module.annotations.ReactModule; 7 | import com.facebook.react.uimanager.ViewManagerDelegate; 8 | import com.facebook.react.viewmanagers.RLottieViewManagerDelegate; 9 | import com.facebook.react.viewmanagers.RLottieViewManagerInterface; 10 | 11 | @ReactModule(name = RLottieViewManager.NAME) 12 | public class RLottieViewManager extends RLottieViewManagerImpl 13 | implements RLottieViewManagerInterface { 14 | 15 | public static final String NAME = "RLottieView"; 16 | 17 | private final ViewManagerDelegate mDelegate; 18 | 19 | public RLottieViewManager(ReactApplicationContext reactContext) { 20 | super(reactContext); 21 | mDelegate = new RLottieViewManagerDelegate<>(this); 22 | } 23 | 24 | @Nullable 25 | @Override 26 | protected ViewManagerDelegate getDelegate() { 27 | return mDelegate; 28 | } 29 | 30 | @Override 31 | public void setDecodeWidth(RLottieView view, float value) { 32 | this.setDecodeWidth(view, Math.round(value)); 33 | } 34 | 35 | @Override 36 | public void setDecodeHeight(RLottieView view, float value) { 37 | this.setDecodeHeight(view, Math.round(value)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /example/src/screens/ManualControlScreen.tsx: -------------------------------------------------------------------------------- 1 | import React, {useRef} from 'react'; 2 | import { 3 | View, 4 | StyleSheet, 5 | Dimensions, 6 | Button, 7 | Animated, 8 | Text, 9 | } from 'react-native'; 10 | import RLottieView from 'react-native-rlottie'; 11 | 12 | const anim = require('../../assets/icon_trophy.json'); 13 | const AnimatedRLottieView = Animated.createAnimatedComponent(RLottieView); 14 | 15 | export const ManualControlScreen = () => { 16 | const animation = useRef(new Animated.Value(0)).current; 17 | 18 | const onPressStart = () => { 19 | animation.setValue(0); 20 | Animated.timing(animation, { 21 | toValue: 1, 22 | useNativeDriver: true, 23 | duration: 2000, 24 | }).start(); 25 | }; 26 | 27 | return ( 28 | 29 | Note: This is android only currently 🤖🚫 30 | 36 |