ListItem.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. // @flow
  2. import { Platform, PixelRatio } from 'react-native';
  3. import pickerTheme from './Picker';
  4. import variable from './../variables/platform';
  5. import { PLATFORM } from './../variables/commonColor';
  6. export default (variables /* : * */ = variable) => {
  7. const platform = variables.platform;
  8. const selectedStyle = {
  9. 'NativeBase.Text': {
  10. color: variables.listItemSelected
  11. },
  12. 'NativeBase.Icon': {
  13. color: variables.listItemSelected
  14. }
  15. };
  16. const listItemTheme = {
  17. 'NativeBase.InputGroup': {
  18. 'NativeBase.Icon': {
  19. paddingRight: 5
  20. },
  21. 'NativeBase.IconNB': {
  22. paddingRight: 5
  23. },
  24. 'NativeBase.Input': {
  25. paddingHorizontal: 5
  26. },
  27. flex: 1,
  28. borderWidth: null,
  29. margin: -10,
  30. borderBottomColor: 'transparent'
  31. },
  32. '.searchBar': {
  33. 'NativeBase.Item': {
  34. 'NativeBase.Icon': {
  35. backgroundColor: 'transparent',
  36. color: variables.dropdownLinkColor,
  37. fontSize:
  38. platform === PLATFORM.IOS
  39. ? variables.iconFontSize - 10
  40. : variables.iconFontSize - 5,
  41. alignItems: 'center',
  42. marginTop: 2,
  43. paddingRight: 8
  44. },
  45. 'NativeBase.IconNB': {
  46. backgroundColor: 'transparent',
  47. color: null,
  48. alignSelf: 'center'
  49. },
  50. 'NativeBase.Input': {
  51. alignSelf: 'center'
  52. },
  53. alignSelf: 'center',
  54. alignItems: 'center',
  55. justifyContent: 'flex-start',
  56. flex: 1,
  57. height: platform === PLATFORM.IOS ? 30 : 40,
  58. borderColor: 'transparent',
  59. backgroundColor: '#fff',
  60. borderRadius: 5
  61. },
  62. 'NativeBase.Button': {
  63. '.transparent': {
  64. 'NativeBase.Text': {
  65. fontWeight: '500'
  66. },
  67. paddingHorizontal: null,
  68. paddingLeft: platform === PLATFORM.IOS ? 10 : null
  69. },
  70. paddingHorizontal: platform === PLATFORM.IOS ? undefined : null,
  71. width: platform === PLATFORM.IOS ? undefined : 0,
  72. height: platform === PLATFORM.IOS ? undefined : 0
  73. },
  74. backgroundColor: variables.toolbarInputColor,
  75. padding: 10,
  76. marginLeft: null
  77. },
  78. 'NativeBase.CheckBox': {
  79. marginLeft: -10,
  80. marginRight: 10
  81. },
  82. '.first': {
  83. '.itemHeader': {
  84. paddingTop: variables.listItemPadding + 3
  85. }
  86. },
  87. '.itemHeader': {
  88. '.first': {
  89. paddingTop: variables.listItemPadding + 3
  90. },
  91. borderBottomWidth:
  92. platform === PLATFORM.IOS ? variables.borderWidth : null,
  93. marginLeft: null,
  94. padding: variables.listItemPadding,
  95. paddingLeft: variables.listItemPadding + 5,
  96. paddingTop:
  97. platform === PLATFORM.IOS ? variables.listItemPadding + 25 : undefined,
  98. paddingBottom:
  99. platform === PLATFORM.ANDROID ? variables.listItemPadding + 20 : undefined,
  100. flexDirection: 'row',
  101. borderColor: variables.listBorderColor,
  102. 'NativeBase.Text': {
  103. fontSize: 14,
  104. color: platform === PLATFORM.IOS ? undefined : variables.listNoteColor
  105. }
  106. },
  107. '.itemDivider': {
  108. borderBottomWidth: null,
  109. marginLeft: null,
  110. padding: variables.listItemPadding,
  111. paddingLeft: variables.listItemPadding + 5,
  112. backgroundColor: variables.listDividerBg,
  113. flexDirection: 'row',
  114. borderColor: variables.listBorderColor
  115. },
  116. '.selected': {
  117. 'NativeBase.Left': {
  118. ...selectedStyle
  119. },
  120. 'NativeBase.Body': {
  121. ...selectedStyle
  122. },
  123. 'NativeBase.Right': {
  124. ...selectedStyle
  125. },
  126. ...selectedStyle
  127. },
  128. 'NativeBase.Left': {
  129. 'NativeBase.Body': {
  130. 'NativeBase.Text': {
  131. '.note': {
  132. color: variables.listNoteColor,
  133. fontWeight: '200'
  134. },
  135. fontWeight: '600'
  136. },
  137. marginLeft: 10,
  138. alignItems: null,
  139. alignSelf: null
  140. },
  141. 'NativeBase.Icon': {
  142. width: variables.iconFontSize - 10,
  143. fontSize: variables.iconFontSize - 10
  144. },
  145. 'NativeBase.IconNB': {
  146. width: variables.iconFontSize - 10,
  147. fontSize: variables.iconFontSize - 10
  148. },
  149. 'NativeBase.Text': {
  150. alignSelf: 'center'
  151. },
  152. flexDirection: 'row'
  153. },
  154. 'NativeBase.Body': {
  155. 'NativeBase.Text': {
  156. marginHorizontal: variables.listItemPadding,
  157. '.note': {
  158. color: variables.listNoteColor,
  159. fontWeight: '200'
  160. }
  161. },
  162. alignSelf: null,
  163. alignItems: null
  164. },
  165. 'NativeBase.Right': {
  166. 'NativeBase.Badge': {
  167. alignSelf: null
  168. },
  169. 'NativeBase.PickerNB': {
  170. 'NativeBase.Button': {
  171. marginRight: -15,
  172. 'NativeBase.Text': {
  173. color: variables.topTabBarActiveTextColor
  174. }
  175. }
  176. },
  177. 'NativeBase.Button': {
  178. alignSelf: null,
  179. '.transparent': {
  180. 'NativeBase.Text': {
  181. color: variables.topTabBarActiveTextColor
  182. }
  183. }
  184. },
  185. 'NativeBase.Icon': {
  186. alignSelf: null,
  187. fontSize: variables.iconFontSize - 8,
  188. color: '#c9c8cd'
  189. },
  190. 'NativeBase.IconNB': {
  191. alignSelf: null,
  192. fontSize: variables.iconFontSize - 8,
  193. color: '#c9c8cd'
  194. },
  195. 'NativeBase.Text': {
  196. '.note': {
  197. color: variables.listNoteColor,
  198. fontWeight: '200'
  199. },
  200. alignSelf: null
  201. },
  202. 'NativeBase.Thumbnail': {
  203. alignSelf: null
  204. },
  205. 'NativeBase.Image': {
  206. alignSelf: null
  207. },
  208. 'NativeBase.Radio': {
  209. alignSelf: null
  210. },
  211. 'NativeBase.Checkbox': {
  212. alignSelf: null
  213. },
  214. 'NativeBase.Switch': {
  215. alignSelf: null
  216. },
  217. padding: null,
  218. flex: 0.28
  219. },
  220. 'NativeBase.Text': {
  221. '.note': {
  222. color: variables.listNoteColor,
  223. fontWeight: '200'
  224. },
  225. alignSelf: 'center'
  226. },
  227. '.last': {
  228. marginLeft: -(variables.listItemPadding + 5),
  229. paddingLeft: (variables.listItemPadding + 5) * 2,
  230. top: 1
  231. },
  232. '.avatar': {
  233. 'NativeBase.Left': {
  234. flex: 0,
  235. alignSelf: 'flex-start',
  236. paddingTop: 14
  237. },
  238. 'NativeBase.Body': {
  239. 'NativeBase.Text': {
  240. marginLeft: null
  241. },
  242. flex: 1,
  243. paddingVertical: variables.listItemPadding,
  244. borderBottomWidth: variables.borderWidth,
  245. borderColor: variables.listBorderColor,
  246. marginLeft: variables.listItemPadding + 5
  247. },
  248. 'NativeBase.Right': {
  249. 'NativeBase.Text': {
  250. '.note': {
  251. fontSize: variables.noteFontSize - 2
  252. }
  253. },
  254. flex: 0,
  255. paddingRight: variables.listItemPadding + 5,
  256. alignSelf: 'stretch',
  257. paddingVertical: variables.listItemPadding,
  258. borderBottomWidth: variables.borderWidth,
  259. borderColor: variables.listBorderColor
  260. },
  261. '.noBorder': {
  262. 'NativeBase.Body': {
  263. borderBottomWidth: null
  264. },
  265. 'NativeBase.Right': {
  266. borderBottomWidth: null
  267. }
  268. },
  269. borderBottomWidth: null,
  270. paddingVertical: null,
  271. paddingRight: null
  272. },
  273. '.thumbnail': {
  274. 'NativeBase.Left': {
  275. flex: 0
  276. },
  277. 'NativeBase.Body': {
  278. 'NativeBase.Text': {
  279. marginLeft: null
  280. },
  281. flex: 1,
  282. paddingVertical: variables.listItemPadding + 8,
  283. borderBottomWidth: variables.borderWidth,
  284. borderColor: variables.listBorderColor,
  285. marginLeft: variables.listItemPadding + 5
  286. },
  287. 'NativeBase.Right': {
  288. 'NativeBase.Button': {
  289. '.transparent': {
  290. 'NativeBase.Text': {
  291. fontSize: variables.listNoteSize,
  292. color: variables.sTabBarActiveTextColor
  293. }
  294. },
  295. height: null
  296. },
  297. flex: 0,
  298. justifyContent: 'center',
  299. alignSelf: 'stretch',
  300. paddingRight: variables.listItemPadding + 5,
  301. paddingVertical: variables.listItemPadding + 5,
  302. borderBottomWidth: variables.borderWidth,
  303. borderColor: variables.listBorderColor
  304. },
  305. '.noBorder': {
  306. 'NativeBase.Body': {
  307. borderBottomWidth: null
  308. },
  309. 'NativeBase.Right': {
  310. borderBottomWidth: null
  311. }
  312. },
  313. borderBottomWidth: null,
  314. paddingVertical: null,
  315. paddingRight: null
  316. },
  317. '.icon': {
  318. '.last': {
  319. 'NativeBase.Body': {
  320. borderBottomWidth: null
  321. },
  322. 'NativeBase.Right': {
  323. borderBottomWidth: null
  324. },
  325. borderBottomWidth: variables.borderWidth,
  326. borderColor: variables.listBorderColor
  327. },
  328. 'NativeBase.Left': {
  329. 'NativeBase.Button': {
  330. 'NativeBase.IconNB': {
  331. marginHorizontal: null,
  332. fontSize: variables.iconFontSize - 5
  333. },
  334. 'NativeBase.Icon': {
  335. marginHorizontal: null,
  336. fontSize: variables.iconFontSize - 8
  337. },
  338. alignSelf: 'center',
  339. height: 29,
  340. width: 29,
  341. borderRadius: 6,
  342. paddingVertical: null,
  343. paddingHorizontal: null,
  344. alignItems: 'center',
  345. justifyContent: 'center'
  346. },
  347. 'NativeBase.Icon': {
  348. width: variables.iconFontSize - 5,
  349. fontSize: variables.iconFontSize - 2
  350. },
  351. 'NativeBase.IconNB': {
  352. width: variables.iconFontSize - 5,
  353. fontSize: variables.iconFontSize - 2
  354. },
  355. paddingRight: variables.listItemPadding + 5,
  356. flex: 0,
  357. height: 44,
  358. justifyContent: 'center',
  359. alignItems: 'center'
  360. },
  361. 'NativeBase.Body': {
  362. 'NativeBase.Text': {
  363. marginLeft: null,
  364. fontSize: 17
  365. },
  366. flex: 1,
  367. height: 44,
  368. justifyContent: 'center',
  369. borderBottomWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
  370. borderColor: variables.listBorderColor
  371. },
  372. 'NativeBase.Right': {
  373. 'NativeBase.Text': {
  374. textAlign: 'center',
  375. color: '#8F8E95',
  376. fontSize: 17
  377. },
  378. 'NativeBase.IconNB': {
  379. color: '#C8C7CC',
  380. fontSize: variables.iconFontSize - 10,
  381. alignSelf: 'center',
  382. paddingLeft: 10,
  383. paddingTop: 3
  384. },
  385. 'NativeBase.Icon': {
  386. color: '#C8C7CC',
  387. fontSize: variables.iconFontSize - 10,
  388. alignSelf: 'center',
  389. paddingLeft: 10,
  390. paddingTop: 3
  391. },
  392. 'NativeBase.Switch': {
  393. marginRight: Platform.OS === PLATFORM.IOS ? undefined : -5,
  394. alignSelf: null
  395. },
  396. 'NativeBase.PickerNB': {
  397. ...pickerTheme()
  398. },
  399. flexDirection: 'row',
  400. alignItems: 'center',
  401. flex: 0,
  402. alignSelf: 'stretch',
  403. height: 44,
  404. justifyContent: 'flex-end',
  405. borderBottomWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
  406. borderColor: variables.listBorderColor,
  407. paddingRight: variables.listItemPadding + 5
  408. },
  409. '.noBorder': {
  410. 'NativeBase.Body': {
  411. borderBottomWidth: null
  412. },
  413. 'NativeBase.Right': {
  414. borderBottomWidth: null
  415. }
  416. },
  417. borderBottomWidth: null,
  418. paddingVertical: null,
  419. paddingRight: null,
  420. height: 44,
  421. justifyContent: 'center'
  422. },
  423. '.noBorder': {
  424. borderBottomWidth: null
  425. },
  426. '.noIndent': {
  427. marginLeft: null,
  428. padding: variables.listItemPadding,
  429. paddingLeft: variables.listItemPadding + 6
  430. },
  431. alignItems: 'center',
  432. flexDirection: 'row',
  433. paddingRight: variables.listItemPadding + 6,
  434. paddingVertical: variables.listItemPadding + 3,
  435. marginLeft: variables.listItemPadding + 6,
  436. borderBottomWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
  437. backgroundColor: variables.listBg,
  438. borderColor: variables.listBorderColor
  439. };
  440. return listItemTheme;
  441. };