You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

styles.js 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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: 0
  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. const brandedDialogLabelStyle = {
  98. color: ColorPalette.white,
  99. flexShrink: 1,
  100. fontSize: MD_FONT_SIZE,
  101. opacity: 0.90
  102. };
  103. const brandedDialogItemContainerStyle = {
  104. alignItems: 'center',
  105. flexDirection: 'row',
  106. height: MD_ITEM_HEIGHT
  107. };
  108. const brandedDialogIconStyle = {
  109. color: ColorPalette.white,
  110. fontSize: 24
  111. };
  112. export const inputDialog = {
  113. bottomField: {
  114. marginBottom: 0
  115. },
  116. fieldWrapper: {
  117. ...brandedDialog.mainWrapper,
  118. paddingBottom: BoxModel.padding * 2
  119. },
  120. formMessage: {
  121. alignSelf: 'flex-start',
  122. fontStyle: 'italic',
  123. margin: BoxModel.margin
  124. }
  125. };
  126. /**
  127. * Default styles for the items of a {@code BottomSheet}-based menu.
  128. *
  129. * These have been implemented as per the Material Design guidelines:
  130. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  131. */
  132. ColorSchemeRegistry.register('BottomSheet', {
  133. buttons: {
  134. /**
  135. * Style for the {@code Icon} element in a generic item of the menu.
  136. */
  137. iconStyle: {
  138. ...brandedDialogIconStyle
  139. },
  140. /**
  141. * Style for the label in a generic item rendered in the menu.
  142. */
  143. labelStyle: {
  144. ...brandedDialogLabelStyle,
  145. marginLeft: 16
  146. },
  147. /**
  148. * Container style for a generic item rendered in the menu.
  149. */
  150. style: {
  151. ...brandedDialogItemContainerStyle,
  152. paddingHorizontal: MD_ITEM_MARGIN_PADDING
  153. },
  154. /**
  155. * Additional style that is not directly used as a style object.
  156. */
  157. underlayColor: ColorPalette.toggled
  158. },
  159. /**
  160. * Bottom sheet's base style.
  161. */
  162. sheet: {
  163. backgroundColor: ColorPalette.black,
  164. borderTopLeftRadius: 16,
  165. borderTopRightRadius: 16
  166. }
  167. });
  168. /**
  169. * Color schemed styles for all the component based on the abstract dialog.
  170. */
  171. ColorSchemeRegistry.register('Dialog', {
  172. button: {
  173. backgroundColor: schemeColor('buttonBackground'),
  174. flex: 1,
  175. padding: BoxModel.padding * 1.5
  176. },
  177. /**
  178. * Separator line for the buttons in a dialog.
  179. */
  180. buttonSeparator: {
  181. borderRightColor: schemeColor('border'),
  182. borderRightWidth: 1
  183. },
  184. buttonLabel: {
  185. color: schemeColor('buttonLabel'),
  186. fontSize: MD_FONT_SIZE,
  187. textAlign: 'center'
  188. },
  189. /**
  190. * Style of the close icon on a dialog.
  191. */
  192. closeStyle: {
  193. color: schemeColor('icon'),
  194. fontSize: MD_FONT_SIZE
  195. },
  196. /**
  197. * Base style of the dialogs.
  198. */
  199. dialog: {
  200. alignItems: 'stretch',
  201. backgroundColor: schemeColor('background'),
  202. borderColor: schemeColor('border'),
  203. borderRadius: BORDER_RADIUS,
  204. borderWidth: 1,
  205. flex: 1,
  206. flexDirection: 'column',
  207. maxWidth: PREFERRED_DIALOG_SIZE
  208. },
  209. /**
  210. * Field on an input dialog.
  211. */
  212. field: {
  213. ...brandedDialogText,
  214. borderBottomWidth: 1,
  215. borderColor: schemeColor('border'),
  216. margin: BoxModel.margin,
  217. textAlign: 'left'
  218. },
  219. /**
  220. * Style for the field label on an input dialog.
  221. */
  222. fieldLabel: {
  223. ...brandedDialogText,
  224. margin: BoxModel.margin,
  225. textAlign: 'left'
  226. },
  227. text: {
  228. ...brandedDialogText
  229. },
  230. topBorderContainer: {
  231. borderTopColor: schemeColor('border'),
  232. borderTopWidth: 1
  233. }
  234. });
  235. ColorSchemeRegistry.register('SecurityDialog', {
  236. /**
  237. * Field on an input dialog.
  238. */
  239. field: {
  240. borderBottomWidth: 1,
  241. borderColor: schemeColor('border'),
  242. color: schemeColor('text'),
  243. fontSize: 14,
  244. paddingBottom: 8
  245. },
  246. text: {
  247. color: schemeColor('text'),
  248. fontSize: 14,
  249. marginTop: 8
  250. },
  251. title: {
  252. color: schemeColor('text'),
  253. fontSize: 18,
  254. fontWeight: 'bold'
  255. }
  256. });