Theme.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. searchInputBorderActive: '#475569',
  19. searchInputText: '#e2e8f0',
  20. searchInputTextPlaceholder: '#888',
  21. }
  22. };
  23. const themeLight = {
  24. dark: false,
  25. barStyle: 'dark-content',
  26. colors: {
  27. primary: '#fff',
  28. textOnPrimary: '#334155',
  29. textOnPrimaryDisabled: '#eee',
  30. background: '#F3F4F6',
  31. toolbarBorder: '#cbd5e1',
  32. drawerBackground: '#F3F4F6',
  33. drawerText: '#1890ff',
  34. drawerBorder: '#cbd5e1',
  35. statusBar: '#eee',
  36. activityIndicator: '#334155',
  37. searchInputBackground: '#F7F9FC',
  38. searchInputBorder: '#cbd5e1',
  39. searchInputBorderActive: '#cbd5e1',
  40. searchInputText: '#334155',
  41. searchInputTextPlaceholder: '#888',
  42. }
  43. };
  44. function useTheme (s) {
  45. var colorScheme = Appearance.getColorScheme();
  46. var a = s.split('.'),
  47. ret = 'dark' === colorScheme ? themeDark : themeLight,
  48. i = 0;
  49. for (; i < a.length ; i++) {
  50. if ('undefined' !== typeof(ret[a[i]]))
  51. ret = ret[a[i]];
  52. }
  53. return ret;
  54. }
  55. export {themeDark, themeLight, useTheme};