platform.js 8.9 KB

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