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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. // @flow
  2. import { StyleSheet } from 'react-native';
  3. import BaseTheme from '../../../../base/ui/components/BaseTheme.native';
  4. import { ColorSchemeRegistry, schemeColor } from '../../../color-scheme';
  5. import { BoxModel, ColorPalette } from '../../../styles';
  6. import { PREFERRED_DIALOG_SIZE } from '../../constants';
  7. const BORDER_RADIUS = 5;
  8. export const FIELD_UNDERLINE = ColorPalette.transparent;
  9. /**
  10. * NOTE: These Material guidelines based values are currently only used in
  11. * dialogs (and related) but later on it would be nice to export it into a base
  12. * Material feature.
  13. */
  14. export const MD_FONT_SIZE = 16;
  15. export const MD_ITEM_HEIGHT = 48;
  16. export const MD_ITEM_MARGIN_PADDING = 16;
  17. export const PLACEHOLDER_COLOR = ColorPalette.lightGrey;
  18. /**
  19. * The React {@code Component} styles of {@code BottomSheet}. These have
  20. * been implemented as per the Material Design guidelines:
  21. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  22. */
  23. export const bottomSheetStyles = {
  24. sheetAreaCover: {
  25. backgroundColor: ColorPalette.transparent,
  26. flex: 1
  27. },
  28. scrollView: {
  29. paddingHorizontal: 0
  30. },
  31. /**
  32. * Style for the container of the sheet.
  33. */
  34. sheetContainer: {
  35. alignItems: 'stretch',
  36. flex: 1,
  37. flexDirection: 'column',
  38. justifyContent: 'flex-end',
  39. maxWidth: 500,
  40. marginLeft: 'auto',
  41. marginRight: 'auto',
  42. width: '100%'
  43. },
  44. sheetItemContainer: {
  45. flex: -1
  46. }
  47. };
  48. export const brandedDialog = {
  49. /**
  50. * The style of bold {@code Text} rendered by the {@code Dialog}s of the
  51. * feature authentication.
  52. */
  53. boldDialogText: {
  54. fontWeight: 'bold'
  55. },
  56. buttonFarLeft: {
  57. borderBottomLeftRadius: BORDER_RADIUS
  58. },
  59. buttonFarRight: {
  60. borderBottomRightRadius: BORDER_RADIUS
  61. },
  62. buttonWrapper: {
  63. alignItems: 'stretch',
  64. borderRadius: BORDER_RADIUS,
  65. flexDirection: 'row'
  66. },
  67. closeWrapper: {
  68. alignSelf: 'flex-end',
  69. padding: BoxModel.padding
  70. },
  71. mainWrapper: {
  72. alignSelf: 'stretch',
  73. padding: BoxModel.padding * 2,
  74. // The added bottom padding is to compensate the empty space around the
  75. // close icon.
  76. paddingBottom: BoxModel.padding * 3
  77. },
  78. overlay: {
  79. ...StyleSheet.absoluteFillObject,
  80. alignItems: 'center',
  81. backgroundColor: 'rgba(127, 127, 127, 0.6)',
  82. flexDirection: 'row',
  83. justifyContent: 'center',
  84. padding: 30
  85. },
  86. overlayTouchable: {
  87. ...StyleSheet.absoluteFillObject
  88. }
  89. };
  90. /**
  91. * Reusable (colored) style for text in any branded dialogs.
  92. */
  93. const brandedDialogText = {
  94. color: schemeColor('text'),
  95. fontSize: MD_FONT_SIZE,
  96. textAlign: 'center'
  97. };
  98. const brandedDialogLabelStyle = {
  99. color: ColorPalette.white,
  100. flexShrink: 1,
  101. fontSize: MD_FONT_SIZE,
  102. opacity: 0.90
  103. };
  104. const brandedDialogItemContainerStyle = {
  105. alignItems: 'center',
  106. flexDirection: 'row',
  107. height: MD_ITEM_HEIGHT
  108. };
  109. const brandedDialogIconStyle = {
  110. color: ColorPalette.white,
  111. fontSize: 24
  112. };
  113. export const inputDialog = {
  114. bottomField: {
  115. marginBottom: 0
  116. },
  117. fieldWrapper: {
  118. ...brandedDialog.mainWrapper,
  119. paddingBottom: BoxModel.padding * 2
  120. },
  121. formMessage: {
  122. alignSelf: 'flex-start',
  123. fontStyle: 'italic',
  124. margin: BoxModel.margin
  125. }
  126. };
  127. /**
  128. * Default styles for the items of a {@code BottomSheet}-based menu.
  129. *
  130. * These have been implemented as per the Material Design guidelines:
  131. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  132. */
  133. ColorSchemeRegistry.register('BottomSheet', {
  134. buttons: {
  135. /**
  136. * Style for the {@code Icon} element in a generic item of the menu.
  137. */
  138. iconStyle: {
  139. ...brandedDialogIconStyle
  140. },
  141. /**
  142. * Style for the label in a generic item rendered in the menu.
  143. */
  144. labelStyle: {
  145. ...brandedDialogLabelStyle,
  146. marginLeft: 16
  147. },
  148. /**
  149. * Container style for a generic item rendered in the menu.
  150. */
  151. style: {
  152. ...brandedDialogItemContainerStyle,
  153. paddingHorizontal: MD_ITEM_MARGIN_PADDING
  154. },
  155. /**
  156. * Additional style that is not directly used as a style object.
  157. */
  158. underlayColor: ColorPalette.toggled
  159. },
  160. /**
  161. * Bottom sheet's base style.
  162. */
  163. sheet: {
  164. backgroundColor: BaseTheme.palette.ui02,
  165. borderTopLeftRadius: 16,
  166. borderTopRightRadius: 16
  167. },
  168. /**
  169. * Bottom sheet's base style with header.
  170. */
  171. sheetHeader: {
  172. backgroundColor: BaseTheme.palette.ui02
  173. }
  174. });
  175. /**
  176. * Color schemed styles for all the component based on the abstract dialog.
  177. */
  178. ColorSchemeRegistry.register('Dialog', {
  179. button: {
  180. backgroundColor: schemeColor('buttonBackground'),
  181. flex: 1,
  182. padding: BoxModel.padding * 1.5
  183. },
  184. /**
  185. * Separator line for the buttons in a dialog.
  186. */
  187. buttonSeparator: {
  188. borderRightColor: schemeColor('border'),
  189. borderRightWidth: 1
  190. },
  191. buttonLabel: {
  192. color: schemeColor('buttonLabel'),
  193. fontSize: MD_FONT_SIZE,
  194. textAlign: 'center'
  195. },
  196. /**
  197. * Style of the close icon on a dialog.
  198. */
  199. closeStyle: {
  200. color: schemeColor('icon'),
  201. fontSize: MD_FONT_SIZE
  202. },
  203. /**
  204. * Base style of the dialogs.
  205. */
  206. dialog: {
  207. alignItems: 'stretch',
  208. backgroundColor: schemeColor('background'),
  209. borderColor: schemeColor('border'),
  210. borderRadius: BORDER_RADIUS,
  211. borderWidth: 1,
  212. flex: 1,
  213. flexDirection: 'column',
  214. maxWidth: PREFERRED_DIALOG_SIZE
  215. },
  216. /**
  217. * Field on an input dialog.
  218. */
  219. field: {
  220. ...brandedDialogText,
  221. borderBottomWidth: 1,
  222. borderColor: schemeColor('border'),
  223. margin: BoxModel.margin,
  224. textAlign: 'left'
  225. },
  226. /**
  227. * Style for the field label on an input dialog.
  228. */
  229. fieldLabel: {
  230. ...brandedDialogText,
  231. margin: BoxModel.margin,
  232. textAlign: 'left'
  233. },
  234. text: {
  235. ...brandedDialogText
  236. },
  237. topBorderContainer: {
  238. borderTopColor: schemeColor('border'),
  239. borderTopWidth: 1
  240. }
  241. });
  242. ColorSchemeRegistry.register('SecurityDialog', {
  243. /**
  244. * Field on an input dialog.
  245. */
  246. field: {
  247. borderBottomWidth: 1,
  248. borderColor: schemeColor('border'),
  249. color: schemeColor('text'),
  250. fontSize: 14,
  251. paddingBottom: 8
  252. },
  253. text: {
  254. color: schemeColor('text'),
  255. fontSize: 14,
  256. marginTop: 8
  257. },
  258. title: {
  259. color: schemeColor('text'),
  260. fontSize: 18,
  261. fontWeight: 'bold'
  262. }
  263. });