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

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