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.8KB

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