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

styles.js 5.4KB

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