Skip to content

Commit

Permalink
feat(menu): use settings as menu entry
Browse files Browse the repository at this point in the history
- add useMenuSettings
  • Loading branch information
SimonGolms committed Jan 27, 2021
1 parent b520bbb commit 31342e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 2 additions & 16 deletions src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
IonListHeader,
IonMenu,
IonMenuToggle,
IonFooter,
IonHeader,
IonToolbar,
IonTitle,
} from '@ionic/react';
import { push } from 'connected-react-router';
import { settingsOutline } from 'ionicons/icons';
import React from 'react';
import { useDispatch } from 'react-redux';
import { useMenus } from '../../utils/hooks/useMenus';
Expand Down Expand Up @@ -58,20 +58,6 @@ export const Menu: React.FC = () => {
})}
</IonList>
</IonContent>
<IonFooter>
<IonMenuToggle autoHide={false}>
<IonItem
routerLink={'/settings'}
routerDirection="none"
lines="none"
detail={false}
onClick={() => dispatch(push('/settings'))}
>
<IonIcon slot="start" icon={settingsOutline} />
<IonLabel>Settings</IonLabel>
</IonItem>
</IonMenuToggle>
</IonFooter>
</IonMenu>
);
};
16 changes: 15 additions & 1 deletion src/utils/hooks/useMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
homeOutline,
information,
searchOutline,
settingsOutline,
} from 'ionicons/icons';
import { useTranslation } from 'react-i18next';
import {
Expand All @@ -30,9 +31,10 @@ export const useMenus = (): Menu[] => {
const about = useMenuAbout();
const home = useMenuHome();
const search = useMenuSearch();
const settings = useMenuSettings();
const chapters = useMenuChapters();

return [home, about, search, ...chapters.flat()];
return [home, about, search, settings, ...chapters.flat()];
};

const useMenuAbout = (): Menu => {
Expand Down Expand Up @@ -94,3 +96,15 @@ const useMenuSearch = (): Menu => {
url: '/page/search',
};
};

const useMenuSettings = (): Menu => {
const { t } = useTranslation();

return {
color: '',
icon: settingsOutline,
isHeader: false,
title: t('SETTINGS.TITLE'),
url: '/settings',
};
};

0 comments on commit 31342e2

Please sign in to comment.