Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

refactor

ammarahm-ed1dcc899a3f20
diff --git a/apps/mobile/src/components/header/HeaderMenu.js b/apps/mobile/src/components/header/HeaderMenu.js
new file mode 100644
index 000000000..994b51d5a
--- /dev/null
+++ b/apps/mobile/src/components/header/HeaderMenu.js
@@ -0,0 +1,99 @@
+import React, { createRef } from 'react';
+import { TouchableOpacity } from 'react-native';
+import Menu, { MenuDivider, MenuItem } from 'react-native-material-menu';
+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
+import { SIZE, WEIGHT } from '../../common/common';
+import { useTracked } from '../../provider';
+import { ACTIONS } from '../../provider/actions';
+const menuRef = createRef();
+export const HeaderMenu = () => {
+ const [state, dispatch] = useTracked();
+ const {colors, headerVerticalMenu} = state;
+
+ return headerVerticalMenu ? (
+ <Menu
+ ref={menuRef}
+ style={{
+ borderRadius: 5,
+ backgroundColor: colors.bg,
+ }}
+ button={
+ <TouchableOpacity
+ onPress={() => {
+ menuRef.current?.show();
+ }}
+ style={{
+ justifyContent: 'center',
+ alignItems: 'flex-end',
+ height: 40,
+ width: 60,
+ }}>
+ <Icon name="sort" size={SIZE.xl} color={colors.icon} />
+ </TouchableOpacity>
+ }>
+ <MenuItem
+ textStyle={{
+ color: colors.icon,
+ fontSize: 12,
+ }}>
+ Sort by:
+ </MenuItem>
+ <MenuDivider />
+ <MenuItem
+ textStyle={{
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ }}
+ onPress={() => {
+ dispatch({type: ACTIONS.NOTES, sort: null});
+ menuRef.current?.hide();
+ }}>
+ Default
+ </MenuItem>
+ <MenuItem
+ textStyle={{
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ }}
+ onPress={() => {
+ dispatch({type: ACTIONS.NOTES, sort: 'abc'});
+ menuRef.current?.hide();
+ }}>
+ Alphabetical
+ </MenuItem>
+ <MenuItem
+ textStyle={{
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ }}
+ onPress={() => {
+ dispatch({type: ACTIONS.NOTES, sort: 'year'});
+ menuRef.current?.hide();
+ }}>
+ By year
+ </MenuItem>
+ <MenuItem
+ textStyle={{
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ }}
+ onPress={() => {
+ dispatch({type: ACTIONS.NOTES, sort: 'month'});
+ menuRef.current?.hide();
+ }}>
+ By month
+ </MenuItem>
+ <MenuItem
+ textStyle={{
+ fontFamily: WEIGHT.regular,
+ color: colors.pri,
+ }}
+ onPress={() => {
+ dispatch({type: ACTIONS.NOTES, sort: 'week'});
+ menuRef.current?.hide();
+ }}>
+ By week
+ </MenuItem>
+ </Menu>
+ ) : null;
+};
diff --git a/apps/mobile/src/components/header/HeaderTitle.js b/apps/mobile/src/components/header/HeaderTitle.js
new file mode 100644
index 000000000..e55f5ee7d
--- /dev/null
+++ b/apps/mobile/src/components/header/HeaderTitle.js
@@ -0,0 +1,31 @@
+import React, {createRef, useEffect} from 'react';
+import {Text} from 'react-native';
+import {SIZE, WEIGHT} from '../../common/common';
+import {useTracked} from '../../provider';
+
+export const HeaderTitle = ({root}) => {
+ const [state, dispatch] = useTracked();
+ const {colors} = state;
+ let headerTextState = root ? state.headerTextState : state.indHeaderTextState;
+
+ return (
+ <Text
+ style={{
+ fontSize: SIZE.xl,
+ color: headerTextState.color ? headerTextState.color : colors.pri,
+ fontFamily: WEIGHT.bold,
+
+ }}>
+ <Text
+ style={{
+ color: colors.accent,
+ }}>
+ {headerTextState.heading.slice(0, 1) === '#' ? '#' : null}
+ </Text>
+
+ {headerTextState.heading.slice(0, 1) === '#'
+ ? headerTextState.heading.slice(1)
+ : headerTextState.heading}
+ </Text>
+ );
+};