Skip to content

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

fix incorrect size of items in the list

ammarahm-ed18cb552a3f0e
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index 1a1ea2d87..17e73a2ca 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -66,7 +66,7 @@ export default class NoteItem extends React.Component {
};
render() {
- let {colors, item, customStyle, isTrash} = this.props;
+ let {colors, item, customStyle, isTrash,fontScale} = this.props;
return (
<View
style={[
@@ -79,7 +79,7 @@ export default class NoteItem extends React.Component {
alignSelf: 'center',
borderBottomWidth: 1,
borderBottomColor: colors.nav,
- height: 100,
+ height: 100 * fontScale,
},
customStyle ? customStyle : {},
]}>
@@ -115,7 +115,7 @@ export default class NoteItem extends React.Component {
{db.notebooks.notebook(item.notebooks[0]?.id)?.title + ' '}{' '}
{item.notebooks.length > 1
? '& ' + (item.notebooks.length - 1) + ' others'
- : ''}
+ : ''}
</Heading>
</TouchableOpacity>
</View>
@@ -125,15 +125,11 @@ export default class NoteItem extends React.Component {
color={COLORS_NOTE[item.color]}
numberOfLines={1}
size={SIZE.md}>
- {item?.title.replace('\n', '')}
+ {item.title}
</Heading>
- {item?.headline ? (
- <Paragraph numberOfLines={2}>
- {item.headline[item.headline.length - 1] === '\n'
- ? item.headline.slice(0, item.headline.length - 1)
- : item.headline}
- </Paragraph>
+ {item.headline ? (
+ <Paragraph numberOfLines={2}>{item.headline}</Paragraph>
) : null}
<View
diff --git a/apps/mobile/src/components/NoteItem/wrapper.js b/apps/mobile/src/components/NoteItem/wrapper.js
index 9372cfb8d..77ff717a9 100644
--- a/apps/mobile/src/components/NoteItem/wrapper.js
+++ b/apps/mobile/src/components/NoteItem/wrapper.js
@@ -16,12 +16,15 @@ import {db} from '../../utils/DB';
import {DDS} from '../../services/DeviceDetection';
import {tabBarRef} from '../../utils/Refs';
import {notesnook} from '../../../e2e/test.ids';
+import {history} from '../../utils';
+import { useWindowDimensions } from 'react-native';
export const NoteWrapper = ({item, index, isTrash = false}) => {
const [state, dispatch] = useTracked();
- const {colors, selectionMode} = state;
+ const {colors} = state;
const [note, setNote] = useState(item);
-
+ const {fontScale} = useWindowDimensions();
+
useEffect(() => {
setNote(item);
}, [item]);
@@ -48,34 +51,26 @@ export const NoteWrapper = ({item, index, isTrash = false}) => {
};
}, [note]);
- const style = useMemo(() => {
- return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};
- }, [selectionMode]);
-
- const onLongPress = () => {
- if (!selectionMode) {
- dispatch({type: Actions.SELECTION_MODE, enabled: true});
- }
- dispatch({type: Actions.SELECTED_ITEMS, item: note});
- };
-
+
const onPress = async () => {
if (note.conflicted) {
eSendEvent(eShowMergeDialog, note);
return;
}
- if (selectionMode) {
- onLongPress();
+ if (history.selectedItemsList.length > 0) {
+ dispatch({type: Actions.SELECTED_ITEMS, item: note});
return;
- } else if (note.locked) {
+ }
+
+ if (note.locked) {
openVault({
item: item,
novault: true,
locked: true,
goToEditor: true,
- title:'Open note',
- description:"Unlock note to open it in editor."
+ title: 'Open note',
+ description: 'Unlock note to open it in editor.',
});
return;
}
@@ -93,14 +88,12 @@ export const NoteWrapper = ({item, index, isTrash = false}) => {
<SelectionWrapper
index={index}
testID={notesnook.ids.note.get(index)}
- onLongPress={onLongPress}
onPress={onPress}
item={note}>
<NoteItem
colors={colors}
- customStyle={style}
- selectionMode={selectionMode}
item={note}
+ fontScale={fontScale}
isTrash={isTrash}
/>
</SelectionWrapper>
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 1cbec94e0..465f39865 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -1,9 +1,11 @@
import React from 'react';
+import { useWindowDimensions } from 'react-native';
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 Navigation from '../../services/Navigation';
+import { history } from '../../utils';
import {pv, SIZE} from '../../utils/SizeUtils';
import {ActionIcon} from '../ActionIcon';
import {ActionSheetEvent} from '../DialogManager/recievers';
@@ -19,7 +21,7 @@ export const NotebookItem = ({
}) => {
const [state] = useTracked();
const {colors} = state;
-
+ const {fontScale} = useWindowDimensions();
const showActionSheet = () => {
let rowItems = isTrash
? ['Restore', 'Remove']
@@ -40,7 +42,7 @@ export const NotebookItem = ({
<View
style={[
{
- height: isTopic ? 80 : 110,
+ height: isTopic ? 80 * fontScale : 110 * fontScale,
justifyContent: 'space-between',
alignItems: 'center',
flexDirection: 'row',
@@ -50,7 +52,6 @@ export const NotebookItem = ({
borderBottomColor: item.pinned ? 'transparent' : colors.nav,
width: '100%',
},
- customStyle,
]}>
<View
style={{
@@ -97,6 +98,7 @@ export const NotebookItem = ({
<TouchableOpacity
activeOpacity={0.8}
onPress={() => {
+ if (history.selectedItemsList.length > 0) return;
let routeName = 'NotesPage';
let params = {...topic, menu: false};
let headerState = {
diff --git a/apps/mobile/src/components/NotebookItem/wrapper.js b/apps/mobile/src/components/NotebookItem/wrapper.js
index fe894095a..10565a1e0 100644
--- a/apps/mobile/src/components/NotebookItem/wrapper.js
+++ b/apps/mobile/src/components/NotebookItem/wrapper.js
@@ -6,6 +6,7 @@ import {useTracked} from '../../provider';
import {Actions} from '../../provider/Actions';
import Navigation from '../../services/Navigation';
import {rootNavigatorRef} from '../../utils/Refs';
+import { history } from '../../utils';
export const NotebookWrapper = ({
item,
@@ -15,31 +16,14 @@ export const NotebookWrapper = ({
isTopic,
}) => {
const [state, dispatch] = useTracked();
- const {selectionMode, preventDefaultMargins} = state;
- const style = useMemo(() => {
- return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};
- }, [selectionMode]);
- const onLongPress = () => {
- if (item.title === 'General') return;
- if (!selectionMode) {
+ const onPress = () => {
+ if (history.selectedItemsList.length > 0) {
dispatch({
- type: Actions.SELECTION_MODE,
- enabled: !selectionMode,
+ type: Actions.SELECTED_ITEMS,
+ item: item,
});
- }
-
- dispatch({
- type: Actions.SELECTED_ITEMS,
- item: item,
- });
- };
-
- const onPress = () => {
- if (selectionMode) {
-
- onLongPress();
return;
}
let routeName = isTopic ? 'NotesPage' : 'Notebook';
@@ -59,7 +43,6 @@ export const NotebookWrapper = ({
};
return (
<SelectionWrapper
- onLongPress={onLongPress}
pinned={pinned}
testID={
isTopic
@@ -70,9 +53,7 @@ export const NotebookWrapper = ({
onPress={onPress}
item={item}>
<NotebookItem
- hideMore={preventDefaultMargins}
isTopic={isTopic}
- customStyle={style}
item={item}
index={index}
isTrash={isTrash}
diff --git a/apps/mobile/src/components/TagItem/index.js b/apps/mobile/src/components/TagItem/index.js
index 662b15484..c0451665d 100644
--- a/apps/mobile/src/components/TagItem/index.js
+++ b/apps/mobile/src/components/TagItem/index.js
@@ -1,5 +1,5 @@
import React from 'react';
-import {View} from 'react-native';
+import {useWindowDimensions, View} from 'react-native';
import { notesnook } from '../../../e2e/test.ids';
import {PressableButton} from '../../components/PressableButton';
import {useTracked} from '../../provider';
@@ -13,7 +13,7 @@ import Paragraph from '../Typography/Paragraph';
const TagItem = ({item, index}) => {
const [state] = useTracked();
const {colors} = state;
-
+ const {fontScale} = useWindowDimensions();
const onPress = () => {
Navigation.navigate(
'NotesPage',
@@ -39,7 +39,7 @@ const TagItem = ({item, index}) => {
opacity={1}
customStyle={{
paddingHorizontal: 12,
- height: 80,
+ height: 80 * fontScale,
flexDirection: 'row',
alignItems: 'center',
borderBottomWidth: 1.5,