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 5.9KB

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