您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

styles.js 5.5KB

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