廓形仪rn版本-技术调研
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
933 B

  1. import React, { useEffect } from 'react';
  2. import { config } from './config';
  3. import { View, ViewProps } from 'react-native';
  4. import { OverlayProvider } from '@gluestack-ui/overlay';
  5. import { ToastProvider } from '@gluestack-ui/toast';
  6. import { useColorScheme } from 'nativewind';
  7. import { ModeType } from './types';
  8. export function GluestackUIProvider({
  9. mode = 'light',
  10. ...props
  11. }: {
  12. mode?: ModeType;
  13. children?: React.ReactNode;
  14. style?: ViewProps['style'];
  15. }) {
  16. const { colorScheme, setColorScheme } = useColorScheme();
  17. useEffect(() => {
  18. setColorScheme(mode);
  19. // eslint-disable-next-line react-hooks/exhaustive-deps
  20. }, [mode]);
  21. return (
  22. <View
  23. style={[
  24. config[colorScheme!],
  25. { flex: 1, height: '100%', width: '100%' },
  26. props.style,
  27. ]}
  28. >
  29. <OverlayProvider>
  30. <ToastProvider>{props.children}</ToastProvider>
  31. </OverlayProvider>
  32. </View>
  33. );
  34. }