commonColor.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // @flow
  2. import color from 'color';
  3. import { Platform, Dimensions, PixelRatio } from 'react-native';
  4. export const PLATFORM = {
  5. ANDROID: 'android',
  6. IOS: 'ios',
  7. MATERIAL: 'material',
  8. WEB: 'web'
  9. };
  10. const deviceHeight = Dimensions.get('window').height;
  11. const deviceWidth = Dimensions.get('window').width;
  12. const platform = Platform.OS;
  13. const platformStyle = undefined;
  14. const isIphoneX =
  15. platform === PLATFORM.IOS &&
  16. (deviceHeight === 812 ||
  17. deviceWidth === 812 ||
  18. deviceHeight === 896 ||
  19. deviceWidth === 896);
  20. export default {
  21. platformStyle,
  22. platform,
  23. // Accordion
  24. headerStyle: '#edebed',
  25. iconStyle: '#000',
  26. contentStyle: '#f5f4f5',
  27. expandedIconStyle: '#000',
  28. accordionBorderColor: '#d3d3d3',
  29. // ActionSheet
  30. elevation: 4,
  31. containerTouchableBackgroundColor: 'rgba(0,0,0,0.4)',
  32. innerTouchableBackgroundColor: '#fff',
  33. listItemHeight: 50,
  34. listItemBorderColor: 'transparent',
  35. marginHorizontal: -15,
  36. marginLeft: 14,
  37. marginTop: 15,
  38. minHeight: 56,
  39. padding: 15,
  40. touchableTextColor: '#757575',
  41. // Android
  42. androidRipple: true,
  43. androidRippleColor: 'rgba(256, 256, 256, 0.3)',
  44. androidRippleColorDark: 'rgba(0, 0, 0, 0.15)',
  45. buttonUppercaseAndroidText: true,
  46. // Badge
  47. badgeBg: '#ED1727',
  48. badgeColor: '#fff',
  49. badgePadding: platform === PLATFORM.IOS ? 3 : 0,
  50. // Button
  51. buttonFontFamily: platform === PLATFORM.IOS ? 'System' : 'Roboto_medium',
  52. buttonDisabledBg: '#b5b5b5',
  53. buttonPadding: 6,
  54. get buttonPrimaryBg() {
  55. return this.brandPrimary;
  56. },
  57. get buttonPrimaryColor() {
  58. return this.inverseTextColor;
  59. },
  60. get buttonInfoBg() {
  61. return this.brandInfo;
  62. },
  63. get buttonInfoColor() {
  64. return this.inverseTextColor;
  65. },
  66. get buttonSuccessBg() {
  67. return this.brandSuccess;
  68. },
  69. get buttonSuccessColor() {
  70. return this.inverseTextColor;
  71. },
  72. get buttonDangerBg() {
  73. return this.brandDanger;
  74. },
  75. get buttonDangerColor() {
  76. return this.inverseTextColor;
  77. },
  78. get buttonWarningBg() {
  79. return this.brandWarning;
  80. },
  81. get buttonWarningColor() {
  82. return this.inverseTextColor;
  83. },
  84. get buttonTextSize() {
  85. return platform === PLATFORM.IOS
  86. ? this.fontSizeBase * 1.1
  87. : this.fontSizeBase - 1;
  88. },
  89. get buttonTextSizeLarge() {
  90. return this.fontSizeBase * 1.5;
  91. },
  92. get buttonTextSizeSmall() {
  93. return this.fontSizeBase * 0.8;
  94. },
  95. get borderRadiusLarge() {
  96. return this.fontSizeBase * 3.8;
  97. },
  98. get iconSizeLarge() {
  99. return this.iconFontSize * 1.5;
  100. },
  101. get iconSizeSmall() {
  102. return this.iconFontSize * 0.6;
  103. },
  104. // Card
  105. cardDefaultBg: '#fff',
  106. cardBorderColor: '#ccc',
  107. cardBorderRadius: 2,
  108. cardItemPadding: platform === PLATFORM.IOS ? 10 : 12,
  109. // CheckBox
  110. CheckboxRadius: platform === PLATFORM.IOS ? 13 : 0,
  111. CheckboxBorderWidth: platform === PLATFORM.IOS ? 1 : 2,
  112. CheckboxPaddingLeft: platform === PLATFORM.IOS ? 4 : 2,
  113. CheckboxPaddingBottom: platform === PLATFORM.IOS ? 0 : 5,
  114. CheckboxIconSize: platform === PLATFORM.IOS ? 21 : 16,
  115. CheckboxIconMarginTop: platform === PLATFORM.IOS ? undefined : 1,
  116. CheckboxFontSize: platform === PLATFORM.IOS ? 23 / 0.9 : 17,
  117. checkboxBgColor: '#039BE5',
  118. checkboxSize: 20,
  119. checkboxTickColor: '#fff',
  120. // Color
  121. brandPrimary: platform === PLATFORM.IOS ? '#007aff' : '#3F51B5',
  122. brandInfo: '#62B1F6',
  123. brandSuccess: '#5cb85c',
  124. brandDanger: '#d9534f',
  125. brandWarning: '#f0ad4e',
  126. brandDark: '#000',
  127. brandLight: '#f4f4f4',
  128. // Container
  129. containerBgColor: '#fff',
  130. // Date Picker
  131. datePickerTextColor: '#000',
  132. datePickerBg: 'transparent',
  133. // FAB
  134. fabWidth: 56,
  135. // Font
  136. DefaultFontSize: 16,
  137. fontFamily: platform === PLATFORM.IOS ? 'System' : 'Roboto',
  138. fontSizeBase: 15,
  139. get fontSizeH1() {
  140. return this.fontSizeBase * 1.8;
  141. },
  142. get fontSizeH2() {
  143. return this.fontSizeBase * 1.6;
  144. },
  145. get fontSizeH3() {
  146. return this.fontSizeBase * 1.4;
  147. },
  148. // Footer
  149. footerHeight: 55,
  150. footerDefaultBg: platform === PLATFORM.IOS ? '#F8F8F8' : '#3F51B5',
  151. footerPaddingBottom: 0,
  152. // FooterTab
  153. tabBarTextColor: platform === PLATFORM.IOS ? '#737373' : '#bfc6ea',
  154. tabBarTextSize: platform === PLATFORM.IOS ? 14 : 11,
  155. activeTab: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  156. sTabBarActiveTextColor: '#007aff',
  157. tabBarActiveTextColor: platform === PLATFORM.IOS ? '#2874F0' : '#fff',
  158. tabActiveBgColor: platform === PLATFORM.IOS ? '#cde1f9' : '#3F51B5',
  159. // Header
  160. toolbarBtnColor: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  161. toolbarDefaultBg: platform === PLATFORM.IOS ? '#F8F8F8' : '#3F51B5',
  162. toolbarHeight: platform === PLATFORM.IOS ? 64 : 56,
  163. toolbarSearchIconSize: platform === PLATFORM.IOS ? 20 : 23,
  164. toolbarInputColor: platform === PLATFORM.IOS ? '#CECDD2' : '#fff',
  165. searchBarHeight: platform === PLATFORM.IOS ? 30 : 40,
  166. searchBarInputHeight: platform === PLATFORM.IOS ? 30 : 50,
  167. toolbarBtnTextColor: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  168. iosStatusbar: 'dark-content',
  169. toolbarDefaultBorder: platform === PLATFORM.IOS ? '#a7a6ab' : '#3F51B5',
  170. get statusBarColor() {
  171. return color(this.toolbarDefaultBg)
  172. .darken(0.2)
  173. .hex();
  174. },
  175. get darkenHeader() {
  176. return color(this.tabBgColor)
  177. .darken(0.03)
  178. .hex();
  179. },
  180. // Icon
  181. iconFamily: 'Ionicons',
  182. iconFontSize: platform === PLATFORM.IOS ? 30 : 28,
  183. iconHeaderSize: platform === PLATFORM.IOS ? 33 : 24,
  184. // InputGroup
  185. inputFontSize: 17,
  186. inputBorderColor: '#D9D5DC',
  187. inputSuccessBorderColor: '#2b8339',
  188. inputErrorBorderColor: '#ed2f2f',
  189. inputHeightBase: 50,
  190. get inputColor() {
  191. return this.textColor;
  192. },
  193. get inputColorPlaceholder() {
  194. return '#575757';
  195. },
  196. // Line Height
  197. buttonLineHeight: 19,
  198. lineHeightH1: 32,
  199. lineHeightH2: 27,
  200. lineHeightH3: 22,
  201. lineHeight: platform === PLATFORM.IOS ? 20 : 24,
  202. // List
  203. listBg: 'transparent',
  204. listBorderColor: '#c9c9c9',
  205. listDividerBg: '#f4f4f4',
  206. listBtnUnderlayColor: '#DDD',
  207. listItemPadding: platform === PLATFORM.IOS ? 10 : 12,
  208. listNoteColor: '#808080',
  209. listNoteSize: 13,
  210. listItemSelected: platform === PLATFORM.IOS ? '#007aff' : '#3F51B5',
  211. // Progress Bar
  212. defaultProgressColor: '#E4202D',
  213. inverseProgressColor: '#1A191B',
  214. // Radio Button
  215. radioBtnSize: platform === PLATFORM.IOS ? 25 : 23,
  216. radioSelectedColorAndroid: '#3F51B5',
  217. radioBtnLineHeight: platform === PLATFORM.IOS ? 29 : 24,
  218. get radioColor() {
  219. return this.brandPrimary;
  220. },
  221. // Segment
  222. segmentBackgroundColor: platform === PLATFORM.IOS ? '#F8F8F8' : '#3F51B5',
  223. segmentActiveBackgroundColor: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  224. segmentTextColor: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  225. segmentActiveTextColor: platform === PLATFORM.IOS ? '#fff' : '#3F51B5',
  226. segmentBorderColor: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  227. segmentBorderColorMain: platform === PLATFORM.IOS ? '#a7a6ab' : '#3F51B5',
  228. // Spinner
  229. defaultSpinnerColor: '#45D56E',
  230. inverseSpinnerColor: '#1A191B',
  231. // Tab
  232. tabDefaultBg: platform === PLATFORM.IOS ? '#F8F8F8' : '#3F51B5',
  233. topTabBarTextColor: platform === PLATFORM.IOS ? '#6b6b6b' : '#b3c7f9',
  234. topTabBarActiveTextColor: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  235. topTabBarBorderColor: platform === PLATFORM.IOS ? '#a7a6ab' : '#fff',
  236. topTabBarActiveBorderColor: platform === PLATFORM.IOS ? '#007aff' : '#fff',
  237. // Tabs
  238. tabBgColor: '#F8F8F8',
  239. tabFontSize: 15,
  240. // Text
  241. textColor: '#000',
  242. inverseTextColor: '#fff',
  243. noteFontSize: 14,
  244. get defaultTextColor() {
  245. return this.textColor;
  246. },
  247. // Title
  248. titleFontfamily: platform === PLATFORM.IOS ? 'System' : 'Roboto_medium',
  249. titleFontSize: platform === PLATFORM.IOS ? 17 : 19,
  250. subTitleFontSize: platform === PLATFORM.IOS ? 11 : 14,
  251. subtitleColor: platform === PLATFORM.IOS ? '#000' : '#fff',
  252. titleFontColor: platform === PLATFORM.IOS ? '#000' : '#fff',
  253. // Other
  254. borderRadiusBase: platform === PLATFORM.IOS ? 5 : 2,
  255. borderWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
  256. contentPadding: 10,
  257. dropdownLinkColor: '#414142',
  258. inputLineHeight: 24,
  259. deviceWidth,
  260. deviceHeight,
  261. isIphoneX,
  262. inputGroupRoundedBorderRadius: 30,
  263. // iPhoneX SafeArea
  264. Inset: {
  265. portrait: {
  266. topInset: 24,
  267. leftInset: 0,
  268. rightInset: 0,
  269. bottomInset: 34
  270. },
  271. landscape: {
  272. topInset: 0,
  273. leftInset: 44,
  274. rightInset: 44,
  275. bottomInset: 21
  276. }
  277. }
  278. };