Skip to content

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

add compact mode

ammarahm-ed053050aa3e8c
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index f87a515be..e8c2a269e 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -1,70 +1,167 @@
import React from 'react';
-import {Text, View} from 'react-native';
+import {View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {useTracked} from '../../provider';
+import {useSettingStore} from '../../provider/stores';
+import {eSendEvent} from '../../services/EventManager';
+import Navigation from '../../services/Navigation';
import {COLORS_NOTE} from '../../utils/Colors';
import {db} from '../../utils/DB';
+import {refreshNotesPage} from '../../utils/Events';
import {SIZE} from '../../utils/SizeUtils';
import {ActionIcon} from '../ActionIcon';
+import {Button} from '../Button';
import {ActionSheetEvent} from '../DialogManager/recievers';
import {TimeSince} from '../Menu/TimeSince';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
-const NoteItem = ({item, isTrash}) => {
- const [state] = useTracked();
- const {colors} = state;
+function navigateToNotebook(item) {
+ let notebook = db.notebooks.notebook(item.id).data;
+ let routeName = 'Notebook';
+ let params = {
+ menu: false,
+ notebook: notebook,
+ title: notebook.title,
+ };
- const showActionSheet = () => {
- let note = isTrash ? item : db.notes.note(item?.id)?.data;
- ActionSheetEvent(
- note ? note : item,
- isTrash ? false : true,
- isTrash ? false : true,
- isTrash
- ? ['Remove', 'Restore']
- : ['Add to notebook', 'Share', 'Export','Copy','Publish','Pin', 'Favorite', 'Vault','Delete','RemoveTopic'],
- isTrash ? [] : ['Pin', 'Favorite', 'Vault','Delete','RemoveTopic'],
- );
+ let headerState = {
+ heading: notebook.title,
+ id: notebook.id,
+ type: notebook.type,
};
+ Navigation.navigate(routeName, params, headerState);
+}
-
+function navigateToTag(item) {
+ let tags = db.tags.all;
+ let _tag = tags.find(t => t.title === item);
+ let params = {
+ ..._tag,
+ type: 'tag',
+ get: 'tagged',
+ };
+ Navigation.navigate('NotesPage', params, {
+ heading: '#' + _tag.title,
+ id: _tag.id,
+ type: _tag.type,
+ });
+ eSendEvent(refreshNotesPage, params);
+}
+
+const showActionSheet = (item, isTrash) => {
+ let note = isTrash ? item : db.notes.note(item?.id)?.data;
+ ActionSheetEvent(
+ note ? note : item,
+ isTrash ? false : true,
+ isTrash ? false : true,
+ isTrash
+ ? ['PermDelete', 'Restore']
+ : [
+ 'Add to notebook',
+ 'Share',
+ 'Export',
+ 'Copy',
+ 'Publish',
+ 'Pin',
+ 'Favorite',
+ 'Vault',
+ 'Delete',
+ 'RemoveTopic',
+ ],
+ isTrash ? [] : ['Pin', 'Favorite', 'Vault', 'Delete', 'RemoveTopic'],
+ );
+};
+
+const NoteItem = ({item, isTrash, tags}) => {
+ const [state] = useTracked();
+ const {colors} = state;
+ const settings = useSettingStore(state => state.settings);
+ const compactMode = settings.notesListMode === 'compact';
return (
<>
<View
style={{
- width: '92%',
- paddingRight: 5,
+ flexGrow: 1,
+ flexShrink: 1,
}}>
- {!isTrash && item.notebooks && item.notebooks.length > 0 ? (
- <Heading
- size={SIZE.xs}
+ {!compactMode && (
+ <View
style={{
- marginBottom: 2.5,
- }}
- color={item.color ? COLORS_NOTE[item.color] : colors.accent}>
- <Icon
- name="book-outline"
- color={item.color ? COLORS_NOTE[item.color] : colors.accent}
- size={SIZE.xs}
- />{' '}
- {db.notebooks.notebook(item.notebooks[0]?.id)?.title + ' '}{' '}
- {item.notebooks.length > 1
- ? '& ' + (item.notebooks.length - 1) + ' others'
- : ''}
- </Heading>
- ) : null}
+ flexDirection: 'row',
+ alignItems: 'center',
+ zIndex: 10,
+ elevation: 10,
+ }}>
+ {!isTrash &&
+ item.notebooks?.slice(0, 1).map(_item => (
+ <Button
+ title={db.notebooks.notebook(_item.id)?.data.title}
+ key={_item}
+ height={22}
+ textStyle={{
+ fontWeight: 'normal',
+ fontFamily: null,
+ }}
+ icon="book-outline"
+ type="grayBg"
+ fontSize={SIZE.xs + 1}
+ style={{
+ borderRadius: 100,
+ marginRight: 5,
+ borderWidth: 0.5,
+ borderColor: colors.icon,
+ paddingHorizontal: 6,
+ paddingRight: 2,
+ }}
+ onPress={() => navigateToNotebook(_item)}
+ />
+ ))}
+ {!isTrash &&
+ tags?.slice(0, 2).map(item => (
+ <Button
+ title={'#' + item}
+ key={item}
+ height={22}
+ textStyle={{
+ fontWeight: 'normal',
+ fontFamily: null,
+ }}
+ type="grayBg"
+ fontSize={SIZE.xs + 1}
+ style={{
+ borderRadius: 100,
+ marginRight: 5,
+ borderWidth: 0.5,
+ borderColor: colors.icon,
+ paddingHorizontal: 6,
+ zIndex: 10,
+ }}
+ onPress={() => navigateToTag(item)}
+ />
+ ))}
+ </View>
+ )}
<Heading
numberOfLines={1}
color={COLORS_NOTE[item.color] || colors.heading}
+ style={{
+ flexWrap: 'wrap',
+ }}
size={SIZE.md}>
{item.title}
</Heading>
- {item.headline ? (
- <Paragraph numberOfLines={2}>{item.headline}</Paragraph>
+ {item.headline && !compactMode ? (
+ <Paragraph
+ style={{
+ flexWrap: 'wrap',
+ }}
+ numberOfLines={2}>
+ {item.headline}
+ </Paragraph>
) : null}
<View
@@ -73,14 +170,14 @@ const NoteItem = ({item, isTrash}) => {
justifyContent: 'flex-start',
alignItems: 'center',
width: '100%',
- marginTop: 2.5,
+ marginTop: 5,
height: SIZE.md + 2,
}}>
{!isTrash ? (
<>
<TimeSince
style={{
- fontSize: SIZE.xs,
+ fontSize: SIZE.xs + 1,
color: colors.icon,
marginRight: 10,
}}
@@ -104,28 +201,27 @@ const NoteItem = ({item, isTrash}) => {
/>
) : null}
- {item.locked ? (
- <Icon
+ {item.pinned ? (
+ <Icon1
style={{marginRight: 10}}
- name="lock"
+ name="pin"
size={SIZE.sm}
style={{
- marginRight: 10,
+ marginRight: 5,
}}
- color={colors.icon}
+ color={COLORS_NOTE[item.color] || colors.accent}
/>
) : null}
- {item.pinned ? (
+ {item.locked ? (
<Icon
style={{marginRight: 10}}
- name="pin"
+ name="lock"
size={SIZE.sm}
style={{
marginRight: 10,
- marginTop: 2,
}}
- color={colors.accent}
+ color={colors.icon}
/>
) : null}
@@ -140,6 +236,30 @@ const NoteItem = ({item, isTrash}) => {
color="orange"
/>
) : null}
+
+ {item.conflicted ? (
+ <View
+ style={{
+ marginRight: 10,
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ }}>
+ <Icon
+ name="alert-circle"
+ size={SIZE.xs + 1}
+ color={colors.red}
+ />
+ <Heading
+ size={SIZE.xs}
+ style={{
+ color: colors.red,
+ marginLeft: 2,
+ }}>
+ CONFLICTS
+ </Heading>
+ </View>
+ ) : null}
</>
) : (
<>
@@ -167,10 +287,10 @@ const NoteItem = ({item, isTrash}) => {
</View>
</View>
<ActionIcon
- color={colors.heading}
+ color={colors.pri}
name="dots-horizontal"
size={SIZE.xl}
- onPress={showActionSheet}
+ onPress={() => showActionSheet(item, isTrash)}
customStyle={{
justifyContent: 'center',
height: 35,
diff --git a/apps/mobile/src/components/NoteItem/wrapper.js b/apps/mobile/src/components/NoteItem/wrapper.js
index ea26ff651..6bac270fe 100644
--- a/apps/mobile/src/components/NoteItem/wrapper.js
+++ b/apps/mobile/src/components/NoteItem/wrapper.js
@@ -12,7 +12,7 @@ import { tabBarRef } from '../../utils/Refs';
import { presentDialog } from '../Dialog/functions';
import SelectionWrapper from '../SelectionWrapper';
-export const NoteWrapper = React.memo(({item, index}) => {
+export const NoteWrapper = React.memo(({item, index,tags,compactMode}) => {
const isTrash = item.type === 'trash';
const setSelectedItem = useSelectionStore(state => state.setSelectedItem);
@@ -95,7 +95,16 @@ export const NoteWrapper = React.memo(({item, index}) => {
testID={notesnook.ids.note.get(index)}
onPress={onPress}
item={item}>
- <NoteItem item={item} isTrash={isTrash} />
+ <NoteItem item={item} tags={tags} isTrash={isTrash} />
</SelectionWrapper>
);
+},(prev,next) => {
+ if (prev.tags.length !== next.tags.length) {
+ return false;
+ }
+ if (prev.item !== next.item) {
+ return false;
+ }
+
+ return true;
});
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index ca0655a8c..14c67424a 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -3,10 +3,12 @@ import {TouchableOpacity, View} from 'react-native';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import {notesnook} from '../../../e2e/test.ids';
import {useTracked} from '../../provider';
+import { useSettingStore } from '../../provider/stores';
import Navigation from '../../services/Navigation';
-import {getTotalNotes, history} from '../../utils';
+import {getElevation, getTotalNotes, history} from '../../utils';
import {SIZE} from '../../utils/SizeUtils';
import {ActionIcon} from '../ActionIcon';
+import {Button} from '../Button';
import {ActionSheetEvent} from '../DialogManager/recievers';
import Heading from '../Typography/Heading';
import Paragraph from '../Typography/Paragraph';
@@ -14,6 +16,9 @@ import Paragraph from '../Typography/Paragraph';
export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {
const [state] = useTracked();
const {colors} = state;
+ const settings = useSettingStore(state => state.settings);
+ const compactMode = settings.notebooksListMode === 'compact';
+
const topics = item.topics?.slice(0, 3) || [];
const totalNotes = getTotalNotes(item);
const showActionSheet = () => {
@@ -44,65 +49,58 @@ export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {
<>
<View
style={{
- width: '90%',
- maxWidth: '90%',
- minHeight: 50,
- justifyContent: 'center',
+ flexGrow: 1,
+ flexShrink: 1,
}}>
<Heading
size={SIZE.md}
numberOfLines={1}
style={{
- maxWidth: '100%',
+ flexWrap: 'wrap',
}}>
{item.title}
</Heading>
- {isTopic || !item.description ? null : (
+ {isTopic || !item.description || compactMode ? null : (
<Paragraph
size={SIZE.sm}
numberOfLines={2}
style={{
- maxWidth: '100%',
+ flexWrap: 'wrap',
}}>
{item.description}
</Paragraph>
)}
- {isTopic ? null : (
+ {isTopic || compactMode ? null : (
<View
style={{
flexDirection: 'row',
alignItems: 'center',
- width: '80%',
- maxWidth: '80%',
flexWrap: 'wrap',
- paddingVertical: 0,
}}>
{topics.map(topic => (
- <TouchableOpacity
- activeOpacity={0.8}
- onPress={() => navigateToTopic(topic)}
+ <Button
+ title={topic.title}
key={topic.id}
+ height={25}
+ textStyle={{
+ fontWeight: 'normal',
+ fontFamily: null,
+ }}
+ type="grayBg"
+ fontSize={SIZE.xs + 1}
+ icon="book-open-outline"
style={{
- borderRadius: 2.5,
- backgroundColor: colors.accent,
- paddingHorizontal: 5,
- paddingVertical: 2,
+ borderRadius: 100,
marginRight: 5,
- marginVertical: 2.5,
- maxWidth: 100,
- }}>
- <Paragraph
- size={SIZE.xs}
- numberOfLines={1}
- lineBreakMode="tail"
- color="white"
- style={{
- maxWidth: '100%',
- }}>
- {topic.title}
- </Paragraph>
- </TouchableOpacity>
+ marginVertical: 5,
+ maxWidth: 120,
+ borderWidth: 0.5,
+ borderColor: colors.icon,
+ paddingHorizontal: 6,
+ }}
+ onPress={() => navigateToTopic(topic)}
+ />
))}
</View>
)}
@@ -112,8 +110,8 @@ export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
- marginTop: 2.5,
- minHeight: SIZE.md + 2,
+ marginTop: 5,
+ height: SIZE.md + 2,
}}>
{isTrash ? (
<>
diff --git a/apps/mobile/src/components/NotebookItem/wrapper.js b/apps/mobile/src/components/NotebookItem/wrapper.js
index 3ef9bd176..bece436c3 100644
--- a/apps/mobile/src/components/NotebookItem/wrapper.js
+++ b/apps/mobile/src/components/NotebookItem/wrapper.js
@@ -31,7 +31,7 @@ export const NotebookWrapper = React.memo(({item, index}) => {
id: item.id,
type: item.type,
};
- Navigation.push(routeName, params, headerState);
+ Navigation.navigate(routeName, params, headerState);
};
return (
<SelectionWrapper