Theme.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import {Appearance} from 'react-native';
  2. const themeDark = {
  3. dark: true,
  4. iosBarStyle: 'light-content',
  5. colors: {
  6. primary: '#1890ff',
  7. textOnPrimary: '#f3f4f5',
  8. background: '#123',
  9. text: '#f3f4f5',
  10. drawerBackground: '#f3f4f5',
  11. drawerText: '#1890ff',
  12. statusBar: '#076fd3',
  13. activityIndicator: '#f3f4f5',
  14. }
  15. };
  16. const themeLight = {
  17. dark: false,
  18. iosBarStyle: 'light-content',
  19. colors: {
  20. primary: '#1890ff',
  21. textOnPrimary: '#f3f4f5',
  22. background: '#edf1f7',
  23. text: '#595959',
  24. drawerBackground: '#edf1f7',
  25. drawerText: '#1890ff',
  26. statusBar: '#076fd3',
  27. activityIndicator: '#f3f4f5',
  28. }
  29. };
  30. function useTheme (s) {
  31. var colorScheme = Appearance.getColorScheme();
  32. var a = s.split('.'),
  33. ret = 'dark' === colorScheme ? themeDark : themeLight,
  34. i = 0;
  35. for (; i < a.length ; i++) {
  36. if ('undefined' !== typeof(ret[a[i]]))
  37. ret = ret[a[i]];
  38. }
  39. return ret;
  40. }
  41. export {themeDark, themeLight, useTheme};