2021-07-28 16:15:52 +03:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import './Drawer.scss';
|
|
|
|
|
|
|
|
import cons from '../../../client/state/cons';
|
|
|
|
import navigation from '../../../client/state/navigation';
|
|
|
|
|
|
|
|
import ScrollView from '../../atoms/scroll/ScrollView';
|
|
|
|
|
2021-08-30 18:42:24 +03:00
|
|
|
import DrawerHeader from './DrawerHeader';
|
2021-09-03 15:28:01 +03:00
|
|
|
import DrawerBreadcrumb from './DrawerBreadcrumb';
|
2021-08-30 18:42:24 +03:00
|
|
|
import Home from './Home';
|
|
|
|
import Directs from './Directs';
|
2021-07-28 16:15:52 +03:00
|
|
|
|
2021-08-30 06:01:13 +03:00
|
|
|
function Drawer() {
|
2021-09-03 15:28:01 +03:00
|
|
|
const [selectedTab, setSelectedTab] = useState('home');
|
|
|
|
const [spaceId, setSpaceId] = useState(navigation.selectedSpaceId);
|
2021-08-30 06:01:13 +03:00
|
|
|
|
|
|
|
function onTabChanged(tabId) {
|
2021-09-03 15:28:01 +03:00
|
|
|
setSelectedTab(tabId);
|
|
|
|
}
|
|
|
|
function onSpaceSelected(roomId) {
|
|
|
|
setSpaceId(roomId);
|
2021-08-30 06:01:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
navigation.on(cons.events.navigation.TAB_CHANGED, onTabChanged);
|
2021-09-03 15:28:01 +03:00
|
|
|
navigation.on(cons.events.navigation.SPACE_SELECTED, onSpaceSelected);
|
2021-08-30 06:01:13 +03:00
|
|
|
return () => {
|
|
|
|
navigation.removeListener(cons.events.navigation.TAB_CHANGED, onTabChanged);
|
2021-09-03 15:28:01 +03:00
|
|
|
navigation.removeListener(cons.events.navigation.SPACE_SELECTED, onSpaceSelected);
|
2021-08-30 06:01:13 +03:00
|
|
|
};
|
|
|
|
}, []);
|
2021-07-28 16:15:52 +03:00
|
|
|
return (
|
|
|
|
<div className="drawer">
|
2021-09-03 15:28:01 +03:00
|
|
|
<DrawerHeader selectedTab={selectedTab} spaceId={spaceId} />
|
2021-07-28 16:15:52 +03:00
|
|
|
<div className="drawer__content-wrapper">
|
2021-09-03 15:28:01 +03:00
|
|
|
{selectedTab === 'home' && <DrawerBreadcrumb />}
|
2021-08-31 16:13:31 +03:00
|
|
|
<div className="rooms__wrapper">
|
2021-07-28 16:15:52 +03:00
|
|
|
<ScrollView autoHide>
|
2021-08-31 16:13:31 +03:00
|
|
|
<div className="rooms-container">
|
2021-08-30 18:42:24 +03:00
|
|
|
{
|
2021-09-03 15:28:01 +03:00
|
|
|
selectedTab === 'home'
|
|
|
|
? <Home spaceId={spaceId} />
|
2021-08-30 18:42:24 +03:00
|
|
|
: <Directs />
|
|
|
|
}
|
|
|
|
</div>
|
2021-07-28 16:15:52 +03:00
|
|
|
</ScrollView>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Drawer;
|