react-native-elements#ThemeProvider TypeScript Examples

The following examples show how to use react-native-elements#ThemeProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: App-test.tsx    From magento_react_native_graphql with MIT License 6 votes vote down vote up
it('renders correctly', () => {
  renderer.create(
    <MockedProvider mocks={mocks} addTypename={false}>
      <ThemeProvider>
        <OverflowMenuProvider>
          <Navigator />
        </OverflowMenuProvider>
      </ThemeProvider>
    </MockedProvider>,
  );
});
Example #2
Source File: App.tsx    From magento_react_native_graphql with MIT License 5 votes vote down vote up
App = (): React.ReactElement => {
  const [client, setClient] = useState<ApolloClient<any>>();
  const colorScheme: ColorSchemeName = useColorScheme();

  useEffect(() => {
    getApolloClient()
      .then(setClient)
      .catch(e => console.log(e));

    const listener = ({
      colorScheme: newColorScheme,
    }: {
      colorScheme: ColorSchemeName;
    }) => {
      // do something when color scheme changes
      const theme = newColorScheme === 'dark' ? darkTheme : lightTheme;
      FlashMessage.setColorTheme({
        success: theme.colors.success,
        info: theme.colors.info,
        warning: theme.colors.warning,
        danger: theme.colors.error,
      });
    };

    Appearance.addChangeListener(listener);

    return () => Appearance.removeChangeListener(listener);
  }, []);

  if (client) {
    return (
      <ApolloProvider client={client}>
        <SafeAreaProvider>
          <ThemeProvider
            useDark={colorScheme === 'dark'}
            theme={colorScheme === 'dark' ? darkTheme : lightTheme}
          >
            <>
              <OverflowMenuProvider>
                <Navigator />
              </OverflowMenuProvider>
              <FlashMessage position="top" />
            </>
          </ThemeProvider>
        </SafeAreaProvider>
      </ApolloProvider>
    );
  }

  // TODO: SplashScreen logic
  return <Spinner />;
}