cinny/src/app/organisms/navigation/Drawer.jsx

60 lines
1.5 KiB
React
Raw Normal View History

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';
import DrawerHeader from './DrawerHeader';
import Home from './Home';
import Directs from './Directs';
2021-07-28 16:15:52 +03:00
function DrawerBradcrumb() {
return (
<div className="breadcrumb__wrapper">
<ScrollView horizontal vertical={false}>
<div>
{/* TODO: bradcrumb space paths when spaces become a thing */}
</div>
</ScrollView>
</div>
);
}
2021-08-30 06:01:13 +03:00
function Drawer() {
const [activeTab, setActiveTab] = useState('home');
function onTabChanged(tabId) {
setActiveTab(tabId);
}
useEffect(() => {
navigation.on(cons.events.navigation.TAB_CHANGED, onTabChanged);
return () => {
navigation.removeListener(cons.events.navigation.TAB_CHANGED, onTabChanged);
};
}, []);
2021-07-28 16:15:52 +03:00
return (
<div className="drawer">
2021-08-30 06:01:13 +03:00
<DrawerHeader activeTab={activeTab} />
2021-07-28 16:15:52 +03:00
<div className="drawer__content-wrapper">
<DrawerBradcrumb />
<div className="channels__wrapper">
<ScrollView autoHide>
<div className="channels-container">
{
activeTab === 'home'
? <Home />
: <Directs />
}
</div>
2021-07-28 16:15:52 +03:00
</ScrollView>
</div>
</div>
</div>
);
}
export default Drawer;