Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Button.js 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. // @flow
  2. import variable from "./../variables/platform";
  3. export default (variables /*: * */ = variable) => {
  4. const platformStyle = variables.platformStyle;
  5. const platform = variables.platform;
  6. const darkCommon = {
  7. "NativeBase.Text": {
  8. color: variables.brandDark
  9. },
  10. "NativeBase.Icon": {
  11. color: variables.brandDark
  12. },
  13. "NativeBase.IconNB": {
  14. color: variables.brandDark
  15. }
  16. };
  17. const lightCommon = {
  18. "NativeBase.Text": {
  19. color: variables.brandLight
  20. },
  21. "NativeBase.Icon": {
  22. color: variables.brandLight
  23. },
  24. "NativeBase.IconNB": {
  25. color: variables.brandLight
  26. }
  27. };
  28. const primaryCommon = {
  29. "NativeBase.Text": {
  30. color: variables.btnPrimaryBg
  31. },
  32. "NativeBase.Icon": {
  33. color: variables.btnPrimaryBg
  34. },
  35. "NativeBase.IconNB": {
  36. color: variables.btnPrimaryBg
  37. }
  38. };
  39. const successCommon = {
  40. "NativeBase.Text": {
  41. color: variables.btnSuccessBg
  42. },
  43. "NativeBase.Icon": {
  44. color: variables.btnSuccessBg
  45. },
  46. "NativeBase.IconNB": {
  47. color: variables.btnSuccessBg
  48. }
  49. };
  50. const infoCommon = {
  51. "NativeBase.Text": {
  52. color: variables.btnInfoBg
  53. },
  54. "NativeBase.Icon": {
  55. color: variables.btnInfoBg
  56. },
  57. "NativeBase.IconNB": {
  58. color: variables.btnInfoBg
  59. }
  60. };
  61. const warningCommon = {
  62. "NativeBase.Text": {
  63. color: variables.btnWarningBg
  64. },
  65. "NativeBase.Icon": {
  66. color: variables.btnWarningBg
  67. },
  68. "NativeBase.IconNB": {
  69. color: variables.btnWarningBg
  70. }
  71. };
  72. const dangerCommon = {
  73. "NativeBase.Text": {
  74. color: variables.btnDangerBg
  75. },
  76. "NativeBase.Icon": {
  77. color: variables.btnDangerBg
  78. },
  79. "NativeBase.IconNB": {
  80. color: variables.btnDangerBg
  81. }
  82. };
  83. const buttonTheme = {
  84. ".disabled": {
  85. ".transparent": {
  86. backgroundColor: null,
  87. "NativeBase.Text": {
  88. color: variables.btnDisabledBg
  89. },
  90. "NativeBase.Icon": {
  91. color: variables.btnDisabledBg
  92. },
  93. "NativeBase.IconNB": {
  94. color: variables.btnDisabledBg
  95. }
  96. },
  97. "NativeBase.Icon": {
  98. color: variables.brandLight
  99. },
  100. "NativeBase.IconNB": {
  101. color: variables.brandLight
  102. },
  103. backgroundColor: variables.btnDisabledBg
  104. },
  105. ".bordered": {
  106. ".dark": {
  107. ...darkCommon,
  108. backgroundColor: "transparent",
  109. borderColor: variables.brandDark,
  110. borderWidth: variables.borderWidth * 2
  111. },
  112. ".light": {
  113. ...lightCommon,
  114. backgroundColor: "transparent",
  115. borderColor: variables.brandLight,
  116. borderWidth: variables.borderWidth * 2
  117. },
  118. ".primary": {
  119. ...primaryCommon,
  120. backgroundColor: "transparent",
  121. borderColor: variables.btnPrimaryBg,
  122. borderWidth: variables.borderWidth * 2
  123. },
  124. ".success": {
  125. ...successCommon,
  126. backgroundColor: "transparent",
  127. borderColor: variables.btnSuccessBg,
  128. borderWidth: variables.borderWidth * 2
  129. },
  130. ".info": {
  131. ...infoCommon,
  132. backgroundColor: "transparent",
  133. borderColor: variables.btnInfoBg,
  134. borderWidth: variables.borderWidth * 2
  135. },
  136. ".warning": {
  137. ...warningCommon,
  138. backgroundColor: "transparent",
  139. borderColor: variables.btnWarningBg,
  140. borderWidth: variables.borderWidth * 2
  141. },
  142. ".danger": {
  143. ...dangerCommon,
  144. backgroundColor: "transparent",
  145. borderColor: variables.btnDangerBg,
  146. borderWidth: variables.borderWidth * 2
  147. },
  148. ".disabled": {
  149. backgroundColor: null,
  150. borderColor: variables.btnDisabledBg,
  151. borderWidth: variables.borderWidth * 2,
  152. "NativeBase.Text": {
  153. color: variables.btnDisabledBg
  154. }
  155. },
  156. ...primaryCommon,
  157. borderWidth: variables.borderWidth * 2,
  158. elevation: null,
  159. shadowColor: null,
  160. shadowOffset: null,
  161. shadowOpacity: null,
  162. shadowRadius: null,
  163. backgroundColor: "transparent"
  164. },
  165. ".dark": {
  166. ".bordered": {
  167. ...darkCommon
  168. },
  169. backgroundColor: variables.brandDark
  170. },
  171. ".light": {
  172. ".transparent": {
  173. ...lightCommon,
  174. backgroundColor: null
  175. },
  176. ".bordered": {
  177. ...lightCommon
  178. },
  179. ...darkCommon,
  180. backgroundColor: variables.brandLight
  181. },
  182. ".primary": {
  183. ".bordered": {
  184. ...primaryCommon
  185. },
  186. backgroundColor: variables.btnPrimaryBg
  187. },
  188. ".success": {
  189. ".bordered": {
  190. ...successCommon
  191. },
  192. backgroundColor: variables.btnSuccessBg
  193. },
  194. ".info": {
  195. ".bordered": {
  196. ...infoCommon
  197. },
  198. backgroundColor: variables.btnInfoBg
  199. },
  200. ".warning": {
  201. ".bordered": {
  202. ...warningCommon
  203. },
  204. backgroundColor: variables.btnWarningBg
  205. },
  206. ".danger": {
  207. ".bordered": {
  208. ...dangerCommon
  209. },
  210. backgroundColor: variables.btnDangerBg
  211. },
  212. ".block": {
  213. justifyContent: "center",
  214. alignSelf: "stretch"
  215. },
  216. ".full": {
  217. justifyContent: "center",
  218. alignSelf: "stretch",
  219. borderRadius: 0
  220. },
  221. ".rounded": {
  222. // paddingHorizontal: variables.buttonPadding + 20,
  223. borderRadius: variables.borderRadiusLarge
  224. },
  225. ".transparent": {
  226. backgroundColor: "transparent",
  227. elevation: 0,
  228. shadowColor: null,
  229. shadowOffset: null,
  230. shadowRadius: null,
  231. shadowOpacity: null,
  232. ...primaryCommon,
  233. ".dark": {
  234. ...darkCommon,
  235. backgroundColor: null
  236. },
  237. ".danger": {
  238. ...dangerCommon,
  239. backgroundColor: null
  240. },
  241. ".warning": {
  242. ...warningCommon,
  243. backgroundColor: null
  244. },
  245. ".info": {
  246. ...infoCommon,
  247. backgroundColor: null
  248. },
  249. ".primary": {
  250. ...primaryCommon,
  251. backgroundColor: null
  252. },
  253. ".success": {
  254. ...successCommon,
  255. backgroundColor: null
  256. },
  257. ".light": {
  258. ...lightCommon,
  259. backgroundColor: null
  260. },
  261. ".disabled": {
  262. backgroundColor: "transparent",
  263. borderColor: variables.btnDisabledBg,
  264. borderWidth: variables.borderWidth * 2,
  265. "NativeBase.Text": {
  266. color: variables.btnDisabledBg
  267. },
  268. "NativeBase.Icon": {
  269. color: variables.btnDisabledBg
  270. },
  271. "NativeBase.IconNB": {
  272. color: variables.btnDisabledBg
  273. }
  274. }
  275. },
  276. ".small": {
  277. height: 30,
  278. "NativeBase.Text": {
  279. fontSize: 14
  280. },
  281. "NativeBase.Icon": {
  282. fontSize: 20,
  283. paddingTop: 0
  284. },
  285. "NativeBase.IconNB": {
  286. fontSize: 20,
  287. paddingTop: 0
  288. }
  289. },
  290. ".large": {
  291. height: 60,
  292. "NativeBase.Text": {
  293. fontSize: 22,
  294. }
  295. },
  296. ".capitalize": {},
  297. ".vertical": {
  298. flexDirection: "column",
  299. height: null
  300. },
  301. "NativeBase.Text": {
  302. fontFamily: variables.btnFontFamily,
  303. marginLeft: 0,
  304. marginRight: 0,
  305. color: variables.btnTextColor,
  306. fontSize: variables.btnTextSize,
  307. paddingHorizontal: 16,
  308. backgroundColor: "transparent"
  309. // childPosition: 1
  310. },
  311. "NativeBase.Icon": {
  312. color: variables.btnTextColor,
  313. fontSize: 24,
  314. marginHorizontal: 16,
  315. paddingTop: platform === "ios" ? 2 : undefined
  316. },
  317. "NativeBase.IconNB": {
  318. color: variables.btnTextColor,
  319. fontSize: 24,
  320. marginHorizontal: 16,
  321. paddingTop: platform === "ios" ? 2 : undefined
  322. },
  323. ".iconLeft": {
  324. "NativeBase.Text": {
  325. marginLeft: 0
  326. },
  327. "NativeBase.IconNB": {
  328. marginRight: 0,
  329. marginLeft: 16
  330. },
  331. "NativeBase.Icon": {
  332. marginRight: 0,
  333. marginLeft: 16
  334. }
  335. },
  336. ".iconRight": {
  337. "NativeBase.Text": {
  338. marginRight: 0
  339. },
  340. "NativeBase.IconNB": {
  341. marginLeft: 0,
  342. marginRight: 16
  343. },
  344. "NativeBase.Icon": {
  345. marginLeft: 0,
  346. marginRight: 16
  347. }
  348. },
  349. ".picker": {
  350. "NativeBase.Text": {
  351. ".note": {
  352. fontSize: 16,
  353. lineHeight: null
  354. }
  355. }
  356. },
  357. paddingVertical: variables.buttonPadding,
  358. // paddingHorizontal: variables.buttonPadding + 10,
  359. backgroundColor: variables.btnPrimaryBg,
  360. borderRadius: variables.borderRadiusBase,
  361. borderColor: variables.btnPrimaryBg,
  362. borderWidth: null,
  363. height: 45,
  364. alignSelf: "flex-start",
  365. flexDirection: "row",
  366. elevation: 2,
  367. shadowColor: platformStyle === "material" ? variables.brandDark : undefined,
  368. shadowOffset:
  369. platformStyle === "material" ? { width: 0, height: 2 } : undefined,
  370. shadowOpacity: platformStyle === "material" ? 0.2 : undefined,
  371. shadowRadius: platformStyle === "material" ? 1.2 : undefined,
  372. alignItems: "center",
  373. justifyContent: "space-between"
  374. };
  375. return buttonTheme;
  376. };