Skip to content

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

make pinned items selectable

ammarahm-ed837beaeeccde
diff --git a/apps/mobile/src/common/common.js b/apps/mobile/src/common/common.js
index a39904780..d2c02e84a 100755
--- a/apps/mobile/src/common/common.js
+++ b/apps/mobile/src/common/common.js
@@ -11,7 +11,6 @@ export const scale = {
fontScale: 1,
};
const {height, width} = Dimensions.get('window');
-const standardLength = width > height ? width : height;
//COLOR SCHEME
export const ACCENT = {
@@ -102,7 +101,7 @@ const correction = (size, multiplier) => {
let dSize = getDeviceSize();
if (dSize > 4 && dSize <= 5.3 && pixelDensity <= 3) {
- return size * 0.87;
+ return size * 0.92;
} else if (dSize > 5.5 && dSize < 6.5 && pixelDensity <= 3) {
if (Platform.OS === 'ios') {
return size;
@@ -125,7 +124,6 @@ const correction = (size, multiplier) => {
export const normalize = size => {
let pd = pixelDensity;
- console.log(pd);
if (pd === 1 || pd < 1) {
return correction(size, 0.75);
} else if (pd > 1 && pd <= 1.5) {
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.js
index ff40b7182..725e8cc2b 100644
--- a/apps/mobile/src/components/NoteItem/index.js
+++ b/apps/mobile/src/components/NoteItem/index.js
@@ -82,31 +82,6 @@ export default class NoteItem extends React.Component {
},
customStyle ? customStyle : {},
]}>
- {pinned ? (
- <View
- style={{
- ...getElevation(3),
- width: 30,
- height: 30,
- backgroundColor: colors.accent,
- borderRadius: 100,
- position: 'absolute',
- left: 20,
- top: -15,
- justifyContent: 'center',
- alignItems: 'center',
- }}>
- <View
- style={{
- width: 5,
- height: 5,
- backgroundColor: 'white',
- borderRadius: 100,
- }}
- />
- </View>
- ) : null}
-
<TouchableOpacity
activeOpacity={0.8}
onLongPress={() => onLongPress()}
diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.js
index 9b3986fea..c942e26d9 100644
--- a/apps/mobile/src/components/NotebookItem/index.js
+++ b/apps/mobile/src/components/NotebookItem/index.js
@@ -70,31 +70,6 @@ export const NotebookItem = ({
},
customStyle,
]}>
- {pinned ? (
- <View
- style={{
- ...getElevation(3),
- width: 30,
- height: 30,
- backgroundColor: colors.accent,
- borderRadius: 100,
- position: 'absolute',
- left: 20,
- top: -15,
- justifyContent: 'center',
- alignItems: 'center',
- }}>
- <View
- style={{
- width: 5,
- height: 5,
- backgroundColor: 'white',
- borderRadius: 100,
- }}
- />
- </View>
- ) : null}
-
<View
style={{
flexDirection: 'row',
diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.js
index 0679212ac..60de7192e 100644
--- a/apps/mobile/src/components/NotesList/index.js
+++ b/apps/mobile/src/components/NotesList/index.js
@@ -256,7 +256,7 @@ export const NotesList = ({isGrouped = false}) => {
const PinnedItems = () => {
const [state, dispatch] = useTracked();
- const {pinned, colors} = state;
+ const {pinned, colors, selectionMode} = state;
useEffect(() => {
dispatch({type: ACTIONS.PINNED});
@@ -269,26 +269,43 @@ const PinnedItems = () => {
keyExtractor={(item, index) => item.id.toString()}
renderItem={({item, index}) =>
item.type === 'note' ? (
- <NoteItem
- colors={colors}
- customStyle={{
- backgroundColor: Platform.ios
- ? hexToRGBA(colors.accent + '19')
- : hexToRGBA(colors.shade),
- width: '100%',
- paddingHorizontal: 12,
- paddingTop: 20,
- paddingRight: 18,
- marginBottom: 10,
- marginTop: 20,
- borderBottomWidth: 0,
- marginHorizontal: 0,
- }}
- onLongPress={() => {}}
- pinned={true}
- item={item}
+ <SelectionWrapper
index={index}
- />
+ currentEditingNote={false}
+ pinned={true}
+ background={
+ Platform.ios
+ ? hexToRGBA(colors.accent + '19')
+ : hexToRGBA(colors.shade)
+ }
+ item={item}>
+ <NoteItem
+ colors={colors}
+ customStyle={{
+ width: selectionMode ? '90%' : '100%',
+ marginHorizontal: 0,
+ paddingTop: 15,
+ paddingRight: 18,
+ marginBottom: 10,
+ marginTop: 15,
+ borderBottomWidth: 0,
+ }}
+ currentEditingNote={false}
+ pinned={true}
+ selectionMode={selectionMode}
+ onLongPress={() => {
+ if (!selectionMode) {
+ dispatch({type: ACTIONS.SELECTION_MODE, enabled: true});
+ }
+ dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
+ }}
+ update={() => {
+ dispatch({type: ACTIONS.NOTES});
+ }}
+ item={item}
+ index={index}
+ />
+ </SelectionWrapper>
) : null
}
/>
diff --git a/apps/mobile/src/components/SelectionWrapper/index.js b/apps/mobile/src/components/SelectionWrapper/index.js
index c4d2b858d..6249f2a4f 100644
--- a/apps/mobile/src/components/SelectionWrapper/index.js
+++ b/apps/mobile/src/components/SelectionWrapper/index.js
@@ -5,8 +5,16 @@ import {SIZE} from '../../common/common';
import {useTracked} from '../../provider';
import {ACTIONS} from '../../provider/actions';
import Animated from 'react-native-reanimated';
+import {getElevation} from '../../utils/utils';
-const SelectionWrapper = ({children, item, currentEditingNote, index}) => {
+const SelectionWrapper = ({
+ children,
+ item,
+ currentEditingNote,
+ index,
+ background,
+ pinned,
+}) => {
const [state, dispatch] = useTracked();
const {colors, selectionMode, selectedItemsList} = state;
const [selected, setSelected] = useState(false);
@@ -34,11 +42,44 @@ const SelectionWrapper = ({children, item, currentEditingNote, index}) => {
alignItems: 'center',
width: '100%',
paddingHorizontal: 12,
+ marginTop:
+ index === 0 && pinned && !selectionMode
+ ? 15
+ : index === 0 && pinned && selectionMode
+ ? 30
+ : 0,
backgroundColor:
currentEditingNote === item.dateCreated
? colors.shade
+ : background
+ ? background
: 'transparent',
}}>
+ {pinned ? (
+ <View
+ style={{
+ ...getElevation(3),
+ width: 30,
+ height: 30,
+ backgroundColor: colors.accent,
+ borderRadius: 100,
+ position: 'absolute',
+ left: 20,
+ top: -15,
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}>
+ <View
+ style={{
+ width: 5,
+ height: 5,
+ backgroundColor: 'white',
+ borderRadius: 100,
+ }}
+ />
+ </View>
+ ) : null}
+
<View
style={{
display: selectionMode ? 'flex' : 'none',
diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js
index 259f53b0e..bc825465c 100644
--- a/apps/mobile/src/components/SimpleList/index.js
+++ b/apps/mobile/src/components/SimpleList/index.js
@@ -7,7 +7,8 @@ import {ACTIONS} from '../../provider/actions';
import {eSendEvent} from '../../services/eventManager';
import {eScrollEvent, eClearSearch} from '../../services/events';
import {NotebookItem} from '../NotebookItem';
-import {hexToRGBA} from '../../utils/utils';
+import {hexToRGBA, getElevation} from '../../utils/utils';
+import SelectionWrapper from '../SelectionWrapper';
const SimpleList = ({
data,
@@ -108,29 +109,45 @@ const SimpleList = ({
keyExtractor={(item, index) => item.id.toString()}
renderItem={({item, index}) =>
item.type === 'notebook' ? (
- <NotebookItem
- hideMore={hideMore}
- customStyle={{
- backgroundColor: Platform.ios
- ? hexToRGBA(colors.accent + '19')
- : hexToRGBA(colors.shade),
- width: '100%',
- paddingHorizontal: 12,
- paddingTop: 20,
- paddingRight: 18,
- marginBottom: 10,
- marginTop: 20,
- borderBottomWidth: 0,
- marginHorizontal: 0,
- }}
- isMove={isMove}
- onLongPress={() => {}}
- noteToMove={noteToMove}
- item={item}
- pinned={true}
+ <SelectionWrapper
index={index}
- colors={colors}
- />
+ currentEditingNote={false}
+ pinned={true}
+ background={
+ Platform.ios
+ ? hexToRGBA(colors.accent + '19')
+ : hexToRGBA(colors.shade)
+ }
+ item={item}>
+ <NotebookItem
+ hideMore={hideMore}
+ customStyle={{
+ width: '100%',
+ paddingTop: 15,
+ paddingRight: 18,
+ marginBottom: 10,
+ marginTop: 15,
+ borderBottomWidth: 0,
+ marginHorizontal: 0,
+ }}
+ isMove={isMove}
+ selectionMode={selectionMode}
+ onLongPress={() => {
+ if (!selectionMode) {
+ dispatch({
+ type: ACTIONS.SELECTION_MODE,
+ enabled: true,
+ });
+ }
+ dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});
+ }}
+ noteToMove={noteToMove}
+ item={item}
+ pinned={true}
+ index={index}
+ colors={colors}
+ />
+ </SelectionWrapper>
) : null
}
/>