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.

styles.js 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. // @flow
  2. import { StyleSheet } from 'react-native';
  3. import BaseTheme from '../../../../base/ui/components/BaseTheme.native';
  4. import { ColorSchemeRegistry, schemeColor } from '../../../color-scheme';
  5. import { BoxModel, ColorPalette } from '../../../styles';
  6. import { PREFERRED_DIALOG_SIZE } from '../../constants';
  7. const BORDER_RADIUS = 5;
  8. export const FIELD_UNDERLINE = ColorPalette.transparent;
  9. /**
  10. * NOTE: These Material guidelines based values are currently only used in
  11. * dialogs (and related) but later on it would be nice to export it into a base
  12. * Material feature.
  13. */
  14. export const MD_FONT_SIZE = 16;
  15. export const MD_ITEM_HEIGHT = 48;
  16. export const MD_ITEM_MARGIN_PADDING = 16;
  17. export const PLACEHOLDER_COLOR = ColorPalette.lightGrey;
  18. /**
  19. * The React {@code Component} styles of {@code BottomSheet}. These have
  20. * been implemented as per the Material Design guidelines:
  21. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  22. */
  23. export const bottomSheetStyles = {
  24. sheetAreaCover: {
  25. backgroundColor: ColorPalette.transparent,
  26. flex: 1
  27. },
  28. scrollView: {
  29. paddingHorizontal: 0
  30. },
  31. /**
  32. * Style for the container of the sheet.
  33. */
  34. sheetContainer: {
  35. alignItems: 'stretch',
  36. flex: 1,
  37. flexDirection: 'column',
  38. justifyContent: 'flex-end',
  39. maxWidth: 500,
  40. marginLeft: 'auto',
  41. marginRight: 'auto',
  42. width: '100%'
  43. },
  44. sheetItemContainer: {
  45. flex: -1
  46. }
  47. };
  48. export const brandedDialog = {
  49. /**
  50. * The style of bold {@code Text} rendered by the {@code Dialog}s of the
  51. * feature authentication.
  52. */
  53. boldDialogText: {
  54. fontWeight: 'bold'
  55. },
  56. buttonFarLeft: {
  57. borderBottomLeftRadius: BORDER_RADIUS
  58. },
  59. buttonFarRight: {
  60. borderBottomRightRadius: BORDER_RADIUS
  61. },
  62. buttonWrapper: {
  63. alignItems: 'stretch',
  64. borderRadius: BORDER_RADIUS,
  65. flexDirection: 'row'
  66. },
  67. closeWrapper: {
  68. padding: BoxModel.padding
  69. },
  70. dialogTitle: {
  71. fontWeight: 'bold',
  72. paddingLeft: BoxModel.padding * 2
  73. },
  74. headerWrapper: {
  75. alignItems: 'center',
  76. flexDirection: 'row',
  77. justifyContent: 'space-between'
  78. },
  79. mainWrapper: {
  80. alignSelf: 'stretch',
  81. padding: BoxModel.padding * 2,
  82. // The added bottom padding is to compensate the empty space around the
  83. // close icon.
  84. paddingBottom: BoxModel.padding * 3
  85. },
  86. overlay: {
  87. ...StyleSheet.absoluteFillObject,
  88. alignItems: 'center',
  89. backgroundColor: 'rgba(127, 127, 127, 0.6)',
  90. flexDirection: 'row',
  91. justifyContent: 'center',
  92. padding: 30
  93. },
  94. overlayTouchable: {
  95. ...StyleSheet.absoluteFillObject
  96. }
  97. };
  98. /**
  99. * Reusable (colored) style for text in any branded dialogs.
  100. */
  101. const brandedDialogText = {
  102. color: schemeColor('text'),
  103. fontSize: MD_FONT_SIZE,
  104. textAlign: 'center'
  105. };
  106. const brandedDialogLabelStyle = {
  107. color: ColorPalette.white,
  108. flexShrink: 1,
  109. fontSize: MD_FONT_SIZE,
  110. opacity: 0.90
  111. };
  112. const brandedDialogItemContainerStyle = {
  113. alignItems: 'center',
  114. flexDirection: 'row',
  115. height: MD_ITEM_HEIGHT
  116. };
  117. const brandedDialogIconStyle = {
  118. color: ColorPalette.white,
  119. fontSize: 24
  120. };
  121. export const inputDialog = {
  122. bottomField: {
  123. marginBottom: 0
  124. },
  125. fieldWrapper: {
  126. ...brandedDialog.mainWrapper,
  127. paddingBottom: BoxModel.padding * 2
  128. },
  129. formMessage: {
  130. alignSelf: 'flex-start',
  131. fontStyle: 'italic',
  132. margin: BoxModel.margin
  133. }
  134. };
  135. /**
  136. * Default styles for the items of a {@code BottomSheet}-based menu.
  137. *
  138. * These have been implemented as per the Material Design guidelines:
  139. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  140. */
  141. ColorSchemeRegistry.register('BottomSheet', {
  142. buttons: {
  143. /**
  144. * Style for the {@code Icon} element in a generic item of the menu.
  145. */
  146. iconStyle: {
  147. ...brandedDialogIconStyle
  148. },
  149. /**
  150. * Style for the label in a generic item rendered in the menu.
  151. */
  152. labelStyle: {
  153. ...brandedDialogLabelStyle,
  154. marginLeft: 16
  155. },
  156. /**
  157. * Container style for a generic item rendered in the menu.
  158. */
  159. style: {
  160. ...brandedDialogItemContainerStyle,
  161. paddingHorizontal: MD_ITEM_MARGIN_PADDING
  162. },
  163. /**
  164. * Additional style that is not directly used as a style object.
  165. */
  166. underlayColor: ColorPalette.toggled
  167. },
  168. /**
  169. * Bottom sheet's base style.
  170. */
  171. sheet: {
  172. backgroundColor: BaseTheme.palette.ui02,
  173. borderTopLeftRadius: 16,
  174. borderTopRightRadius: 16
  175. },
  176. /**
  177. * Bottom sheet's base style with header.
  178. */
  179. sheetHeader: {
  180. backgroundColor: BaseTheme.palette.ui02
  181. }
  182. });
  183. /**
  184. * Color schemed styles for all the component based on the abstract dialog.
  185. */
  186. ColorSchemeRegistry.register('Dialog', {
  187. button: {
  188. backgroundColor: schemeColor('buttonBackground'),
  189. flex: 1,
  190. padding: BoxModel.padding * 1.5
  191. },
  192. /**
  193. * Separator line for the buttons in a dialog.
  194. */
  195. buttonSeparator: {
  196. borderRightColor: schemeColor('border'),
  197. borderRightWidth: 1
  198. },
  199. buttonLabel: {
  200. color: schemeColor('buttonLabel'),
  201. fontSize: MD_FONT_SIZE,
  202. textAlign: 'center'
  203. },
  204. /**
  205. * Style of the close icon on a dialog.
  206. */
  207. closeStyle: {
  208. color: schemeColor('icon'),
  209. fontSize: MD_FONT_SIZE
  210. },
  211. /**
  212. * Base style of the dialogs.
  213. */
  214. dialog: {
  215. alignItems: 'stretch',
  216. backgroundColor: schemeColor('background'),
  217. borderColor: schemeColor('border'),
  218. borderRadius: BORDER_RADIUS,
  219. borderWidth: 1,
  220. flex: 1,
  221. flexDirection: 'column',
  222. maxWidth: PREFERRED_DIALOG_SIZE
  223. },
  224. /**
  225. * Field on an input dialog.
  226. */
  227. field: {
  228. ...brandedDialogText,
  229. borderBottomWidth: 1,
  230. borderColor: schemeColor('border'),
  231. margin: BoxModel.margin,
  232. textAlign: 'left'
  233. },
  234. /**
  235. * Style for the field label on an input dialog.
  236. */
  237. fieldLabel: {
  238. ...brandedDialogText,
  239. margin: BoxModel.margin,
  240. textAlign: 'left'
  241. },
  242. text: {
  243. ...brandedDialogText
  244. },
  245. topBorderContainer: {
  246. borderTopColor: schemeColor('border'),
  247. borderTopWidth: 1
  248. }
  249. });
  250. ColorSchemeRegistry.register('SecurityDialog', {
  251. /**
  252. * Field on an input dialog.
  253. */
  254. field: {
  255. borderBottomWidth: 1,
  256. borderColor: schemeColor('border'),
  257. color: schemeColor('text'),
  258. fontSize: 14,
  259. paddingBottom: 8
  260. },
  261. text: {
  262. color: schemeColor('text'),
  263. fontSize: 14,
  264. marginTop: 8
  265. },
  266. title: {
  267. color: schemeColor('text'),
  268. fontSize: 18,
  269. fontWeight: 'bold'
  270. }
  271. });