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

styles.js 5.9KB

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