I was upgrading my version of libraries in my android project and I saw that rememberSystemUiController() is deprecated. I was doing like this to make the status and navigation bar green -
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.setStatusBarColor(
color = Color(0xFF076C07),
darkIcons = false
)
systemUiController.setNavigationBarColor(
color = Color(0xFF076C07),
darkIcons = false
)
}
What should I do now to achieve the same effect?
I am assuming that you are referring to Accompanist System UI Controller, which had that function. The documentation states:
This library is deprecated, and the API is no longer maintained. We recommend forking the implementation and customising it to your needs. The original documentation is below.
Migration
Recommendation: If you were using SystemUIController to go edge-to-edge in your activity and change the system bar colors and system bar icon colors, use the new Activity.enableEdgeToEdge method available in androidx.activity 1.8.0-alpha03 and later. This method backports the scrims used on some versions of Android. This is a sample PR of the migration to the new method and removing the dependency on SystemUIController in Now in Android.
For other usages, migrate to using WindowInsetsControllerCompat or window APIs directly.
For your use case, their "Migration" instructions do not seem that helpful. Hence, you might be best off forking their implementation. The last-published version of that function seems to be the 0.36.0
tagged version. It seems to be self-contained, without imports of anything else from Accompanist. So, in principle, you should be able to copy that file into your project (either in its original com.google.accompanist.systemuicontroller
package, or moved into one of your packages) and use your local copy.
Alternatively, you could just keep depending on the 0.36.0
version of that artifact. Personally, given its un-maintained state, I would fork and use a local copy, per my preceding paragraph.