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

styles.js 5.8KB

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