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 6.5KB

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