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.8KB

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