accompanist icon indicating copy to clipboard operation
accompanist copied to clipboard

[System UI Controller] Request - Provide current statusBarColor, navigationBarColor

Open miduch opened this issue 3 years ago • 11 comments

Description It would be useful if SystemUiController could be used to get current values statusBarColor, navigationBarColor. One usecase would be user moving from some main screen which has already set e.g. statusBarColor to a different screen which wants to set a different statusBar color and have possibility of reverting back to orig value

Steps to reproduce

Expected behavior

Additional context

miduch avatar Mar 23 '22 05:03 miduch

I thought it was a bug that when navigating back the original color is not retained

LSafer-Agile avatar Apr 20 '22 22:04 LSafer-Agile

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar May 21 '22 03:05 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 21 '22 03:06 github-actions[bot]

I used this kind of solution by using DisposableEffect to toggle the original statusBarColor back when Lifecycle goes to STOP state

 DisposableEffect(viewLifecycleOwner) {
        val observer = LifecycleEventObserver { _, event ->
            if (event == Lifecycle.Event.ON_START) {
               // Toggle transparent bar
                systemUiController.setStatusBarColor(Color.Black.copy(0.32f))
            } else if (event == Lifecycle.Event.ON_STOP) {
               // Toggle original
                systemUiController.setStatusBarColor(statusBarColor)
            }
        }

        viewLifecycleOwner.lifecycle.addObserver(observer)

        onDispose {
            viewLifecycleOwner.lifecycle.removeObserver(observer)
        }
    }

Veeksi avatar Jun 22 '22 06:06 Veeksi

@Veeksi Thanks for your code, it works fine in my project.

Any chance to provide such function in system ui controller as an extension or optional params?

xiaozhikang0916 avatar Jun 22 '22 08:06 xiaozhikang0916

@xiaozhikang0916 Dunno about that, but I would like to see that kind of functionality straight from the library itself!

Veeksi avatar Jun 22 '22 09:06 Veeksi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 23 '22 03:07 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 25 '22 04:08 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 25 '22 03:09 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 26 '22 03:10 github-actions[bot]

I second this request. I have the use case where a detail screen changes the status bar color. When the composable is disposed, I want to restore the previous color. It could look like this:

DisposableEffect(Unit) {
    val prevColor = systemUiController.statusBarColor
    systemUiController.setStatusBarColor(Color.White)
    onDispose { 
        systemUiController.setStatusBarColor(prevColor)
    }
}

svenjacobs avatar Nov 10 '22 15:11 svenjacobs

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Dec 11 '22 03:12 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jan 27 '23 03:01 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Mar 14 '23 03:03 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 29 '23 03:04 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 16 '23 03:06 github-actions[bot]

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 01 '23 03:08 github-actions[bot]

Unfortunately Accompanist SystemUIController has been deprecated and won't be supported going forwards. I am closing this issue. For more information please see our update blog

bentrengrove avatar Aug 25 '23 05:08 bentrengrove