Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

styles.js 5.4KB

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