I’m facing a problem when trying to use PlatformColor as an argument for the setBackgroundColorAsync function in the expo-navigation-bar package. The function expects a ColorValue, which can be either a string or an OpaqueColorValue.
However, when I pass a PlatformColor to setBackgroundColorAsync, I encounter the following error:
WARN: Possible Unhandled Promise Rejection (id: 1):
Error: Argument of an incompatible class: class java.util.HashMap cannot be passed as an argument to parameter expecting int.
This error is surprising because PlatformColor works fine with other components like the backgroundColor prop of a View, which also expects a ColorValue.
For eg, this code works perfectly:
<View style={{backgroundColor: PlatformColor('@android:color/system_neutral2_900')}}>
</View>
But not this:
NavigationBar.setBackgroundColorAsync(PlatformColor('@android:color/system_neutral2_900'));
And if i use processColor, like this:
import { processColor, PlatformColor } from 'react-native';
const color = processColor(PlatformColor('@android/system_neutral2_900'));
NavigationBar.setBackgroundColorAsync(color);
It says: Cannot convert ‘[object Object]’ to a Kotlin type
I’m trying to dynamically set the navigation bar color to match the current theme of my Android app. Instead of using a static color like black, I want the navigation bar color to adjust to the app’s overall color scheme.
Is there any way to resolve this issue and pass the PlatformColor as an argument to setBackgroundColorAsync? or maybe a workaround would be helpful