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.

102 lines
2.7 KiB

  1. import ColumnsArea from './components/columns_area';
  2. import NotificationsContainer from './containers/notifications_container';
  3. import PureRenderMixin from 'react-addons-pure-render-mixin';
  4. import LoadingBarContainer from './containers/loading_bar_container';
  5. import HomeTimeline from '../home_timeline';
  6. import MentionsTimeline from '../mentions_timeline';
  7. import Compose from '../compose';
  8. import TabsBar from './components/tabs_bar';
  9. import ModalContainer from './containers/modal_container';
  10. import Notifications from '../notifications';
  11. import { debounce } from 'react-decoration';
  12. import { uploadCompose } from '../../actions/compose';
  13. import { connect } from 'react-redux';
  14. import { isMobile } from '../../is_mobile'
  15. const UI = React.createClass({
  16. propTypes: {
  17. dispatch: React.PropTypes.func.isRequired,
  18. children: React.PropTypes.node
  19. },
  20. getInitialState () {
  21. return {
  22. width: window.innerWidth
  23. };
  24. },
  25. mixins: [PureRenderMixin],
  26. @debounce(500)
  27. handleResize () {
  28. this.setState({ width: window.innerWidth });
  29. },
  30. handleDragOver (e) {
  31. e.preventDefault();
  32. e.stopPropagation();
  33. e.dataTransfer.dropEffect = 'copy';
  34. if (e.dataTransfer.effectAllowed === 'all' || e.dataTransfer.effectAllowed === 'uninitialized') {
  35. //
  36. }
  37. },
  38. handleDrop (e) {
  39. e.preventDefault();
  40. if (e.dataTransfer && e.dataTransfer.files.length === 1) {
  41. this.props.dispatch(uploadCompose(e.dataTransfer.files));
  42. }
  43. },
  44. componentWillMount () {
  45. window.addEventListener('resize', this.handleResize, { passive: true });
  46. window.addEventListener('dragover', this.handleDragOver);
  47. window.addEventListener('drop', this.handleDrop);
  48. },
  49. componentWillUnmount () {
  50. window.removeEventListener('resize', this.handleResize);
  51. window.removeEventListener('dragover', this.handleDragOver);
  52. window.removeEventListener('drop', this.handleDrop);
  53. },
  54. render () {
  55. let mountedColumns;
  56. if (isMobile(this.state.width)) {
  57. mountedColumns = (
  58. <ColumnsArea>
  59. {this.props.children}
  60. </ColumnsArea>
  61. );
  62. } else {
  63. mountedColumns = (
  64. <ColumnsArea>
  65. <Compose withHeader={true} />
  66. <HomeTimeline trackScroll={false} />
  67. <Notifications trackScroll={false} />
  68. {this.props.children}
  69. </ColumnsArea>
  70. );
  71. }
  72. return (
  73. <div style={{ flex: '0 0 auto', display: 'flex', flexDirection: 'column', width: '100%', height: '100%', background: '#1a1c23' }}>
  74. <TabsBar />
  75. {mountedColumns}
  76. <NotificationsContainer />
  77. <LoadingBarContainer style={{ backgroundColor: '#2b90d9', left: '0', top: '0' }} />
  78. <ModalContainer />
  79. </div>
  80. );
  81. }
  82. });
  83. export default connect()(UI);