ramilushev / react-native-background-color Goto Github PK
View Code? Open in Web Editor NEWSet the root app background color from JavaScript
License: The Unlicense
Set the root app background color from JavaScript
License: The Unlicense
At the top of my file I have:
import BackgroundColor from 'react-native-background-color';
Now this works on Android, but in iOS it is giving me error:
error: bundling failed: Error: While trying to resolve module `react-native-background-color` from file `/Users/noitidart/Documents/Did/App/AppCover/index.ios.js`, the package `/Users/noitidart/Documents/Did/node_modules/react-native-background-color/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/noitidart/Documents/Did/node_modules/react-native-background-color/index`. Indeed, none of these files exist:
* `/Users/noitidart/Documents/Did/node_modules/react-native-background-color/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
* `/Users/noitidart/Documents/Did/node_modules/react-native-background-color/index/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`
at ResolutionRequest.resolveDependency (/Users/noitidart/Documents/Did/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:95:15)
at DependencyGraph.resolveDependency (/Users/noitidart/Documents/Did/node_modules/metro/src/node-haste/DependencyGraph.js:238:485)
at Object.resolve (/Users/noitidart/Documents/Did/node_modules/metro/src/lib/transformHelpers.js:180:25)
at dependencies.map.result (/Users/noitidart/Documents/Did/node_modules/metro/src/DeltaBundler/traverseDependencies.js:311:29)
at Array.map (<anonymous>)
at resolveDependencies (/Users/noitidart/Documents/Did/node_modules/metro/src/DeltaBundler/traverseDependencies.js:307:16)
at /Users/noitidart/Documents/Did/node_modules/metro/src/DeltaBundler/traverseDependencies.js:164:33
at Generator.next (<anonymous>)
at step (/Users/noitidart/Documents/Did/node_modules/metro/src/DeltaBundler/traverseDependencies.js:266:307)
at /Users/noitidart/Documents/Did/node_modules/metro/src/DeltaBundler/traverseDependencies.js:266:467
I was hoping to avoid creating platform specific files.
I've implemented the library, it looks like a very simple implementation, however, my applications (both iOS and Android) are just closing on the BackgroundColor.setColor('#FFFFFF');
line.
There is nothing printed, no error, nothing. Any ideas why?
I'm using this library to get around this bug: facebook/react-native#17800. The library works well, and there doesn't seem to be a problem if I set the color to #00000000
like so:
useEffect(() => {
if (Platform.OS !== 'android') return;
setTimeout(() => {
BackgroundColor.setColor('#00000000');
}, 0);
}, []);
Then the flash of color behind the keyboard is hidden entirely, whereas with #FFFFFF
there's a flash of white.
I'm mostly asking because I haven't seen this mentioned anywhere, so I'm concerned there might be a gotcha I don't know about. Generally, I'm not very familiar with how Android handles color values, but as far as I can tell from discussions like this it seems like #00000000
should be valid.
If this is a valid approach, I'd be happy to open a PR to document it, because I think it could be helpful to users of this library!
It change first time after thant it can not be change means it it can not change light theme and darktheme
I upgraded to 0.57.1 - in dev mode it works fine. But when trying to build production I get the following errors:
> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
bundle: Writing bundle output to: C:\Users\Mercurius\Documents\GitHub\diddo\android\app\build\generated\assets\react\release\index.android.bundle
bundle: Done writing bundle output
bundle: Copying 1 asset files
bundle: Done copying assets
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-background-color:verifyReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 47s
140 actionable tasks: 132 executed, 8 up-to-date
QA tester recently found a bug with the library - when clicking the device back buttons twice to exit out of the app, and then upon re-opening the app, the splash logo shows.
I have been able to reproduce this as well.
I have created a background image in my Android using native technique, this is for splash screen. Like this:
This image stays in the background forever. When keyboard or switching views I sometimes see it. Do you have any ideas on how to remove it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.