react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Dynamically changing dark/light mode of the navigator

Open assimovt opened this issue 4 years ago • 1 comments

Hello.

I've got a question regarding theming the storybook navigator. I've followed the example in this repository and configured the theme like this:

import { Appearance } from 'react-native'
import { getStorybookUI, configure } from '@storybook/react-native'
import theme from 'ui/theme'

configure(() => {
  // my stories
}, module)

const StorybookUIRoot = getStorybookUI({
  asyncStorage: null,
  theme:
    Appearance.getColorScheme() === 'dark'
      ? theme.dark.storybook
      : theme.light.storybook,
})

export default StorybookUIRoot

It works well, but I have to reload the simulator every time I change the appearance. So, how can I dynamically apply the theme of the storybook navigator (not UI components, they're handled outside with my custom theme context), for instance using color scheme hook?

assimovt avatar Apr 23 '21 08:04 assimovt

@assimovt hey sorry for the slow reply, will have to check and get back to you.

dannyhw avatar May 01 '21 15:05 dannyhw

@dannyhw Any updates on this ?

Also am thinking of an usecase in which we can set it directly from the addon. I have created a new addon for Themes with options Light, Dark, Auto. Changing anything from here would directly update the theme for the entire storybook

satheshrgs avatar Oct 10 '22 16:10 satheshrgs

hey yeah sorry I guess I forgot to respond at the time, currently its not really possible to change the theme at runtime without doing a reload of the app. However I think it would be valuable change to enable this, I can only really promise to add it to the backlog for now however I'm always open to PR's.

dannyhw avatar Oct 10 '22 18:10 dannyhw

Cool, Thanks

satheshrgs avatar Oct 10 '22 18:10 satheshrgs

there is now a dark/light mode that will dynamically change when you change the device appearance settings.

dannyhw avatar Jul 14 '23 10:07 dannyhw