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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. /**
  28. * Style for the container of the sheet.
  29. */
  30. sheetContainer: {
  31. alignItems: 'stretch',
  32. flex: 1,
  33. flexDirection: 'column',
  34. justifyContent: 'flex-end'
  35. },
  36. sheetItemContainer: {
  37. flex: -1,
  38. maxHeight: '60%',
  39. paddingHorizontal: MD_ITEM_MARGIN_PADDING
  40. }
  41. };
  42. export const brandedDialog = {
  43. /**
  44. * The style of bold {@code Text} rendered by the {@code Dialog}s of the
  45. * feature authentication.
  46. */
  47. boldDialogText: {
  48. fontWeight: 'bold'
  49. },
  50. buttonFarLeft: {
  51. borderBottomLeftRadius: BORDER_RADIUS
  52. },
  53. buttonFarRight: {
  54. borderBottomRightRadius: BORDER_RADIUS
  55. },
  56. buttonWrapper: {
  57. alignItems: 'stretch',
  58. borderRadius: BORDER_RADIUS,
  59. flexDirection: 'row'
  60. },
  61. closeWrapper: {
  62. alignSelf: 'flex-end',
  63. padding: BoxModel.padding
  64. },
  65. mainWrapper: {
  66. alignSelf: 'stretch',
  67. padding: BoxModel.padding * 2,
  68. // The added bottom padding is to compensate the empty space around the
  69. // close icon.
  70. paddingBottom: BoxModel.padding * 3
  71. },
  72. overlay: {
  73. ...StyleSheet.absoluteFillObject,
  74. alignItems: 'center',
  75. backgroundColor: 'rgba(127, 127, 127, 0.6)',
  76. flexDirection: 'row',
  77. justifyContent: 'center',
  78. padding: 30
  79. },
  80. overlayTouchable: {
  81. ...StyleSheet.absoluteFillObject
  82. }
  83. };
  84. /**
  85. * Reusable (colored) style for text in any branded dialogs.
  86. */
  87. const brandedDialogText = {
  88. color: schemeColor('text'),
  89. fontSize: MD_FONT_SIZE,
  90. textAlign: 'center'
  91. };
  92. export const inputDialog = {
  93. bottomField: {
  94. marginBottom: 0
  95. },
  96. fieldWrapper: {
  97. ...brandedDialog.mainWrapper,
  98. paddingBottom: BoxModel.padding * 2
  99. },
  100. formMessage: {
  101. alignSelf: 'flex-start',
  102. fontStyle: 'italic',
  103. margin: BoxModel.margin
  104. }
  105. };
  106. /**
  107. * Default styles for the items of a {@code BottomSheet}-based menu.
  108. *
  109. * These have been implemented as per the Material Design guidelines:
  110. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  111. */
  112. ColorSchemeRegistry.register('BottomSheet', {
  113. /**
  114. * Style for the {@code Icon} element in a generic item of the menu.
  115. */
  116. iconStyle: {
  117. color: schemeColor('icon'),
  118. fontSize: 24
  119. },
  120. /**
  121. * Style for the label in a generic item rendered in the menu.
  122. */
  123. labelStyle: {
  124. color: schemeColor('label'),
  125. flexShrink: 1,
  126. fontSize: MD_FONT_SIZE,
  127. marginLeft: 32,
  128. opacity: 0.90
  129. },
  130. /**
  131. * Bottom sheet's base style.
  132. */
  133. sheet: {
  134. backgroundColor: schemeColor('background')
  135. },
  136. /**
  137. * Container style for a generic item rendered in the menu.
  138. */
  139. style: {
  140. alignItems: 'center',
  141. flexDirection: 'row',
  142. height: MD_ITEM_HEIGHT
  143. },
  144. /**
  145. * Additional style that is not directly used as a style object.
  146. */
  147. underlayColor: ColorPalette.overflowMenuItemUnderlay
  148. });
  149. /**
  150. * Color schemed styles for all the component based on the abstract dialog.
  151. */
  152. ColorSchemeRegistry.register('Dialog', {
  153. button: {
  154. backgroundColor: schemeColor('buttonBackground'),
  155. flex: 1,
  156. padding: BoxModel.padding * 1.5
  157. },
  158. /**
  159. * Separator line for the buttons in a dialog.
  160. */
  161. buttonSeparator: {
  162. borderRightColor: schemeColor('border'),
  163. borderRightWidth: 1
  164. },
  165. buttonLabel: {
  166. color: schemeColor('buttonLabel'),
  167. fontSize: MD_FONT_SIZE,
  168. textAlign: 'center'
  169. },
  170. /**
  171. * Style of the close icon on a dialog.
  172. */
  173. closeStyle: {
  174. color: schemeColor('icon'),
  175. fontSize: MD_FONT_SIZE
  176. },
  177. /**
  178. * Base style of the dialogs.
  179. */
  180. dialog: {
  181. alignItems: 'stretch',
  182. backgroundColor: schemeColor('background'),
  183. borderColor: schemeColor('border'),
  184. borderRadius: BORDER_RADIUS,
  185. borderWidth: 1,
  186. flex: 1,
  187. flexDirection: 'column',
  188. maxWidth: PREFERRED_DIALOG_SIZE
  189. },
  190. /**
  191. * Field on an input dialog.
  192. */
  193. field: {
  194. ...brandedDialogText,
  195. borderBottomWidth: 1,
  196. borderColor: schemeColor('border'),
  197. margin: BoxModel.margin,
  198. textAlign: 'left'
  199. },
  200. /**
  201. * Style for the field label on an input dialog.
  202. */
  203. fieldLabel: {
  204. ...brandedDialogText,
  205. margin: BoxModel.margin,
  206. textAlign: 'left'
  207. },
  208. text: {
  209. ...brandedDialogText
  210. },
  211. topBorderContainer: {
  212. borderTopColor: schemeColor('border'),
  213. borderTopWidth: 1
  214. }
  215. });