NitroImage is an example nitro module.
Nitro Image is installed in the example/
app.
To load an Image, use the exported ImageConstructors
:
import { ImageConstructors } from 'react-native-nitro-image'
const image = ImageConstructors.loadImageFromSystemName('heart.fill')
Nitro Image also contains a HybridTestObject
, which can be used for playing around with HybridObjects and testing various features.
When any of the HybridObjects specs (*.nitro.ts
) change, you must re-run nitrogen:
npm run nitrogen
android/
: All yourandroid
-specific implementations. (HybridImage.kt
andHybridImageFactory.kt
)build.gradle
: The gradle build file. This contains four important pieces:- Standard react-native library boilerplate code
- Configures Kotlin (
apply plugin: 'org.jetbrains.kotlin.android'
) - Adds all Nitrogen files (
apply from: '.../NitroImage+autolinking.gradle'
) - Triggers the native C++ build (via CMake/
externalNativeBuild
)
CMakeLists.txt
: The CMake build file to build C++ code. This contains four important pieces:- Creates a library called
NitroImage
(same as innitro.json
) - Adds all Nitrogen files (
include(.../NitroImage+autolinking.cmake)
) - Adds all custom C++ files (only
HybridTestObjectCpp.cpp
) - Adds a
cpp-adapter.cpp
file, which autolinks all C++ HybridObjects (onlyHybridTestObjectCpp
)
- Creates a library called
src/main/java/com/margelo/nitro/image/
: All Kotlin implementations.NitroImagePackage.java
: The react-native package. You need this because the react-native CLI only adds libraries if they have a*Package.java
file. In here, you can autolink all Kotlin HybridObjects (ImageFactory
)
cpp/
: All your cross-platform implementations. (onlyHybridTestObjectCpp.cpp
)ios/
: All your iOS-specific implementations. (HybridImage.swift
andHybridImageFactory.swift
)nitrogen/
: All files generated by nitrogen. You should commit this folder to git.src/
: The TypeScript codebase. This defines all HybridObjects and loads them at runtime.specs/
: All HybridObject types. Nitrogen will run on all*.nitro.ts
files.
nitro.json
: The configuration file for nitrogen. This will define all native namespaces, as well as the library name.NitroImage.podspec
: The iOS podspec build file to build the iOS code. This contains three important pieces:- Specifies the Pod's name. This must be identical to the name specified in
nitro.json
. - Adds all of your
.swift
or.cpp
files (implementations). - Adds all Nitrogen files (
add_nitrogen_files(s)
)
- Specifies the Pod's name. This must be identical to the name specified in
package.json
: The npm package.json file.react-native-nitro-modules
should be apeerDependency
.