Header.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. // @flow
  2. import { PixelRatio, StatusBar } from "react-native";
  3. import variable from "./../variables/platform";
  4. export default (variables /*: * */ = variable) => {
  5. const platformStyle = variables.platformStyle;
  6. const platform = variables.platform;
  7. const headerTheme = {
  8. ".span": {
  9. height: 128,
  10. "NativeBase.Left": {
  11. alignSelf: "flex-start"
  12. },
  13. "NativeBase.Body": {
  14. alignSelf: "flex-end",
  15. alignItems: "flex-start",
  16. justifyContent: "center",
  17. paddingBottom: 26
  18. },
  19. "NativeBase.Right": {
  20. alignSelf: "flex-start"
  21. }
  22. },
  23. ".hasSubtitle": {
  24. "NativeBase.Body": {
  25. "NativeBase.Title": {
  26. fontSize: variables.titleFontSize - 2,
  27. fontFamily: variables.titleFontfamily,
  28. textAlign: "center",
  29. fontWeight: "500",
  30. paddingBottom: 3
  31. },
  32. "NativeBase.Subtitle": {
  33. fontSize: variables.subTitleFontSize,
  34. fontFamily: variables.titleFontfamily,
  35. color: variables.subtitleColor,
  36. textAlign: "center"
  37. }
  38. }
  39. },
  40. ".transparent": {
  41. backgroundColor: "transparent",
  42. borderBottomColor: "transparent",
  43. elevation: 0,
  44. shadowColor: null,
  45. shadowOffset: null,
  46. shadowRadius: null,
  47. shadowOpacity: null,
  48. paddingTop: platform === "android" ? StatusBar.currentHeight : undefined,
  49. height: platform === "android" ? variables.toolbarHeight + StatusBar.currentHeight : variables.toolbarHeight
  50. },
  51. ".noShadow": {
  52. elevation: 0,
  53. shadowColor: null,
  54. shadowOffset: null,
  55. shadowRadius: null,
  56. shadowOpacity: null
  57. },
  58. ".hasTabs": {
  59. elevation: 0,
  60. shadowColor: null,
  61. shadowOffset: null,
  62. shadowRadius: null,
  63. shadowOpacity: null,
  64. borderBottomWidth: null
  65. },
  66. ".hasSegment": {
  67. elevation: 0,
  68. shadowColor: null,
  69. shadowOffset: null,
  70. shadowRadius: null,
  71. shadowOpacity: null,
  72. borderBottomWidth: null,
  73. "NativeBase.Left": {
  74. flex: 0.3
  75. },
  76. "NativeBase.Right": {
  77. flex: 0.3
  78. },
  79. "NativeBase.Body": {
  80. flex: 1,
  81. "NativeBase.Segment": {
  82. marginRight: 0,
  83. alignSelf: "center",
  84. "NativeBase.Button": {
  85. paddingLeft: 0,
  86. paddingRight: 0
  87. }
  88. }
  89. }
  90. },
  91. ".noLeft": {
  92. "NativeBase.Left": {
  93. width: platform === "ios" ? undefined : 0,
  94. flex: platform === "ios" ? 1 : 0
  95. },
  96. "NativeBase.Body": {
  97. "NativeBase.Title": {
  98. paddingLeft: platform === "ios" ? undefined : 10
  99. },
  100. "NativeBase.Subtitle": {
  101. paddingLeft: platform === "ios" ? undefined : 10
  102. }
  103. }
  104. },
  105. "NativeBase.Button": {
  106. justifyContent: "center",
  107. alignSelf: "center",
  108. alignItems: "center",
  109. ".transparent": {
  110. "NativeBase.Text": {
  111. color: variables.toolbarBtnTextColor,
  112. fontWeight: "600"
  113. },
  114. "NativeBase.Icon": {
  115. color: variables.toolbarBtnColor
  116. },
  117. "NativeBase.IconNB": {
  118. color: variables.toolbarBtnColor
  119. },
  120. paddingHorizontal: variables.buttonPadding
  121. },
  122. paddingHorizontal: 15
  123. },
  124. ".searchBar": {
  125. "NativeBase.Item": {
  126. "NativeBase.Icon": {
  127. backgroundColor: "transparent",
  128. color: variables.dropdownLinkColor,
  129. fontSize: variables.toolbarSearchIconSize,
  130. alignItems: "center",
  131. marginTop: 2,
  132. paddingRight: 10,
  133. paddingLeft: 10
  134. },
  135. "NativeBase.IconNB": {
  136. backgroundColor: "transparent",
  137. color: null,
  138. alignSelf: "center"
  139. },
  140. "NativeBase.Input": {
  141. alignSelf: "center",
  142. lineHeight: null,
  143. height: variables.searchBarInputHeight
  144. },
  145. alignSelf: "center",
  146. alignItems: "center",
  147. justifyContent: "flex-start",
  148. flex: 1,
  149. height: variables.searchBarHeight,
  150. borderColor: "transparent",
  151. backgroundColor: variables.toolbarInputColor
  152. },
  153. "NativeBase.Button": {
  154. ".transparent": {
  155. "NativeBase.Text": {
  156. fontWeight: "500"
  157. },
  158. paddingHorizontal: null,
  159. paddingLeft: platform === "ios" ? 10 : null
  160. },
  161. paddingHorizontal: platform === "ios" ? undefined : null,
  162. width: platform === "ios" ? undefined : 0,
  163. height: platform === "ios" ? undefined : 0
  164. }
  165. },
  166. ".rounded": {
  167. "NativeBase.Item": {
  168. borderRadius:
  169. platform === "ios" && platformStyle !== "material" ? 25 : 3
  170. }
  171. },
  172. "NativeBase.Left": {
  173. "NativeBase.Button": {
  174. ".hasText": {
  175. marginLeft: -10,
  176. height: 30,
  177. "NativeBase.Icon": {
  178. color: variables.toolbarBtnColor,
  179. fontSize: variables.iconHeaderSize,
  180. marginTop: 2,
  181. marginRight: 5,
  182. marginLeft: 2
  183. },
  184. "NativeBase.Text": {
  185. color: variables.toolbarBtnTextColor,
  186. fontSize: platform === "ios" ? 17 : 0,
  187. marginLeft: 7,
  188. lineHeight: 19.5
  189. },
  190. "NativeBase.IconNB": {
  191. color: variables.toolbarBtnColor,
  192. fontSize: variables.iconHeaderSize,
  193. marginTop: 2,
  194. marginRight: 5,
  195. marginLeft: 2
  196. }
  197. },
  198. ".transparent": {
  199. marginLeft:
  200. platform === "ios" && platformStyle !== "material" ? -3 : 0,
  201. "NativeBase.Icon": {
  202. color: variables.toolbarBtnColor,
  203. fontSize:
  204. platform === "ios" && variables.platformStyle !== "material"
  205. ? variables.iconHeaderSize + 1
  206. : variables.iconHeaderSize,
  207. marginTop: 0,
  208. marginRight: 2,
  209. marginLeft: 1,
  210. paddingTop: 1
  211. },
  212. "NativeBase.IconNB": {
  213. color: variables.toolbarBtnColor,
  214. fontSize:
  215. platform === "ios" && variables.platformStyle !== "material"
  216. ? variables.iconHeaderSize + 1
  217. : variables.iconHeaderSize - 2,
  218. marginTop: 0,
  219. marginRight: 2,
  220. marginLeft: 1,
  221. paddingTop: 1
  222. },
  223. "NativeBase.Text": {
  224. color: variables.toolbarBtnTextColor,
  225. fontSize: platform === "ios" ? 17 : 0,
  226. top: platform === "ios" ? 1 : -1.5,
  227. paddingLeft:
  228. platform === "ios" && platformStyle !== "material" ? 2 : 5,
  229. paddingRight:
  230. platform === "ios" && platformStyle !== "material"
  231. ? undefined
  232. : 10
  233. },
  234. backgroundColor: "transparent",
  235. borderColor: null,
  236. elevation: 0,
  237. shadowColor: null,
  238. shadowOffset: null,
  239. shadowRadius: null,
  240. shadowOpacity: null
  241. },
  242. "NativeBase.Icon": {
  243. color: variables.toolbarBtnColor
  244. },
  245. "NativeBase.IconNB": {
  246. color: variables.toolbarBtnColor
  247. },
  248. alignSelf: null,
  249. paddingRight: variables.buttonPadding,
  250. paddingLeft: platform === "ios" && platformStyle !== "material" ? 4 : 8
  251. },
  252. flex: platform === "ios" && platformStyle !== "material" ? 1 : 0.4,
  253. alignSelf: "center",
  254. alignItems: "flex-start"
  255. },
  256. "NativeBase.Body": {
  257. flex: 1,
  258. alignItems:
  259. platform === "ios" && platformStyle !== "material"
  260. ? "center"
  261. : "flex-start",
  262. alignSelf: "center",
  263. "NativeBase.Segment": {
  264. borderWidth: 0,
  265. alignSelf: "flex-end",
  266. marginRight: platform === "ios" ? -40 : -55
  267. },
  268. "NativeBase.Button": {
  269. alignSelf: "center",
  270. ".transparent": {
  271. backgroundColor: "transparent"
  272. },
  273. "NativeBase.Icon": {
  274. color: variables.toolbarBtnColor
  275. },
  276. "NativeBase.IconNB": {
  277. color: variables.toolbarBtnColor
  278. },
  279. "NativeBase.Text": {
  280. color: variables.inverseTextColor,
  281. backgroundColor: "transparent"
  282. }
  283. }
  284. },
  285. "NativeBase.Right": {
  286. "NativeBase.Button": {
  287. ".hasText": {
  288. height: 30,
  289. "NativeBase.Icon": {
  290. color: variables.toolbarBtnColor,
  291. fontSize: variables.iconHeaderSize - 2,
  292. marginTop: 2,
  293. marginRight: 2,
  294. marginLeft: 5
  295. },
  296. "NativeBase.Text": {
  297. color: variables.toolbarBtnTextColor,
  298. fontSize: platform === "ios" ? 17 : 14,
  299. lineHeight: 19.5
  300. },
  301. "NativeBase.IconNB": {
  302. color: variables.toolbarBtnColor,
  303. fontSize: variables.iconHeaderSize - 2,
  304. marginTop: 2,
  305. marginRight: 2,
  306. marginLeft: 5
  307. }
  308. },
  309. ".transparent": {
  310. marginRight: platform === "ios" ? -9 : -5,
  311. paddingLeft: 15,
  312. paddingRight: 12,
  313. paddingHorizontal: 15,
  314. borderRadius: 50,
  315. "NativeBase.Icon": {
  316. color: variables.toolbarBtnColor,
  317. fontSize: variables.iconHeaderSize - 2,
  318. marginTop: 0,
  319. marginLeft: 2,
  320. marginRight: 0
  321. // paddingTop: 0
  322. },
  323. "NativeBase.IconNB": {
  324. color: variables.toolbarBtnColor,
  325. fontSize: variables.iconHeaderSize - 2,
  326. marginTop: 0,
  327. marginLeft: 2,
  328. marginRight: 0
  329. // paddingTop: 0
  330. },
  331. "NativeBase.Text": {
  332. color: variables.toolbarBtnTextColor,
  333. fontSize: platform === "ios" ? 17 : 14,
  334. top: platform === "ios" ? 1 : -1.5,
  335. paddingRight:
  336. platform === "ios" && variables.platformStyle !== "material"
  337. ? 0
  338. : undefined
  339. },
  340. backgroundColor: "transparent",
  341. borderColor: null,
  342. elevation: 0,
  343. shadowColor: null,
  344. shadowOffset: null,
  345. shadowRadius: null,
  346. shadowOpacity: null
  347. },
  348. "NativeBase.Icon": {
  349. color: variables.toolbarBtnColor
  350. },
  351. "NativeBase.IconNB": {
  352. color: variables.toolbarBtnColor
  353. },
  354. alignSelf: null,
  355. paddingHorizontal: variables.buttonPadding
  356. },
  357. flex: 1,
  358. alignSelf: "center",
  359. alignItems: "flex-end",
  360. flexDirection: "row",
  361. justifyContent: "flex-end"
  362. },
  363. backgroundColor: variables.toolbarDefaultBg,
  364. flexDirection: "row",
  365. // paddingHorizontal: 10,
  366. paddingLeft:
  367. platform === "ios" && variables.platformStyle !== "material" ? 6 : 10,
  368. paddingRight: 10,
  369. justifyContent: "center",
  370. paddingTop: platform === "ios" ? 18 : 0,
  371. borderBottomWidth:
  372. platform === "ios" ? 1 / PixelRatio.getPixelSizeForLayoutSize(1) : 0,
  373. borderBottomColor: variables.toolbarDefaultBorder,
  374. height:
  375. variables.platform === "ios" && variables.platformStyle === "material"
  376. ? variables.toolbarHeight + StatusBar.height
  377. : variables.toolbarHeight,
  378. elevation: 3,
  379. shadowColor: platformStyle === "material" ? "#000" : undefined,
  380. shadowOffset:
  381. platformStyle === "material" ? { width: 0, height: 2 } : undefined,
  382. shadowOpacity: platformStyle === "material" ? 0.2 : undefined,
  383. shadowRadius: platformStyle === "material" ? 1.2 : undefined,
  384. top: 0,
  385. left: 0,
  386. right: 0
  387. };
  388. return headerTheme;
  389. };