react-native-nitro-wallpaper 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +71 -0
  3. package/android/CMakeLists.txt +24 -0
  4. package/android/build.gradle +129 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +3 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/reactnativenitrowallpaper/WallpaperSet.kt +53 -0
  9. package/android/src/main/java/com/margelo/nitro/reactnativenitrowallpaper/WallpaperSetPackage.kt +31 -0
  10. package/lib/module/WallpaperSet.nitro.js +4 -0
  11. package/lib/module/WallpaperSet.nitro.js.map +1 -0
  12. package/lib/module/index.js +14 -0
  13. package/lib/module/index.js.map +1 -0
  14. package/lib/module/package.json +1 -0
  15. package/lib/typescript/package.json +1 -0
  16. package/lib/typescript/src/WallpaperSet.nitro.d.ts +7 -0
  17. package/lib/typescript/src/WallpaperSet.nitro.d.ts.map +1 -0
  18. package/lib/typescript/src/index.d.ts +4 -0
  19. package/lib/typescript/src/index.d.ts.map +1 -0
  20. package/nitro.json +16 -0
  21. package/nitrogen/generated/android/c++/JHybridWallpaperSetSpec.cpp +64 -0
  22. package/nitrogen/generated/android/c++/JHybridWallpaperSetSpec.hpp +65 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativenitrowallpaper/HybridWallpaperSetSpec.kt +58 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativenitrowallpaper/reactnativenitrowallpaperOnLoad.kt +35 -0
  25. package/nitrogen/generated/android/reactnativenitrowallpaper+autolinking.cmake +81 -0
  26. package/nitrogen/generated/android/reactnativenitrowallpaper+autolinking.gradle +27 -0
  27. package/nitrogen/generated/android/reactnativenitrowallpaperOnLoad.cpp +44 -0
  28. package/nitrogen/generated/android/reactnativenitrowallpaperOnLoad.hpp +25 -0
  29. package/nitrogen/generated/shared/c++/HybridWallpaperSetSpec.cpp +21 -0
  30. package/nitrogen/generated/shared/c++/HybridWallpaperSetSpec.hpp +63 -0
  31. package/package.json +186 -0
  32. package/react-native.config.js +12 -0
  33. package/src/WallpaperSet.nitro.ts +5 -0
  34. package/src/index.tsx +17 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 rahulmandyal1
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # react-native-nitro-wallpaper
2
+
3
+ Set wallpaper on React Native (Android only)
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install react-native-nitro-wallpaper react-native-nitro-modules
9
+ ```
10
+
11
+ > `react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).
12
+
13
+ ### Android Setup
14
+
15
+ No additional setup required. The library will be automatically linked.
16
+
17
+ > **Note:** This library is Android-only. iOS is not supported. If you try to use it on iOS, it will throw an error.
18
+
19
+ ## Usage
20
+
21
+ ```js
22
+ import { WallpaperSet } from 'react-native-nitro-wallpaper';
23
+
24
+ // Set wallpaper from URL
25
+ await WallpaperSet.setWallpaper('https://example.com/image.jpg');
26
+
27
+ // Set wallpaper from local file path
28
+ await WallpaperSet.setWallpaper('/storage/emulated/0/Pictures/wallpaper.jpg');
29
+
30
+ // Set wallpaper from file URI
31
+ await WallpaperSet.setWallpaper('file:///storage/emulated/0/Pictures/wallpaper.jpg');
32
+
33
+ // Set wallpaper from content URI
34
+ await WallpaperSet.setWallpaper('content://media/external/images/media/123');
35
+ ```
36
+
37
+ ### Example
38
+
39
+ ```jsx
40
+ import React from 'react';
41
+ import { Button, Alert } from 'react-native';
42
+ import { WallpaperSet } from 'react-native-nitro-wallpaper';
43
+
44
+ function App() {
45
+ const handleSetWallpaper = async () => {
46
+ try {
47
+ await WallpaperSet.setWallpaper('https://images.unsplash.com/photo-1506744038136-46273834b3fb');
48
+ Alert.alert('Success', 'Wallpaper set successfully!');
49
+ } catch (error) {
50
+ Alert.alert('Error', error.message);
51
+ }
52
+ };
53
+
54
+ return <Button title="Set Wallpaper" onPress={handleSetWallpaper} />;
55
+ }
56
+ ```
57
+
58
+
59
+ ## Contributing
60
+
61
+ - [Development workflow](CONTRIBUTING.md#development-workflow)
62
+ - [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
63
+ - [Code of conduct](CODE_OF_CONDUCT.md)
64
+
65
+ ## License
66
+
67
+ MIT
68
+
69
+ ---
70
+
71
+ Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
@@ -0,0 +1,24 @@
1
+ project(reactnativenitrowallpaper)
2
+ cmake_minimum_required(VERSION 3.9.0)
3
+
4
+ set(PACKAGE_NAME reactnativenitrowallpaper)
5
+ set(CMAKE_VERBOSE_MAKEFILE ON)
6
+ set(CMAKE_CXX_STANDARD 20)
7
+
8
+ # Define C++ library and add all sources
9
+ add_library(${PACKAGE_NAME} SHARED src/main/cpp/cpp-adapter.cpp)
10
+
11
+ # Add Nitrogen specs :)
12
+ include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/reactnativenitrowallpaper+autolinking.cmake)
13
+
14
+ # Set up local includes
15
+ include_directories("src/main/cpp" "../cpp")
16
+
17
+ find_library(LOG_LIB log)
18
+
19
+ # Link all libraries together
20
+ target_link_libraries(
21
+ ${PACKAGE_NAME}
22
+ ${LOG_LIB}
23
+ android # <-- Android core
24
+ )
@@ -0,0 +1,129 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['WallpaperSet_' + name]
4
+ }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
16
+ }
17
+
18
+ def reactNativeArchitectures() {
19
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
20
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
21
+ }
22
+
23
+ apply plugin: "com.android.library"
24
+ apply plugin: "kotlin-android"
25
+ apply from: '../nitrogen/generated/android/reactnativenitrowallpaper+autolinking.gradle'
26
+
27
+ apply plugin: "com.facebook.react"
28
+
29
+ def getExtOrIntegerDefault(name) {
30
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["WallpaperSet_" + name]).toInteger()
31
+ }
32
+
33
+ android {
34
+ namespace "com.margelo.nitro.reactnativenitrowallpaper"
35
+
36
+ ndkVersion "26.1.10909125"
37
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
38
+
39
+ defaultConfig {
40
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
41
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
42
+
43
+ externalNativeBuild {
44
+ cmake {
45
+ cppFlags "-frtti -fexceptions -Wall -fstack-protector-all"
46
+ arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
47
+ abiFilters (*reactNativeArchitectures())
48
+
49
+ buildTypes {
50
+ debug {
51
+ cppFlags "-O1 -g"
52
+ }
53
+ release {
54
+ cppFlags "-O2"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+
61
+ externalNativeBuild {
62
+ cmake {
63
+ path "CMakeLists.txt"
64
+ }
65
+ }
66
+
67
+ packagingOptions {
68
+ excludes = [
69
+ "META-INF",
70
+ "META-INF/**",
71
+ "**/libc++_shared.so",
72
+ "**/libfbjni.so",
73
+ "**/libjsi.so",
74
+ "**/libfolly_json.so",
75
+ "**/libfolly_runtime.so",
76
+ "**/libglog.so",
77
+ "**/libhermes.so",
78
+ "**/libhermes-executor-debug.so",
79
+ "**/libhermes_executor.so",
80
+ "**/libreactnative.so",
81
+ "**/libreactnativejni.so",
82
+ "**/libturbomodulejsijni.so",
83
+ "**/libreact_nativemodule_core.so",
84
+ "**/libjscexecutor.so"
85
+ ]
86
+ }
87
+
88
+ buildFeatures {
89
+ buildConfig true
90
+ prefab true
91
+ }
92
+
93
+ buildTypes {
94
+ release {
95
+ minifyEnabled false
96
+ }
97
+ }
98
+
99
+ lintOptions {
100
+ disable "GradleCompatible"
101
+ }
102
+
103
+ compileOptions {
104
+ sourceCompatibility JavaVersion.VERSION_1_8
105
+ targetCompatibility JavaVersion.VERSION_1_8
106
+ }
107
+
108
+ sourceSets {
109
+ main {
110
+ java.srcDirs += [
111
+ "generated/java",
112
+ "generated/jni"
113
+ ]
114
+ }
115
+ }
116
+ }
117
+
118
+ repositories {
119
+ mavenCentral()
120
+ google()
121
+ }
122
+
123
+ def kotlin_version = getExtOrDefault("kotlinVersion")
124
+
125
+ dependencies {
126
+ implementation "com.facebook.react:react-android"
127
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
128
+ implementation project(":react-native-nitro-modules")
129
+ }
@@ -0,0 +1,5 @@
1
+ WallpaperSet_kotlinVersion=2.0.21
2
+ WallpaperSet_minSdkVersion=24
3
+ WallpaperSet_targetSdkVersion=34
4
+ WallpaperSet_compileSdkVersion=35
5
+ WallpaperSet_ndkVersion=27.1.12297006
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.SET_WALLPAPER"/>
3
+ </manifest>
@@ -0,0 +1,6 @@
1
+ #include <jni.h>
2
+ #include "reactnativenitrowallpaperOnLoad.hpp"
3
+
4
+ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
5
+ return margelo::nitro::reactnativenitrowallpaper::initialize(vm);
6
+ }
@@ -0,0 +1,53 @@
1
+ package com.margelo.nitro.reactnativenitrowallpaper
2
+
3
+ import com.facebook.proguard.annotations.DoNotStrip
4
+
5
+ import android.app.WallpaperManager
6
+ import android.graphics.Bitmap
7
+ import android.graphics.BitmapFactory
8
+ import android.net.Uri
9
+ import com.margelo.nitro.core.Promise
10
+ import java.net.URL
11
+
12
+ @DoNotStrip
13
+ class WallpaperSet : HybridWallpaperSetSpec() {
14
+ override fun setWallpaper(image: String): Promise<Unit> {
15
+ val promise = Promise<Unit>()
16
+ val context = WallpaperSetPackage.context
17
+ if (context == null) {
18
+ promise.reject(Exception("Context not initialized"))
19
+ return promise
20
+ }
21
+
22
+ Thread {
23
+ try {
24
+ val wallpaperManager = WallpaperManager.getInstance(context)
25
+ val bitmap: Bitmap?
26
+
27
+ if (image.startsWith("http")) {
28
+ val url = URL(image)
29
+ bitmap = BitmapFactory.decodeStream(url.openStream())
30
+ } else if (image.startsWith("file://") || image.startsWith("content://")) {
31
+ val uri = Uri.parse(image)
32
+ val inputStream = context.contentResolver.openInputStream(uri)
33
+ ?: throw Exception("Could not open input stream for URI: $image")
34
+ bitmap = BitmapFactory.decodeStream(inputStream)
35
+ inputStream?.close()
36
+ } else {
37
+ bitmap = BitmapFactory.decodeFile(image)
38
+ }
39
+
40
+ if (bitmap == null) {
41
+ throw Exception("Failed to decode bitmap from: $image")
42
+ }
43
+
44
+ wallpaperManager.setBitmap(bitmap)
45
+ promise.resolve(Unit)
46
+ } catch (e: Throwable) {
47
+ promise.reject(e)
48
+ }
49
+ }.start()
50
+
51
+ return promise
52
+ }
53
+ }
@@ -0,0 +1,31 @@
1
+ package com.margelo.nitro.reactnativenitrowallpaper
2
+
3
+ import com.facebook.react.BaseReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfoProvider
7
+
8
+ import android.util.Log
9
+
10
+ class WallpaperSetPackage : BaseReactPackage() {
11
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
+ return null
13
+ }
14
+
15
+ override fun createNativeModules(reactContext: ReactApplicationContext): MutableList<NativeModule> {
16
+ Log.d("WallpaperSetPackage", "createNativeModules called!")
17
+ context = reactContext
18
+ return super.createNativeModules(reactContext) as MutableList<NativeModule>
19
+ }
20
+
21
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
22
+ return ReactModuleInfoProvider { HashMap() }
23
+ }
24
+
25
+ companion object {
26
+ var context: android.content.Context? = null
27
+ init {
28
+ System.loadLibrary("reactnativenitrowallpaper")
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=WallpaperSet.nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["WallpaperSet.nitro.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ import { NitroModules } from 'react-native-nitro-modules';
4
+ import { Platform } from 'react-native';
5
+ const WallpaperSetNative = NitroModules.createHybridObject('WallpaperSet');
6
+ export const WallpaperSet = {
7
+ setWallpaper: async image => {
8
+ if (Platform.OS === 'ios') {
9
+ throw new Error('react-native-nitro-wallpaper is Android-only. iOS is not supported.');
10
+ }
11
+ return WallpaperSetNative.setWallpaper(image);
12
+ }
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NitroModules","Platform","WallpaperSetNative","createHybridObject","WallpaperSet","setWallpaper","image","OS","Error"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SAASC,QAAQ,QAAQ,cAAc;AAGvC,MAAMC,kBAAkB,GACtBF,YAAY,CAACG,kBAAkB,CAAmB,cAAc,CAAC;AAEnE,OAAO,MAAMC,YAAY,GAAG;EAC1BC,YAAY,EAAE,MAAOC,KAAa,IAAoB;IACpD,IAAIL,QAAQ,CAACM,EAAE,KAAK,KAAK,EAAE;MACzB,MAAM,IAAIC,KAAK,CACb,qEACF,CAAC;IACH;IACA,OAAON,kBAAkB,CAACG,YAAY,CAACC,KAAK,CAAC;EAC/C;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,7 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+ export interface WallpaperSet extends HybridObject<{
3
+ android: 'kotlin';
4
+ }> {
5
+ setWallpaper(image: string): Promise<void>;
6
+ }
7
+ //# sourceMappingURL=WallpaperSet.nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WallpaperSet.nitro.d.ts","sourceRoot":"","sources":["../../../src/WallpaperSet.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,YAAa,SAAQ,YAAY,CAAC;IAAE,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACvE,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C"}
@@ -0,0 +1,4 @@
1
+ export declare const WallpaperSet: {
2
+ setWallpaper: (image: string) => Promise<void>;
3
+ };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY;0BACK,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;CAQnD,CAAC"}
package/nitro.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "cxxNamespace": ["reactnativenitrowallpaper"],
3
+ "android": {
4
+ "androidNamespace": ["reactnativenitrowallpaper"],
5
+ "androidCxxLibName": "reactnativenitrowallpaper"
6
+ },
7
+ "ios": {
8
+ "iosModuleName": "ReactNativeNitroWallpaper"
9
+ },
10
+ "autolinking": {
11
+ "WallpaperSet": {
12
+ "kotlin": "WallpaperSet"
13
+ }
14
+ },
15
+ "ignorePaths": ["node_modules"]
16
+ }
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// JHybridWallpaperSetSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "JHybridWallpaperSetSpec.hpp"
9
+
10
+
11
+
12
+ #include <NitroModules/Promise.hpp>
13
+ #include <NitroModules/JPromise.hpp>
14
+ #include <string>
15
+
16
+ namespace margelo::nitro::reactnativenitrowallpaper {
17
+
18
+ jni::local_ref<JHybridWallpaperSetSpec::jhybriddata> JHybridWallpaperSetSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
19
+ return makeCxxInstance(jThis);
20
+ }
21
+
22
+ void JHybridWallpaperSetSpec::registerNatives() {
23
+ registerHybrid({
24
+ makeNativeMethod("initHybrid", JHybridWallpaperSetSpec::initHybrid),
25
+ });
26
+ }
27
+
28
+ size_t JHybridWallpaperSetSpec::getExternalMemorySize() noexcept {
29
+ static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
30
+ return method(_javaPart);
31
+ }
32
+
33
+ void JHybridWallpaperSetSpec::dispose() noexcept {
34
+ static const auto method = javaClassStatic()->getMethod<void()>("dispose");
35
+ method(_javaPart);
36
+ }
37
+
38
+ std::string JHybridWallpaperSetSpec::toString() {
39
+ static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
40
+ auto javaString = method(_javaPart);
41
+ return javaString->toStdString();
42
+ }
43
+
44
+ // Properties
45
+
46
+
47
+ // Methods
48
+ std::shared_ptr<Promise<void>> JHybridWallpaperSetSpec::setWallpaper(const std::string& image) {
49
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* image */)>("setWallpaper");
50
+ auto __result = method(_javaPart, jni::make_jstring(image));
51
+ return [&]() {
52
+ auto __promise = Promise<void>::create();
53
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
54
+ __promise->resolve();
55
+ });
56
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
57
+ jni::JniException __jniError(__throwable);
58
+ __promise->reject(std::make_exception_ptr(__jniError));
59
+ });
60
+ return __promise;
61
+ }();
62
+ }
63
+
64
+ } // namespace margelo::nitro::reactnativenitrowallpaper
@@ -0,0 +1,65 @@
1
+ ///
2
+ /// HybridWallpaperSetSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridWallpaperSetSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::reactnativenitrowallpaper {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridWallpaperSetSpec: public jni::HybridClass<JHybridWallpaperSetSpec, JHybridObject>,
22
+ public virtual HybridWallpaperSetSpec {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/reactnativenitrowallpaper/HybridWallpaperSetSpec;";
25
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
26
+ static void registerNatives();
27
+
28
+ protected:
29
+ // C++ constructor (called from Java via `initHybrid()`)
30
+ explicit JHybridWallpaperSetSpec(jni::alias_ref<jhybridobject> jThis) :
31
+ HybridObject(HybridWallpaperSetSpec::TAG),
32
+ HybridBase(jThis),
33
+ _javaPart(jni::make_global(jThis)) {}
34
+
35
+ public:
36
+ ~JHybridWallpaperSetSpec() override {
37
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
38
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
39
+ }
40
+
41
+ public:
42
+ size_t getExternalMemorySize() noexcept override;
43
+ void dispose() noexcept override;
44
+ std::string toString() override;
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridWallpaperSetSpec::javaobject>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ std::shared_ptr<Promise<void>> setWallpaper(const std::string& image) override;
58
+
59
+ private:
60
+ friend HybridBase;
61
+ using HybridBase::HybridBase;
62
+ jni::global_ref<JHybridWallpaperSetSpec::javaobject> _javaPart;
63
+ };
64
+
65
+ } // namespace margelo::nitro::reactnativenitrowallpaper
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// HybridWallpaperSetSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.reactnativenitrowallpaper
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.Promise
14
+ import com.margelo.nitro.core.HybridObject
15
+
16
+ /**
17
+ * A Kotlin class representing the WallpaperSet HybridObject.
18
+ * Implement this abstract class to create Kotlin-based instances of WallpaperSet.
19
+ */
20
+ @DoNotStrip
21
+ @Keep
22
+ @Suppress(
23
+ "KotlinJniMissingFunction", "unused",
24
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
25
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
26
+ )
27
+ abstract class HybridWallpaperSetSpec: HybridObject() {
28
+ @DoNotStrip
29
+ private var mHybridData: HybridData = initHybrid()
30
+
31
+ init {
32
+ super.updateNative(mHybridData)
33
+ }
34
+
35
+ override fun updateNative(hybridData: HybridData) {
36
+ mHybridData = hybridData
37
+ super.updateNative(hybridData)
38
+ }
39
+
40
+ // Default implementation of `HybridObject.toString()`
41
+ override fun toString(): String {
42
+ return "[HybridObject WallpaperSet]"
43
+ }
44
+
45
+ // Properties
46
+
47
+
48
+ // Methods
49
+ @DoNotStrip
50
+ @Keep
51
+ abstract fun setWallpaper(image: String): Promise<Unit>
52
+
53
+ private external fun initHybrid(): HybridData
54
+
55
+ companion object {
56
+ protected const val TAG = "HybridWallpaperSetSpec"
57
+ }
58
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// reactnativenitrowallpaperOnLoad.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.reactnativenitrowallpaper
9
+
10
+ import android.util.Log
11
+
12
+ internal class reactnativenitrowallpaperOnLoad {
13
+ companion object {
14
+ private const val TAG = "reactnativenitrowallpaperOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "reactnativenitrowallpaper".
18
+ * This method is idempotent and can be called more than once.
19
+ */
20
+ @JvmStatic
21
+ fun initializeNative() {
22
+ if (didLoad) return
23
+ try {
24
+ Log.i(TAG, "Loading reactnativenitrowallpaper C++ library...")
25
+ System.loadLibrary("reactnativenitrowallpaper")
26
+ Log.i(TAG, "Successfully loaded reactnativenitrowallpaper C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load reactnativenitrowallpaper C++ library! Is it properly installed and linked? " +
30
+ "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
+ throw e
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,81 @@
1
+ #
2
+ # reactnativenitrowallpaper+autolinking.cmake
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © 2025 Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # This is a CMake file that adds all files generated by Nitrogen
9
+ # to the current CMake project.
10
+ #
11
+ # To use it, add this to your CMakeLists.txt:
12
+ # ```cmake
13
+ # include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/reactnativenitrowallpaper+autolinking.cmake)
14
+ # ```
15
+
16
+ # Define a flag to check if we are building properly
17
+ add_definitions(-DBUILDING_REACTNATIVENITROWALLPAPER_WITH_GENERATED_CMAKE_PROJECT)
18
+
19
+ # Enable Raw Props parsing in react-native (for Nitro Views)
20
+ add_definitions(-DRN_SERIALIZABLE_STATE)
21
+
22
+ # Add all headers that were generated by Nitrogen
23
+ include_directories(
24
+ "../nitrogen/generated/shared/c++"
25
+ "../nitrogen/generated/android/c++"
26
+ "../nitrogen/generated/android/"
27
+ )
28
+
29
+ # Add all .cpp sources that were generated by Nitrogen
30
+ target_sources(
31
+ # CMake project name (Android C++ library name)
32
+ reactnativenitrowallpaper PRIVATE
33
+ # Autolinking Setup
34
+ ../nitrogen/generated/android/reactnativenitrowallpaperOnLoad.cpp
35
+ # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridWallpaperSetSpec.cpp
37
+ # Android-specific Nitrogen C++ sources
38
+ ../nitrogen/generated/android/c++/JHybridWallpaperSetSpec.cpp
39
+ )
40
+
41
+ # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
42
+ # Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
43
+ target_compile_definitions(
44
+ reactnativenitrowallpaper PRIVATE
45
+ -DFOLLY_NO_CONFIG=1
46
+ -DFOLLY_HAVE_CLOCK_GETTIME=1
47
+ -DFOLLY_USE_LIBCPP=1
48
+ -DFOLLY_CFG_NO_COROUTINES=1
49
+ -DFOLLY_MOBILE=1
50
+ -DFOLLY_HAVE_RECVMMSG=1
51
+ -DFOLLY_HAVE_PTHREAD=1
52
+ # Once we target android-23 above, we can comment
53
+ # the following line. NDK uses GNU style stderror_r() after API 23.
54
+ -DFOLLY_HAVE_XSI_STRERROR_R=1
55
+ )
56
+
57
+ # Add all libraries required by the generated specs
58
+ find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
59
+ find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
60
+ find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
61
+
62
+ # Link all libraries together
63
+ target_link_libraries(
64
+ reactnativenitrowallpaper
65
+ fbjni::fbjni # <-- Facebook C++ JNI helpers
66
+ ReactAndroid::jsi # <-- RN: JSI
67
+ react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
68
+ )
69
+
70
+ # Link react-native (different prefab between RN 0.75 and RN 0.76)
71
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
72
+ target_link_libraries(
73
+ reactnativenitrowallpaper
74
+ ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
75
+ )
76
+ else()
77
+ target_link_libraries(
78
+ reactnativenitrowallpaper
79
+ ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
80
+ )
81
+ endif()
@@ -0,0 +1,27 @@
1
+ ///
2
+ /// reactnativenitrowallpaper+autolinking.gradle
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /// This is a Gradle file that adds all files generated by Nitrogen
9
+ /// to the current Gradle project.
10
+ ///
11
+ /// To use it, add this to your build.gradle:
12
+ /// ```gradle
13
+ /// apply from: '../nitrogen/generated/android/reactnativenitrowallpaper+autolinking.gradle'
14
+ /// ```
15
+
16
+ logger.warn("[NitroModules] 🔥 reactnativenitrowallpaper is boosted by nitro!")
17
+
18
+ android {
19
+ sourceSets {
20
+ main {
21
+ java.srcDirs += [
22
+ // Nitrogen files
23
+ "${project.projectDir}/../nitrogen/generated/android/kotlin"
24
+ ]
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// reactnativenitrowallpaperOnLoad.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #ifndef BUILDING_REACTNATIVENITROWALLPAPER_WITH_GENERATED_CMAKE_PROJECT
9
+ #error reactnativenitrowallpaperOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
10
+ #endif
11
+
12
+ #include "reactnativenitrowallpaperOnLoad.hpp"
13
+
14
+ #include <jni.h>
15
+ #include <fbjni/fbjni.h>
16
+ #include <NitroModules/HybridObjectRegistry.hpp>
17
+
18
+ #include "JHybridWallpaperSetSpec.hpp"
19
+ #include <NitroModules/DefaultConstructableObject.hpp>
20
+
21
+ namespace margelo::nitro::reactnativenitrowallpaper {
22
+
23
+ int initialize(JavaVM* vm) {
24
+ using namespace margelo::nitro;
25
+ using namespace margelo::nitro::reactnativenitrowallpaper;
26
+ using namespace facebook;
27
+
28
+ return facebook::jni::initialize(vm, [] {
29
+ // Register native JNI methods
30
+ margelo::nitro::reactnativenitrowallpaper::JHybridWallpaperSetSpec::registerNatives();
31
+
32
+ // Register Nitro Hybrid Objects
33
+ HybridObjectRegistry::registerHybridObjectConstructor(
34
+ "WallpaperSet",
35
+ []() -> std::shared_ptr<HybridObject> {
36
+ static DefaultConstructableObject<JHybridWallpaperSetSpec::javaobject> object("com/margelo/nitro/reactnativenitrowallpaper/WallpaperSet");
37
+ auto instance = object.create();
38
+ return instance->cthis()->shared();
39
+ }
40
+ );
41
+ });
42
+ }
43
+
44
+ } // namespace margelo::nitro::reactnativenitrowallpaper
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// reactnativenitrowallpaperOnLoad.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include <jni.h>
9
+ #include <NitroModules/NitroDefines.hpp>
10
+
11
+ namespace margelo::nitro::reactnativenitrowallpaper {
12
+
13
+ /**
14
+ * Initializes the native (C++) part of reactnativenitrowallpaper, and autolinks all Hybrid Objects.
15
+ * Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
16
+ * Example:
17
+ * ```cpp (cpp-adapter.cpp)
18
+ * JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
19
+ * return margelo::nitro::reactnativenitrowallpaper::initialize(vm);
20
+ * }
21
+ * ```
22
+ */
23
+ int initialize(JavaVM* vm);
24
+
25
+ } // namespace margelo::nitro::reactnativenitrowallpaper
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// HybridWallpaperSetSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridWallpaperSetSpec.hpp"
9
+
10
+ namespace margelo::nitro::reactnativenitrowallpaper {
11
+
12
+ void HybridWallpaperSetSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("setWallpaper", &HybridWallpaperSetSpec::setWallpaper);
18
+ });
19
+ }
20
+
21
+ } // namespace margelo::nitro::reactnativenitrowallpaper
@@ -0,0 +1,63 @@
1
+ ///
2
+ /// HybridWallpaperSetSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+
17
+
18
+ #include <NitroModules/Promise.hpp>
19
+ #include <string>
20
+
21
+ namespace margelo::nitro::reactnativenitrowallpaper {
22
+
23
+ using namespace margelo::nitro;
24
+
25
+ /**
26
+ * An abstract base class for `WallpaperSet`
27
+ * Inherit this class to create instances of `HybridWallpaperSetSpec` in C++.
28
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
29
+ * @example
30
+ * ```cpp
31
+ * class HybridWallpaperSet: public HybridWallpaperSetSpec {
32
+ * public:
33
+ * HybridWallpaperSet(...): HybridObject(TAG) { ... }
34
+ * // ...
35
+ * };
36
+ * ```
37
+ */
38
+ class HybridWallpaperSetSpec: public virtual HybridObject {
39
+ public:
40
+ // Constructor
41
+ explicit HybridWallpaperSetSpec(): HybridObject(TAG) { }
42
+
43
+ // Destructor
44
+ ~HybridWallpaperSetSpec() override = default;
45
+
46
+ public:
47
+ // Properties
48
+
49
+
50
+ public:
51
+ // Methods
52
+ virtual std::shared_ptr<Promise<void>> setWallpaper(const std::string& image) = 0;
53
+
54
+ protected:
55
+ // Hybrid Setup
56
+ void loadHybridMethods() override;
57
+
58
+ protected:
59
+ // Tag for logging
60
+ static constexpr auto TAG = "WallpaperSet";
61
+ };
62
+
63
+ } // namespace margelo::nitro::reactnativenitrowallpaper
package/package.json ADDED
@@ -0,0 +1,186 @@
1
+ {
2
+ "name": "react-native-nitro-wallpaper",
3
+ "version": "1.0.0",
4
+ "description": "Set wallpaper on React Native (Android only)",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "cpp",
20
+ "nitrogen",
21
+ "nitro.json",
22
+ "react-native.config.js",
23
+ "!android/build",
24
+ "!android/gradle",
25
+ "!android/gradlew",
26
+ "!android/gradlew.bat",
27
+ "!android/local.properties",
28
+ "!**/__tests__",
29
+ "!**/__fixtures__",
30
+ "!**/__mocks__",
31
+ "!**/.*"
32
+ ],
33
+ "scripts": {
34
+ "example": "yarn workspace react-native-wallpaper-set-example",
35
+ "clean": "del-cli android/build example/android/build example/android/app/build lib",
36
+ "prepare": "bob build",
37
+ "nitrogen": "nitrogen",
38
+ "typecheck": "tsc",
39
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
40
+ "test": "jest --passWithNoTests",
41
+ "release": "release-it --only-version"
42
+ },
43
+ "keywords": [
44
+ "react-native",
45
+ "android",
46
+ "wallpaper",
47
+ "react-native-wallpaper",
48
+ "wallpaper-manager",
49
+ "react-native-wallpaper-manager",
50
+ "set-wallpaper",
51
+ "set-wallpaper-react-native",
52
+ "wallpaper-manager-app",
53
+ "react-native-wallpaper-manager-app",
54
+ "android-wallpaper",
55
+ "change-wallpaper",
56
+ "wallpaper-setter",
57
+ "nitro-modules"
58
+ ],
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "git+https://github.com/RahulMandyal1/react-native-nitro-wallpaper.git"
62
+ },
63
+ "author": "rahulmandyal1 <rahulmandyal079@gmail.com> (https://github.com/RahulMandyal1)",
64
+ "license": "MIT",
65
+ "bugs": {
66
+ "url": "https://github.com/RahulMandyal1/react-native-nitro-wallpaper/issues"
67
+ },
68
+ "homepage": "https://github.com/RahulMandyal1/react-native-nitro-wallpaper#readme",
69
+ "publishConfig": {
70
+ "registry": "https://registry.npmjs.org/"
71
+ },
72
+ "devDependencies": {
73
+ "@commitlint/config-conventional": "^19.8.1",
74
+ "@eslint/compat": "^1.3.2",
75
+ "@eslint/eslintrc": "^3.3.1",
76
+ "@eslint/js": "^9.35.0",
77
+ "@react-native/babel-preset": "0.83.0",
78
+ "@react-native/eslint-config": "0.83.0",
79
+ "@release-it/conventional-changelog": "^10.0.1",
80
+ "@types/jest": "^29.5.14",
81
+ "@types/react": "^19.2.0",
82
+ "commitlint": "^19.8.1",
83
+ "del-cli": "^6.0.0",
84
+ "eslint": "^9.35.0",
85
+ "eslint-config-prettier": "^10.1.8",
86
+ "eslint-plugin-prettier": "^5.5.4",
87
+ "jest": "^29.7.0",
88
+ "lefthook": "^2.0.3",
89
+ "nitrogen": "^0.31.10",
90
+ "prettier": "^2.8.8",
91
+ "react": "19.2.0",
92
+ "react-native": "0.83.0",
93
+ "react-native-builder-bob": "^0.40.17",
94
+ "react-native-nitro-modules": "^0.31.10",
95
+ "release-it": "^19.0.4",
96
+ "turbo": "^2.5.6",
97
+ "typescript": "^5.9.2"
98
+ },
99
+ "peerDependencies": {
100
+ "react": "*",
101
+ "react-native": "*",
102
+ "react-native-nitro-modules": "^0.31.10"
103
+ },
104
+ "workspaces": [
105
+ "example"
106
+ ],
107
+ "packageManager": "yarn@4.11.0",
108
+ "react-native-builder-bob": {
109
+ "source": "src",
110
+ "output": "lib",
111
+ "targets": [
112
+ [
113
+ "custom",
114
+ {
115
+ "script": "nitrogen",
116
+ "clean": "nitrogen/"
117
+ }
118
+ ],
119
+ [
120
+ "module",
121
+ {
122
+ "esm": true
123
+ }
124
+ ],
125
+ [
126
+ "typescript",
127
+ {
128
+ "project": "tsconfig.build.json"
129
+ }
130
+ ]
131
+ ]
132
+ },
133
+ "prettier": {
134
+ "quoteProps": "consistent",
135
+ "singleQuote": true,
136
+ "tabWidth": 2,
137
+ "trailingComma": "es5",
138
+ "useTabs": false
139
+ },
140
+ "jest": {
141
+ "preset": "react-native",
142
+ "modulePathIgnorePatterns": [
143
+ "<rootDir>/example/node_modules",
144
+ "<rootDir>/lib/"
145
+ ]
146
+ },
147
+ "commitlint": {
148
+ "extends": [
149
+ "@commitlint/config-conventional"
150
+ ]
151
+ },
152
+ "release-it": {
153
+ "git": {
154
+ "commitMessage": "chore: release ${version}",
155
+ "tagName": "v${version}"
156
+ },
157
+ "npm": {
158
+ "publish": true
159
+ },
160
+ "github": {
161
+ "release": true
162
+ },
163
+ "plugins": {
164
+ "@release-it/conventional-changelog": {
165
+ "preset": {
166
+ "name": "angular"
167
+ }
168
+ }
169
+ }
170
+ },
171
+ "create-react-native-library": {
172
+ "type": "nitro-module",
173
+ "languages": "kotlin",
174
+ "tools": [
175
+ "eslint",
176
+ "jest",
177
+ "lefthook",
178
+ "release-it"
179
+ ],
180
+ "version": "0.56.0"
181
+ },
182
+ "directories": {
183
+ "example": "example",
184
+ "lib": "lib"
185
+ }
186
+ }
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ // Android-only package, iOS not supported
5
+ android: {
6
+ sourceDir: '../android',
7
+ packageImportPath:
8
+ 'import com.margelo.nitro.reactnativenitrowallpaper.WallpaperSetPackage;',
9
+ },
10
+ },
11
+ },
12
+ };
@@ -0,0 +1,5 @@
1
+ import type { HybridObject } from 'react-native-nitro-modules';
2
+
3
+ export interface WallpaperSet extends HybridObject<{ android: 'kotlin' }> {
4
+ setWallpaper(image: string): Promise<void>;
5
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,17 @@
1
+ import { NitroModules } from 'react-native-nitro-modules';
2
+ import { Platform } from 'react-native';
3
+ import type { WallpaperSet as WallpaperSetSpec } from './WallpaperSet.nitro';
4
+
5
+ const WallpaperSetNative =
6
+ NitroModules.createHybridObject<WallpaperSetSpec>('WallpaperSet');
7
+
8
+ export const WallpaperSet = {
9
+ setWallpaper: async (image: string): Promise<void> => {
10
+ if (Platform.OS === 'ios') {
11
+ throw new Error(
12
+ 'react-native-nitro-wallpaper is Android-only. iOS is not supported.'
13
+ );
14
+ }
15
+ return WallpaperSetNative.setWallpaper(image);
16
+ },
17
+ };