1
0

Theme.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {Appearance} from 'react-native';
  2. const themeDark = {
  3. dark: true,
  4. barStyle: 'light-content',
  5. colors: {
  6. primary: '#1e293b',
  7. textOnPrimary: '#e2e8f0',
  8. textOnPrimaryDisabled: '#111',
  9. background: '#000000',
  10. toolbarBorder: '#475569',
  11. drawerBackground: '#F3F4F6',
  12. drawerText: '#1890ff',
  13. drawerBorder: '#475569',
  14. statusBar: '#000',
  15. activityIndicator: '#e2e8f0',
  16. searchInputBackground: '#000000',
  17. searchInputBorder: '#475569',
  18. searchInputText: '#e2e8f0',
  19. }
  20. };
  21. const themeLight = {
  22. dark: false,
  23. barStyle: 'dark-content',
  24. colors: {
  25. primary: '#fff',
  26. textOnPrimary: '#334155',
  27. textOnPrimaryDisabled: '#eee',
  28. background: '#F3F4F6',
  29. toolbarBorder: '#cbd5e1',
  30. drawerBackground: '#F3F4F6',
  31. drawerText: '#1890ff',
  32. drawerBorder: '#cbd5e1',
  33. statusBar: '#eee',
  34. activityIndicator: '#334155',
  35. searchInputBackground: '#F7F9FC',
  36. searchInputBorder: '#cbd5e1',
  37. searchInputText: '#334155',
  38. }
  39. };
  40. function useTheme (s) {
  41. var colorScheme = Appearance.getColorScheme();
  42. var a = s.split('.'),
  43. ret = 'dark' === colorScheme ? themeDark : themeLight,
  44. i = 0;
  45. for (; i < a.length ; i++) {
  46. if ('undefined' !== typeof(ret[a[i]]))
  47. ret = ret[a[i]];
  48. }
  49. return ret;
  50. }
  51. export {themeDark, themeLight, useTheme};