Skip to content

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

change color adding system for notes

ammarahm-ed660538468b03
diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js
index 8837c77e3..3c28d99f1 100644
--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js
+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js
@@ -17,8 +17,7 @@ import {sleep} from '../../utils/TimeUtils';
import {PressableButton} from '../PressableButton';
export const ActionSheetColorsSection = ({item, close}) => {
- const [state, dispatch] = useTracked();
- const {colors} = state;
+ const [, dispatch] = useTracked();
const [note, setNote] = useState(item);
const localRefresh = () => {
@@ -49,8 +48,8 @@ export const ActionSheetColorsSection = ({item, close}) => {
testID={notesnook.ids.dialogs.actionsheet.color(c)}
key={color.value}
onPress={async () => {
- let noteColors = note.colors;
- if (noteColors.includes(color.name)) {
+ let noteColor = note.color;
+ if (noteColor === color.name) {
await db.notes.note(note.id).uncolor(color.name);
} else {
await db.notes.note(note.id).color(color.name);
@@ -66,7 +65,7 @@ export const ActionSheetColorsSection = ({item, close}) => {
justifyContent: 'center',
alignItems: 'center',
}}>
- {note && note.colors && note.colors.includes(color.name) ? (
+ {note.color === color.name ? (
<Icon name="check" color="white" size={SIZE.lg} />
) : null}
</PressableButton>
diff --git a/apps/mobile/src/components/Menu/index.js b/apps/mobile/src/components/Menu/index.js
index 2f12ede52..d324d8f0f 100644
--- a/apps/mobile/src/components/Menu/index.js
+++ b/apps/mobile/src/components/Menu/index.js
@@ -1,7 +1,7 @@
-import React, { useEffect } from 'react';
+import React, {useEffect} from 'react';
import {FlatList, ScrollView, View} from 'react-native';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
-import { notesnook } from '../../../e2e/test.ids';
+import {notesnook} from '../../../e2e/test.ids';
import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions';
import {DDS} from '../../services/DeviceDetection';
@@ -54,8 +54,7 @@ export const Menu = React.memo(
close: true,
},
];
-
-
+
return (
<View
style={{
@@ -75,12 +74,7 @@ export const Menu = React.memo(
renderItem={() => (
<>
{MenuItemsList.map((item, index) => (
- <MenuListItem
- key={item.name}
- item={item}
- testID={item.name}
- index={index}
- />
+ <MenuListItem key={item.name} item={item} testID={item.name} index={index} />
))}
<ColorSection noTextMode={noTextMode} />
<TagsSection />
@@ -90,7 +84,11 @@ export const Menu = React.memo(
{BottomItemsList.map((item, index) => (
<MenuListItem
- testID={item.name == 'Night mode' ? notesnook.ids.menu.nightmode : item.name}
+ testID={
+ item.name == 'Night mode'
+ ? notesnook.ids.menu.nightmode
+ : item.name
+ }
key={item.name}
item={item}
index={index}
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index f8f77f23b..c350557f4 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -132,17 +132,15 @@ export default class NoteItem extends React.Component {
/>
<Heading
size={SIZE.xs}
- color={
- item.colors[0] ? COLORS_NOTE[item.colors[0]] : colors.accent
- }>
- {db.notebooks.notebook(item.notebooks[0].id).title}
+ color={item.color ? COLORS_NOTE[item.color] : colors.accent}>
+ {db.notebooks.notebook(item.notebooks[0].id).title}
</Heading>
</TouchableOpacity>
</View>
)}
<Heading
- color={COLORS_NOTE[item.colors[0]]}
+ color={COLORS_NOTE[item.color]}
numberOfLines={1}
size={SIZE.md}>
{item.title.replace('\n', '')}
@@ -164,28 +162,18 @@ export default class NoteItem extends React.Component {
}}>
{!isTrash ? (
<>
- {item.colors.length > 0 ? (
+ {item.color &&
<View
+ key={item}
style={{
+ width: SIZE.xs,
+ height: SIZE.xs,
+ borderRadius: 100,
+ backgroundColor: COLORS_NOTE[item.color],
+ marginRight: -4.5,
marginRight: 10,
- flexDirection: 'row',
- justifyContent: 'center',
- alignItems: 'center',
- }}>
- {item.colors.map((item) => (
- <View
- key={item}
- style={{
- width: SIZE.xs,
- height: SIZE.xs,
- borderRadius: 100,
- backgroundColor: COLORS_NOTE[item],
- marginRight: -4.5,
- }}
- />
- ))}
- </View>
- ) : null}
+ }}
+ />}
{item.locked ? (
<Icon
diff --git a/apps/mobile/src/components/SelectionWrapper/index.js b/apps/mobile/src/components/SelectionWrapper/index.js
index f08bce228..42bfb4d03 100644
--- a/apps/mobile/src/components/SelectionWrapper/index.js
+++ b/apps/mobile/src/components/SelectionWrapper/index.js
@@ -68,8 +68,8 @@ const SelectionWrapper = ({
<PressableButton
customColor={
currentEditingNote === item.id
- ? item.type === 'note' && item.colors[0]
- ? COLORS_NOTE[item.colors[0]]
+ ? item.type === 'note' && item.color
+ ? COLORS_NOTE[item.color]
: colors.shade
: background
? background
diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js
index 7c673ff72..18a81b2f0 100644
--- a/apps/mobile/src/views/Editor/Functions.js
+++ b/apps/mobile/src/views/Editor/Functions.js
@@ -63,8 +63,8 @@ export function setColors(colors) {
}
let theme = {...appColors, factor: normalize(1)};
- if (note && note.colors[0] && !DDS.isLargeTablet()) {
- theme.shade = hexToRGBA(COLORS_NOTE[note.colors[0]], 0.15);
+ if (note && note.color && !DDS.isLargeTablet()) {
+ theme.shade = hexToRGBA(COLORS_NOTE[note.color], 0.15);
}
post('theme', theme);
}