index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import _ from "lodash";
  2. import bodyTheme from "./Body";
  3. import leftTheme from "./Left";
  4. import rightTheme from "./Right";
  5. import headerTheme from "./Header";
  6. import switchTheme from "./Switch";
  7. import thumbnailTheme from "./Thumbnail";
  8. import containerTheme from "./Container";
  9. import contentTheme from "./Content";
  10. import buttonTheme from "./Button";
  11. import titleTheme from "./Title";
  12. import subtitleTheme from "./Subtitle";
  13. import inputGroupTheme from "./InputGroup";
  14. import badgeTheme from "./Badge";
  15. import checkBoxTheme from "./CheckBox";
  16. import cardTheme from "./Card";
  17. import radioTheme from "./Radio";
  18. import h3Theme from "./H3";
  19. import h2Theme from "./H2";
  20. import h1Theme from "./H1";
  21. import footerTheme from "./Footer";
  22. import footerTabTheme from "./FooterTab";
  23. import fabTheme from "./Fab";
  24. import itemTheme from "./Item";
  25. import labelTheme from "./Label";
  26. import textAreaTheme from "./Textarea";
  27. import textTheme from "./Text";
  28. import toastTheme from "./Toast";
  29. import tabTheme from "./Tab";
  30. import tabBarTheme from "./TabBar";
  31. import tabContainerTheme from "./TabContainer";
  32. import viewTheme from "./View";
  33. import tabHeadingTheme from "./TabHeading";
  34. import iconTheme from "./Icon";
  35. import inputTheme from "./Input";
  36. import swipeRowTheme from "./SwipeRow";
  37. import segmentTheme from "./Segment";
  38. import spinnerTheme from "./Spinner";
  39. import cardItemTheme from "./CardItem";
  40. import listItemTheme from "./ListItem";
  41. import formTheme from "./Form";
  42. import separatorTheme from "./Separator";
  43. import variable from "./../variables/platform";
  44. export default (variables = variable) => {
  45. const theme = {
  46. variables,
  47. "NativeBase.Left": {
  48. ...leftTheme(variables)
  49. },
  50. "NativeBase.Right": {
  51. ...rightTheme(variables)
  52. },
  53. "NativeBase.Body": {
  54. ...bodyTheme(variables)
  55. },
  56. "NativeBase.Header": {
  57. ...headerTheme(variables)
  58. },
  59. "NativeBase.Button": {
  60. ...buttonTheme(variables)
  61. },
  62. "NativeBase.Title": {
  63. ...titleTheme(variables)
  64. },
  65. "NativeBase.Subtitle": {
  66. ...subtitleTheme(variables)
  67. },
  68. "NativeBase.InputGroup": {
  69. ...inputGroupTheme(variables)
  70. },
  71. "NativeBase.Input": {
  72. ...inputTheme(variables)
  73. },
  74. "NativeBase.Badge": {
  75. ...badgeTheme(variables)
  76. },
  77. "NativeBase.CheckBox": {
  78. ...checkBoxTheme(variables)
  79. },
  80. "NativeBase.Radio": {
  81. ...radioTheme(variables)
  82. },
  83. "NativeBase.Card": {
  84. ...cardTheme()
  85. },
  86. "NativeBase.CardItem": {
  87. ...cardItemTheme(variables)
  88. },
  89. "NativeBase.Toast": {
  90. ...toastTheme(variables)
  91. },
  92. "NativeBase.H1": {
  93. ...h1Theme(variables)
  94. },
  95. "NativeBase.H2": {
  96. ...h2Theme(variables)
  97. },
  98. "NativeBase.H3": {
  99. ...h3Theme(variables)
  100. },
  101. "NativeBase.Form": {
  102. ...formTheme(variables)
  103. },
  104. "NativeBase.Container": {
  105. ...containerTheme(variables)
  106. },
  107. "NativeBase.Content": {
  108. ...contentTheme(variables)
  109. },
  110. "NativeBase.Footer": {
  111. ...footerTheme(variables)
  112. },
  113. "NativeBase.Tabs": {
  114. flex: 1
  115. },
  116. "NativeBase.FooterTab": {
  117. ...footerTabTheme(variables)
  118. },
  119. "NativeBase.ListItem": {
  120. ...listItemTheme(variables)
  121. },
  122. "NativeBase.ListItem1": {
  123. ...listItemTheme(variables)
  124. },
  125. "NativeBase.Icon": {
  126. ...iconTheme(variables)
  127. },
  128. "NativeBase.IconNB": {
  129. ...iconTheme(variables)
  130. },
  131. "NativeBase.Text": {
  132. ...textTheme(variables)
  133. },
  134. "NativeBase.Spinner": {
  135. ...spinnerTheme(variables)
  136. },
  137. "NativeBase.Fab": {
  138. ...fabTheme(variables)
  139. },
  140. "NativeBase.Item": {
  141. ...itemTheme(variables)
  142. },
  143. "NativeBase.Label": {
  144. ...labelTheme(variables)
  145. },
  146. "NativeBase.Textarea": {
  147. ...textAreaTheme(variables)
  148. },
  149. "NativeBase.PickerNB": {
  150. "NativeBase.Button": {
  151. "NativeBase.Text": {}
  152. }
  153. },
  154. "NativeBase.Tab": {
  155. ...tabTheme(variables)
  156. },
  157. "NativeBase.Segment": {
  158. ...segmentTheme(variables)
  159. },
  160. "NativeBase.TabBar": {
  161. ...tabBarTheme(variables)
  162. },
  163. "NativeBase.ViewNB": {
  164. ...viewTheme(variables)
  165. },
  166. "NativeBase.TabHeading": {
  167. ...tabHeadingTheme(variables)
  168. },
  169. "NativeBase.TabContainer": {
  170. ...tabContainerTheme(variables)
  171. },
  172. "NativeBase.Switch": {
  173. ...switchTheme(variables)
  174. },
  175. "NativeBase.Separator": {
  176. ...separatorTheme(variables)
  177. },
  178. "NativeBase.SwipeRow": {
  179. ...swipeRowTheme(variables)
  180. },
  181. "NativeBase.Thumbnail": {
  182. ...thumbnailTheme(variables)
  183. }
  184. };
  185. const cssifyTheme = (grandparent, parent, parentKey) => {
  186. _.forEach(parent, (style, styleName) => {
  187. // console.log('styleName', styleName);
  188. // console.log('parentKey', parentKey);
  189. if (
  190. styleName.indexOf(".") === 0 &&
  191. parentKey &&
  192. parentKey.indexOf(".") === 0
  193. ) {
  194. if (grandparent) {
  195. if (!grandparent[styleName]) {
  196. grandparent[styleName] = {};
  197. } else {
  198. grandparent[styleName][parentKey] = style;
  199. }
  200. }
  201. }
  202. if (style && typeof style === "object") {
  203. cssifyTheme(parent, style, styleName);
  204. }
  205. });
  206. };
  207. cssifyTheme(null, theme, null);
  208. return theme;
  209. };