A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
improve note items design
ammarahm-eda6238eacc4de
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.jsindex 5ea9559be..afb3d11f3 100644--- a/apps/mobile/src/components/NoteItem/index.js+++ b/apps/mobile/src/components/NoteItem/index.js@@ -54,21 +54,36 @@ export default class NoteItem extends React.Component {}}+ _onPress = async () => {+ if (item.conflicted) {+ eSendEvent(eShowMergeDialog, item);++ return;+ }+ if (this.props.selectionMode) {+ this.props.onLongPress();+ return;+ } else if (item.locked) {+ openVault(item, true, true, false, true, false);++ return;+ }+ if (DDS.isTab) {+ eSendEvent(eOnLoadNote, item);+ } else if (isTrash) {+ simpleDialogEvent(TEMPLATE_TRASH(item.type));+ } else {+ eSendEvent(eOnLoadNote, item);+ openEditorAnimation();+ }+ };+render() {- let {- colors,- item,- customStyle,- onLongPress,- isTrash,- pinned,- index,- } = this.props;+ let {colors, item, customStyle, isTrash} = this.props;return (<Viewstyle={[{- paddingVertical: pv,justifyContent: 'flex-start',alignItems: 'center',flexDirection: 'row',@@ -76,182 +91,156 @@ export default class NoteItem extends React.Component {paddingRight: 6,alignSelf: 'center',borderBottomWidth: 1,+ height: 100,borderBottomColor: colors.nav,},customStyle ? customStyle : {},]}>- <TouchableOpacity- activeOpacity={0.8}- onLongPress={() => onLongPress()}- onPress={async () => {- if (item.conflicted) {- eSendEvent(eShowMergeDialog, item);-- return;- }- if (this.props.selectionMode) {- this.props.onLongPress();- return;- } else if (item.locked) {- openVault(item, true, true, false, true, false);-- return;- }- if (DDS.isTab) {- eSendEvent(eOnLoadNote, item);- } else if (isTrash) {- simpleDialogEvent(TEMPLATE_TRASH(item.type));- } else {- eSendEvent(eOnLoadNote, item);- openEditorAnimation();- }- }}+ <Viewstyle={{paddingLeft: 0,width: '95%',}}>- <>+ <Text+ numberOfLines={1}+ style={{+ color: colors.heading,+ fontSize: SIZE.sm + 1,+ fontFamily: WEIGHT.bold,+ maxWidth: '100%',+ }}>+ {item.title.replace('\n', '')}+ </Text>+ <View+ style={{+ justifyContent: 'flex-start',+ alignItems: 'flex-start',+ width: '100%',+ }}><Text- numberOfLines={1}+ numberOfLines={2}style={{- color: colors.heading,- fontSize: SIZE.sm + 1,- fontFamily: WEIGHT.bold,+ fontSize: SIZE.sm - 1,+ color: colors.pri + 'B3',+ fontFamily: WEIGHT.regular,+ width: '100%',maxWidth: '100%',+ paddingRight: ph,}}>- {item.title.replace('\n', '')}+ {item.headline[item.headline.length - 1] === '\n'+ ? item.headline.slice(0, item.headline.length - 1)+ : item.headline}</Text>+<Viewstyle={{+ flexDirection: 'row',justifyContent: 'flex-start',- alignItems: 'flex-start',+ alignItems: 'center',width: '100%',+ marginTop: 5,}}>- <Text- numberOfLines={2}- style={{- fontSize: SIZE.sm - 1,- color: colors.pri + 'B3',- fontFamily: WEIGHT.regular,- width: '100%',- maxWidth: '100%',- paddingRight: ph,- }}>- {item.headline[item.headline.length - 1] === '\n'- ? item.headline.slice(0, item.headline.length - 1)- : item.headline}- </Text>-- <View- style={{- flexDirection: 'row',- justifyContent: 'flex-start',- alignItems: 'center',- width: '100%',- marginTop: 5,- }}>- {!isTrash ? (- <>- {item.colors.length > 0 ? (- <View- style={{- 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: item,- marginRight: -4.5,- }}- />- ))}- </View>- ) : null}-- {item.locked ? (- <Icon- style={{marginRight: 10}}- name="lock"- size={SIZE.xs}- color={colors.icon}- />- ) : null}-- {item.favorite ? (- <Icon- style={{marginRight: 10}}- name="star"- size={SIZE.xs + 1}- color="orange"- />- ) : null}- <Text+ {!isTrash ? (+ <>+ {item.colors.length > 0 ? (+ <Viewstyle={{- color: colors.icon,- fontSize: SIZE.xs - 1,- textAlignVertical: 'center',- fontFamily: WEIGHT.regular,marginRight: 10,+ flexDirection: 'row',+ justifyContent: 'center',+ alignItems: 'center',}}>- {timeSince(item.dateCreated)}- </Text>- </>- ) : null}+ {item.colors.map((item) => (+ <View+ key={item}+ style={{+ width: SIZE.xs,+ height: SIZE.xs,+ borderRadius: 100,+ backgroundColor: item,+ marginRight: -4.5,+ }}+ />+ ))}+ </View>+ ) : null}- {isTrash ? (- <>- <Text- style={{- color: colors.icon,- fontSize: SIZE.xs - 1,- textAlignVertical: 'center',- fontFamily: WEIGHT.regular,- }}>- {'Deleted on: ' + item && item.dateDeleted- ? new Date(item.dateDeleted).toISOString().slice(0, 10)- : null + ' '}- </Text>- <Text- style={{- color: colors.accent,- fontSize: SIZE.xs - 1,- textAlignVertical: 'center',- fontFamily: WEIGHT.regular,- }}>- {item.type[0].toUpperCase() + item.type.slice(1) + ' '}- </Text>- </>- ) : null}+ {item.locked ? (+ <Icon+ style={{marginRight: 10}}+ name="lock"+ size={SIZE.xs}+ color={colors.icon}+ />+ ) : null}- {item.conflicted ? (- <View+ {item.favorite ? (+ <Icon+ style={{marginRight: 10}}+ name="star"+ size={SIZE.xs + 1}+ color="orange"+ />+ ) : null}+ <Textstyle={{- backgroundColor: colors.errorText,- borderRadius: 2.5,- paddingHorizontal: 4,- position: 'absolute',- right: 20,+ color: colors.icon,+ fontSize: SIZE.xs - 1,+ textAlignVertical: 'center',+ fontFamily: WEIGHT.regular,+ marginRight: 10,}}>- <Text- style={{- fontSize: SIZE.xs - 1,- color: 'white',- }}>- CONFLICTS- </Text>- </View>- ) : null}- </View>+ {timeSince(item.dateCreated)}+ </Text>+ </>+ ) : null}++ {isTrash ? (+ <>+ <Text+ style={{+ color: colors.icon,+ fontSize: SIZE.xs - 1,+ textAlignVertical: 'center',+ fontFamily: WEIGHT.regular,+ }}>+ {'Deleted on: ' + item && item.dateDeleted+ ? new Date(item.dateDeleted).toISOString().slice(0, 10)+ : null + ' '}+ </Text>+ <Text+ style={{+ color: colors.accent,+ fontSize: SIZE.xs - 1,+ textAlignVertical: 'center',+ fontFamily: WEIGHT.regular,+ }}>+ {item.type[0].toUpperCase() + item.type.slice(1) + ' '}+ </Text>+ </>+ ) : null}++ {item.conflicted ? (+ <View+ style={{+ backgroundColor: colors.errorText,+ borderRadius: 2.5,+ paddingHorizontal: 4,+ position: 'absolute',+ right: 20,+ }}>+ <Text+ style={{+ fontSize: SIZE.xs - 1,+ color: 'white',+ }}>+ CONFLICTS+ </Text>+ </View>+ ) : null}</View>- </>- </TouchableOpacity>+ </View>+ </View><TouchableOpacitystyle={{diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.jsindex 3bcb2a0c6..62c23c8d7 100644--- a/apps/mobile/src/components/NotebookItem/index.js+++ b/apps/mobile/src/components/NotebookItem/index.js@@ -1,296 +1,237 @@import React from 'react';-import { Text, TouchableOpacity, View } from 'react-native';+import {Text, TouchableOpacity, View} from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { ph, pv, SIZE, WEIGHT } from '../../common/common';-import { useTracked } from '../../provider';-import { ACTIONS } from '../../provider/actions';+import {ph, pv, SIZE, WEIGHT} from '../../common/common';+import {useTracked} from '../../provider';+import {ACTIONS} from '../../provider/actions';import NavigationService from '../../services/NavigationService';-import { db, ToastEvent } from '../../utils/utils';-import { Button } from '../Button';-import { ActionSheetEvent, moveNoteHideEvent } from '../DialogManager/recievers';+import {db, ToastEvent} from '../../utils/utils';+import {Button} from '../Button';+import {ActionSheetEvent, moveNoteHideEvent} from '../DialogManager/recievers';+import Seperator from '../Seperator';export const NotebookItem = ({item,- index,hideMore = false,- topic,isTopic = false,- isMove = false,- noteToMove = null,notebookID,numColumns,isTrash,customStyle,- onLongPress,- navigation,- selectionMode,- pinned,}) => {const [state, dispatch] = useTracked();const {colors, selectedItemsList} = state;- const navigate = () => {- if (selectionMode) {- onLongPress();- return;- }- if (isTopic) {- NavigationService.navigate('Notes', {- ...item,- });- } else {- dispatch({- type: ACTIONS.HEADER_TEXT_STATE,- state: {- heading: hideMore ? 'Move to topic' : item.title,- },- });- dispatch({- type: ACTIONS.HEADER_STATE,- state: {- canGoBack: true,- menu: false,- },- });- dispatch({- type: ACTIONS.CONTAINER_BOTTOM_BUTTON,- state: {- bottomButtonText: 'Add new topic',- },- });-- hideMore- ? navigation.navigate('Notebook', {- notebook: item,- title: hideMore ? 'Move to topic' : item.title,- isMove: isMove,- hideMore: hideMore,- root: false,- })- : NavigationService.navigate('Notebook', {- notebook: item,- title: hideMore ? 'Select a topic' : item.title,- isMove: isMove,- hideMore: hideMore,- root: true,- });- }- };-return (<Viewstyle={[{- paddingVertical: isTopic ? pv / 2 : pv,- justifyContent: 'flex-start',+ height: isTopic ? 80 : 120,+ justifyContent: 'space-between',alignItems: 'center',flexDirection: 'row',paddingRight: 6,alignSelf: 'center',borderBottomWidth: 1,borderBottomColor: colors.nav,+ width: '100%',},customStyle,]}><Viewstyle={{- flexDirection: 'row',- justifyContent: 'space-between',- alignItems: 'center',- width: '100%',+ width: hideMore ? '80%' : '90%',+ maxWidth: hideMore ? '80%' : '90%',+ minHeight: 50,+ justifyContent: 'center',}}>- <TouchableOpacity- activeOpacity={0.8}+ <Text+ numberOfLines={1}style={{- width: hideMore ? '80%' : '90%',- maxWidth: hideMore ? '80%' : '90%',- minHeight: 50,- justifyContent: 'center',- }}- onLongPress={onLongPress}- onPress={navigate}>+ fontFamily: WEIGHT.bold,+ fontSize: SIZE.md,+ color: colors.heading,+ maxWidth: '100%',+ }}>+ {item.title}+ </Text>+ {isTopic || !item.description ? null : (<Text- numberOfLines={1}+ numberOfLines={numColumns === 2 ? 3 : 2}style={{- fontFamily: WEIGHT.bold,- fontSize: SIZE.sm + 1,- color: colors.heading,+ fontFamily: WEIGHT.regular,+ fontSize: SIZE.xs + 1,+ lineHeight: SIZE.sm,+ color: colors.pri,maxWidth: '100%',+ paddingVertical: 5,+ height: numColumns === 2 ? SIZE.sm * 3.5 : null,}}>- {item.title}+ {item.description}</Text>- {isTopic || !item.description ? null : (- <Text- numberOfLines={numColumns === 2 ? 3 : 2}- style={{- fontFamily: WEIGHT.regular,- fontSize: SIZE.xs + 1,- lineHeight: SIZE.sm,- color: colors.pri,- maxWidth: '100%',- paddingVertical: 5,- height: numColumns === 2 ? SIZE.sm * 3.5 : null,- }}>- {item.description}- </Text>- )}-- {isTopic ? null : (- <View- style={{- flexDirection: 'row',- alignItems: 'center',- width: '80%',- maxWidth: '80%',- flexWrap: 'wrap',- }}>- {item && item.topics- ? item.topics.slice(1, 4).map((topic) => (- <View- key={topic.dateCreated.toString() + topic.title}- style={{- borderRadius: 5,- backgroundColor: colors.accent,- paddingHorizontal: ph / 1.5,- paddingVertical: pv / 3,- marginRight: 5,- marginVertical: 2.5,- }}>- <Text- numberOfLines={1}- style={{- color: 'white',- fontFamily: WEIGHT.regular,- fontSize: SIZE.xxs,- maxWidth: '100%',- }}>- {topic.title}- </Text>- </View>- ))- : null}- </View>- )}+ )}- {isTrash ? (- <View- style={{- flexDirection: 'row',- alignItems: 'center',- marginTop: 5,- }}>+ {isTopic ? null : (+ <View+ style={{+ flexDirection: 'row',+ alignItems: 'center',+ width: '80%',+ maxWidth: '80%',+ flexWrap: 'wrap',+ }}>+ {item && item.topics ? (+ item.topics.slice(1, 4).map((topic) => (+ <View+ key={topic.dateCreated.toString() + topic.title}+ style={{+ borderRadius: 2.5,+ backgroundColor: colors.accent,+ paddingHorizontal: ph / 1.5,+ paddingVertical: pv / 3,+ marginRight: 5,+ marginVertical: 2.5,+ }}>+ <Text+ numberOfLines={1}+ style={{+ color: 'white',+ fontFamily: WEIGHT.regular,+ fontSize: SIZE.xxs,+ maxWidth: '100%',+ }}>+ {topic.title}+ </Text>+ </View>+ ))+ ) : (<Textstyle={{color: colors.icon,- fontSize: SIZE.xs - 1,- textAlignVertical: 'center',- fontFamily: WEIGHT.regular,- }}>- {'Deleted on: ' + item && item.dateDeleted- ? new Date(item.dateDeleted).toISOString().slice(0, 10)- : null + ' '}- </Text>- <Text- style={{- color: colors.accent,- fontSize: SIZE.xs - 1,- textAlignVertical: 'center',fontFamily: WEIGHT.regular,+ fontSize: SIZE.xxs,+ paddingVertical: pv / 3,+ maxWidth: '100%',}}>- {item.type[0].toUpperCase() + item.type.slice(1) + ' '}+ This notebook has no topics.</Text>- </View>- ) : null}+ )}+ </View>+ )}+ {isTrash ? (<Viewstyle={{flexDirection: 'row',- justifyContent: 'flex-start',alignItems: 'center',marginTop: 5,}}><Textstyle={{color: colors.icon,- fontSize: SIZE.xxs,+ fontSize: SIZE.xs - 1,textAlignVertical: 'center',fontFamily: WEIGHT.regular,}}>- {item && item.totalNotes && item.totalNotes > 1- ? item.totalNotes + ' notes'- : item.totalNotes === 1- ? item.totalNotes + ' note'- : '0 notes'}+ {'Deleted on: ' + item && item.dateDeleted+ ? new Date(item.dateDeleted).toISOString().slice(0, 10)+ : null + ' '}+ </Text>+ <Text+ style={{+ color: colors.accent,+ fontSize: SIZE.xs - 1,+ textAlignVertical: 'center',+ fontFamily: WEIGHT.regular,+ }}>+ {item.type[0].toUpperCase() + item.type.slice(1) + ' '}</Text>-- {isTopic || isTrash ? null : (- <Text- style={{- color: colors.accent,- marginLeft: 10,- fontSize: SIZE.xxs,- textAlignVertical: 'center',- fontFamily: WEIGHT.regular,- }}>- {new Date(item.dateCreated).toDateString().substring(4)}- </Text>- )}</View>- </TouchableOpacity>- {hideMore ||- (item.title === 'General' && item.type === 'topic') ? null : (- <TouchableOpacity+ ) : null}++ <View+ style={{+ flexDirection: 'row',+ justifyContent: 'flex-start',+ alignItems: 'center',+ marginTop: 5,+ }}>+ {isTrash ? null : (+ <Text+ style={{+ color: colors.icon,+ fontSize: SIZE.xxs,+ textAlignVertical: 'center',+ fontFamily: WEIGHT.regular,+ }}>+ {new Date(item.dateCreated).toDateString().substring(4)}+ </Text>+ )}+ <Seperator half />+ <Textstyle={{- justifyContent: 'center',- minHeight: 70,- alignItems: 'center',- }}- onPress={() => {- let rowItems = isTrash- ? ['Restore', 'Remove']- : [- item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook',- 'Delete',- ];+ color: colors.icon,+ fontSize: SIZE.xxs,+ textAlignVertical: 'center',+ fontFamily: WEIGHT.regular,+ }}>+ {item && item.totalNotes && item.totalNotes > 1+ ? item.totalNotes + ' Notes'+ : item.totalNotes === 1+ ? item.totalNotes + ' Note'+ : '0 Notes'}+ </Text>+ </View>+ </View>+ {hideMore ||+ (item.title === 'General' && item.type === 'topic') ? null : (+ <TouchableOpacity+ style={{+ justifyContent: 'center',+ minHeight: 70,+ alignItems: 'center',+ }}+ onPress={() => {+ let rowItems = isTrash+ ? ['Restore', 'Remove']+ : [+ item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook',+ 'Delete',+ ];- let columnItems = item.type === 'topic' ? [] : ['Pin'];+ let columnItems = item.type === 'topic' ? [] : ['Pin'];- ActionSheetEvent(item, false, false, rowItems, columnItems, {- notebookID: notebookID,- });- }}>- <Icon- name="dots-horizontal"- size={SIZE.lg}- color={colors.heading}- />- </TouchableOpacity>- )}+ ActionSheetEvent(item, false, false, rowItems, columnItems, {+ notebookID: notebookID,+ });+ }}>+ <Icon name="dots-horizontal" size={SIZE.lg} color={colors.heading} />+ </TouchableOpacity>+ )}- {hideMore && isTopic ? (- <Button- width="20%"- title="Move"- onPress={async () => {- let noteIds = [];- selectedItemsList.forEach((item) => noteIds.push(item.id));+ {hideMore && isTopic ? (+ <Button+ width="20%"+ title="Move"+ onPress={async () => {+ let noteIds = [];+ selectedItemsList.forEach((item) => noteIds.push(item.id));- await db.notes.move(- {- topic: item.title,- id: item.notebookId,- },- ...noteIds,- );- dispatch({type: ACTIONS.CLEAR_SELECTION});+ await db.notes.move(+ {+ topic: item.title,+ id: item.notebookId,+ },+ ...noteIds,+ );+ dispatch({type: ACTIONS.CLEAR_SELECTION});- moveNoteHideEvent();+ moveNoteHideEvent();- ToastEvent.show(`Note moved to ${item.title}`, 'success');- }}- />- ) : null}- </View>+ ToastEvent.show(`Note moved to ${item.title}`, 'success');+ }}+ />+ ) : null}</View>);};diff --git a/apps/mobile/src/components/PressableButton/index.js b/apps/mobile/src/components/PressableButton/index.jsindex 2142be1e3..df1c19956 100644--- a/apps/mobile/src/components/PressableButton/index.js+++ b/apps/mobile/src/components/PressableButton/index.js@@ -11,7 +11,8 @@ export const PressableButton = ({children,onPress,customStyle,alpha=-0.1,- opacity=1+ opacity=1,+ onLongPress}) => {@@ -19,6 +20,7 @@ export const PressableButton = ({<PressableactiveOpacity={opacity}onPress={onPress}+ onLongPress={onLongPress}style={({pressed}) => [{backgroundColor:diff --git a/apps/mobile/src/components/SelectionHeader/index.js b/apps/mobile/src/components/SelectionHeader/index.jsindex c10ed3495..785175573 100644--- a/apps/mobile/src/components/SelectionHeader/index.js+++ b/apps/mobile/src/components/SelectionHeader/index.js@@ -1,19 +1,19 @@-import React, { useState, useEffect } from 'react';-import { Platform, StatusBar, Text, TouchableOpacity, View } from 'react-native';+import React, {useState, useEffect} from 'react';+import {Platform, StatusBar, Text, TouchableOpacity, View} from 'react-native';import * as Animatable from 'react-native-animatable';-import { useSafeAreaInsets } from 'react-native-safe-area-context';+import {useSafeAreaInsets} from 'react-native-safe-area-context';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { SIZE, WEIGHT } from '../../common/common';-import { useTracked } from '../../provider';-import { ACTIONS } from '../../provider/actions';-import { eSendEvent } from '../../services/eventManager';+import {SIZE, WEIGHT} from '../../common/common';+import {useTracked} from '../../provider';+import {ACTIONS} from '../../provider/actions';+import {eSendEvent} from '../../services/eventManager';import {eOpenMoveNoteDialog,-- eOpenPremiumDialog, eOpenSimpleDialog+ eOpenPremiumDialog,+ eOpenSimpleDialog,} from '../../services/events';-import { db, ToastEvent } from '../../utils/utils';-import { TEMPLATE_DELETE } from '../DialogManager/templates';+import {db, ToastEvent} from '../../utils/utils';+import {TEMPLATE_DELETE} from '../DialogManager/templates';import Animated, {useValue, Easing} from 'react-native-reanimated';export const SelectionHeader = () => {@@ -32,14 +32,13 @@ export const SelectionHeader = () => {const translateY = useValue(-150);useEffect(() => {- Animated.timing(translateY,{- duration:300,- toValue:selectionMode? 0 : -150,- easing:Easing.in(Easing.ease)- }).start();- },[selectionMode])+ Animated.timing(translateY, {+ duration: 300,+ toValue: selectionMode ? 0 : -150,+ easing: Easing.in(Easing.ease),+ }).start();+ }, [selectionMode]);-return containerState.noSelectionHeader ? null : (<Animated.Viewstyle={{@@ -127,10 +126,10 @@ export const SelectionHeader = () => {dispatch({type: ACTIONS.CLEAR_SELECTION});eSendEvent(eOpenMoveNoteDialog);}}>- <Icon color={colors.icon} name={'plus'} size={SIZE.xl} />+ <Icon color={colors.heading} name={'plus'} size={SIZE.xl} /></TouchableOpacity>)}- {currentScreen === 'trash' || currentScreen === 'notebooks' ? null : (+ {/* {currentScreen === 'trash' || currentScreen === 'notebooks' ? null : (<TouchableOpacitystyle={{justifyContent: 'center',@@ -168,9 +167,9 @@ export const SelectionHeader = () => {);}}}>- <Icon color={colors.icon} name={'star'} size={SIZE.xl - 3} />+ <Icon color={colors.heading} name={'star'} size={SIZE.xl - 3} /></TouchableOpacity>- )}+ )} */}{currentScreen === 'trash' ? null : (<TouchableOpacity@@ -185,7 +184,7 @@ export const SelectionHeader = () => {eSendEvent(eOpenSimpleDialog, TEMPLATE_DELETE('item'));return;}}>- <Icon color={colors.icon} name={'delete'} size={SIZE.xl - 3} />+ <Icon color={colors.heading} name={'delete'} size={SIZE.xl - 3} /></TouchableOpacity>)}@@ -214,7 +213,7 @@ export const SelectionHeader = () => {}}}><Icon- color={colors.icon}+ color={colors.heading}name="delete-restore"size={SIZE.xl - 3}/>diff --git a/apps/mobile/src/components/SelectionWrapper/index.js b/apps/mobile/src/components/SelectionWrapper/index.jsindex 65bb33f47..d281a03b8 100644--- a/apps/mobile/src/components/SelectionWrapper/index.js+++ b/apps/mobile/src/components/SelectionWrapper/index.js@@ -1,10 +1,11 @@-import React, {useEffect, useState} from 'react';-import {TouchableWithoutFeedback, View} from 'react-native';+import React, { useEffect, useState } from 'react';+import { TouchableOpacity, View } from 'react-native';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import {SIZE} from '../../common/common';-import {useTracked} from '../../provider';-import {ACTIONS} from '../../provider/actions';-import {getElevation} from '../../utils/utils';+import { SIZE } from '../../common/common';+import { useTracked } from '../../provider';+import { ACTIONS } from '../../provider/actions';+import { getElevation } from '../../utils/utils';+import { PressableButton } from '../PressableButton';const SelectionWrapper = ({children,@@ -13,13 +14,15 @@ const SelectionWrapper = ({index,background,pinned,+ onLongPress,+ onPress}) => {const [state, dispatch] = useTracked();const {colors, selectionMode, selectedItemsList} = state;const [selected, setSelected] = useState(false);useEffect(() => {let exists = selectedItemsList.filter(- o => o.dateCreated === item.dateCreated,+ (o) => o.dateCreated === item.dateCreated,);if (exists[0]) {@@ -33,9 +36,25 @@ const SelectionWrapper = ({}}, [selectedItemsList]);+++++return (- <View- style={{+ <PressableButton+ color={currentEditingNote === item.dateCreated || pinned+ ? colors.shade+ : background+ ? background+ : 'transparent'+ }+ onLongPress={onLongPress}+ onPress={onPress}+ selectedColor={currentEditingNote === item.dateCreated || pinned? colors.accent : colors.nav}+ alpha={!colors.night ? -0.02 : 0.02}+ opacity={ currentEditingNote === item.dateCreated || pinned? 0.12 : 1}+ customStyle={{flexDirection: 'row',justifyContent: 'space-between',alignItems: 'center',@@ -47,12 +66,6 @@ const SelectionWrapper = ({: index === 0 && pinned && selectionMode? 30: 0,- backgroundColor:- currentEditingNote === item.dateCreated || pinned- ? colors.shade- : background- ? background- : 'transparent',}}>{pinned ? (<View@@ -63,7 +76,7 @@ const SelectionWrapper = ({backgroundColor: colors.accent,borderRadius: 100,position: 'absolute',- left: 20,+ right: 20,top: -15,justifyContent: 'center',alignItems: 'center',@@ -89,28 +102,30 @@ const SelectionWrapper = ({alignItems: 'center',paddingRight: 8,}}>- <TouchableWithoutFeedback+ <TouchableOpacity+ activeOpacity={1}onPress={() => {dispatch({type: ACTIONS.SELECTED_ITEMS, item: item});}}style={{justifyContent: 'center',alignItems: 'center',+ height: 70,}}><Iconsize={SIZE.lg}- color={colors.accent}+ color={selected ? colors.accent : colors.icon}name={selected? 'check-circle-outline': 'checkbox-blank-circle-outline'}/>- </TouchableWithoutFeedback>+ </TouchableOpacity></View>{children}- </View>+ </PressableButton>);};diff --git a/apps/mobile/src/components/SimpleList/NoteItemWrapper.js b/apps/mobile/src/components/SimpleList/NoteItemWrapper.jsindex 86ac5891b..c28fd853f 100644--- a/apps/mobile/src/components/SimpleList/NoteItemWrapper.js+++ b/apps/mobile/src/components/SimpleList/NoteItemWrapper.js@@ -1,52 +1,77 @@-import React from 'react';+import React, {useMemo} from 'react';import NoteItem from '../../components/NoteItem';import SelectionWrapper from '../../components/SelectionWrapper';-import { useTracked } from '../../provider';-import { ACTIONS } from '../../provider/actions';+import {useTracked} from '../../provider';+import {ACTIONS} from '../../provider/actions';+import {eSendEvent, openVault} from '../../services/eventManager';+import {eShowMergeDialog, eOnLoadNote} from '../../services/events';+import {simpleDialogEvent} from '../DialogManager/recievers';+import {TEMPLATE_TRASH} from '../DialogManager/templates';+import {openEditorAnimation} from '../../utils/animations';--export const NoteItemWrapper = ({item,index,isTrash = false, pinned = false }) => {+export const NoteItemWrapper = ({+ item,+ index,+ isTrash = false,+ pinned = false,+}) => {const [state, dispatch] = useTracked();- const {colors,currentEditingNote,selectionMode} = state;+ const {colors, currentEditingNote, selectionMode} = state;++ 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: item});+ };++ const onPress = async () => {+ if (item.conflicted) {+ eSendEvent(eShowMergeDialog, item);++ return;+ }+ if (selectionMode) {+ onLongPress();+ return;+ } else if (item.locked) {+ openVault(item, true, true, false, true, false);+ return;+ }+ if (DDS.isTab) {+ eSendEvent(eOnLoadNote, item);+ } else if (isTrash) {+ simpleDialogEvent(TEMPLATE_TRASH(item.type));+ } else {+ eSendEvent(eOnLoadNote, item);+ openEditorAnimation();+ }+ };- return <SelectionWrapper+ return (+ <SelectionWrapperindex={index}pinned={pinned}+ onLongPress={onLongPress}+ onPress={onPress}currentEditingNote={currentEditingNote === item.id ? currentEditingNote : null}item={item}><NoteItemcolors={colors}- pinned={pinned}- customStyle={pinned? {- width: selectionMode ? '90%' : '100%',- marginHorizontal: 0,- paddingTop: 10,- paddingRight: 6,- marginBottom: 5,- marginTop: 15,- borderBottomWidth: 0,- } :{- width: selectionMode ? '90%' : '100%',- marginHorizontal: 0,- }}+ customStyle={style}currentEditingNote={currentEditingNote === item.id ? currentEditingNote : null}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}isTrash={isTrash}/></SelectionWrapper>+ );};diff --git a/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js b/apps/mobile/src/components/SimpleList/NotebookItemWrapper.jsindex e719afa27..3d051706a 100644--- a/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js+++ b/apps/mobile/src/components/SimpleList/NotebookItemWrapper.js@@ -1,50 +1,102 @@-import React from 'react';-import { NotebookItem } from '../../components/NotebookItem';+import React, {useMemo} from 'react';+import {NotebookItem} from '../../components/NotebookItem';import SelectionWrapper from '../../components/SelectionWrapper';-import { useTracked } from '../../provider';-import { ACTIONS } from '../../provider/actions';+import {useTracked} from '../../provider';+import {ACTIONS} from '../../provider/actions';+import NavigationService from '../../services/NavigationService';-export const NotebookItemWrapper = ({item, index,isTrash = false, pinned = false}) => {+export const NotebookItemWrapper = ({+ item,+ index,+ isTrash = false,+ pinned = false,+}) => {const [state, dispatch] = useTracked();- const {selectionMode,preventDefaultMargins} = state;- let headerState = preventDefaultMargins? state.indHeaderState : state.headerState;- let params = headerState.route.params? headerState.route.params : {};-+ const {selectionMode, preventDefaultMargins} = state;+ let headerState = preventDefaultMargins+ ? state.indHeaderState+ : state.headerState;+ let params = headerState.route.params ? headerState.route.params : {};++ const style = useMemo(() => {+ return {width: selectionMode ? '90%' : '100%', marginHorizontal: 0};+ }, [selectionMode]);++ const onLongPress = () => {+ if (!selectionMode) {+ dispatch({+ type: ACTIONS.SELECTION_MODE,+ enabled: !selectionMode,+ });+ }++ dispatch({+ type: ACTIONS.SELECTED_ITEMS,+ item: item,+ });+ };++ const onPress = () => {+ if (selectionMode) {+ onLongPress();+ return;+ }+ if (item.type === 'topic') {+ NavigationService.navigate('Notes', {+ ...item,+ });+ } else {+ dispatch({+ type: ACTIONS.HEADER_TEXT_STATE,+ state: {+ heading: preventDefaultMargins ? 'Move to topic' : item.title,+ },+ });+ dispatch({+ type: ACTIONS.HEADER_STATE,+ state: {+ canGoBack: true,+ menu: false,+ },+ });+ dispatch({+ type: ACTIONS.CONTAINER_BOTTOM_BUTTON,+ state: {+ bottomButtonText: 'Add new topic',+ },+ });++ preventDefaultMargins+ ? navigation.navigate('Notebook', {+ notebook: item,+ title: preventDefaultMargins ? 'Move to topic' : item.title,+ isMove: preventDefaultMargins,+ hideMore: preventDefaultMargins,+ root: preventDefaultMargins ? false : true,+ })+ : NavigationService.navigate('Notebook', {+ notebook: item,+ title: preventDefaultMargins ? 'Select a topic' : item.title,+ isMove: preventDefaultMargins,+ hideMore: preventDefaultMargins,+ root: true,+ });+ }+ };return (- <SelectionWrapper pinned={pinned} index={index} item={item}>+ <SelectionWrapper+ onLongPress={onLongPress}+ pinned={pinned}+ index={index}+ onPress={onPress}+ item={item}><NotebookItemhideMore={preventDefaultMargins}navigation={headerState.navigation}route={headerState.route}- pinned={pinned}- customStyle={pinned? {- width: selectionMode ? '90%' : '100%',- marginHorizontal: 0,- paddingTop: 10,- paddingRight: 6,- marginBottom: 5,- marginTop: 15,- borderBottomWidth: 0,- } :{- width: selectionMode ? '90%' : '100%',- marginHorizontal: 0,- }}- isMove={preventDefaultMargins}- selectionMode={selectionMode}- onLongPress={() => {- if (!selectionMode) {- dispatch({- type: ACTIONS.SELECTION_MODE,- enabled: !selectionMode,- });- }-- dispatch({- type: ACTIONS.SELECTED_ITEMS,- item: item,- });- }}+ isTopic={item.type === "topic"}+ customStyle={style}noteToMove={params.note}item={item}index={index}diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.jsindex 4655170a4..e8b9fd513 100644--- a/apps/mobile/src/components/SimpleList/index.js+++ b/apps/mobile/src/components/SimpleList/index.js@@ -6,25 +6,23 @@ import {SectionList,Text,View,- TouchableOpacity,} from 'react-native';+import * as Animatable from 'react-native-animatable';import {useSafeArea} from 'react-native-safe-area-context';-import {SIZE, WEIGHT, opacity, pv} from '../../common/common';+import Icon from 'react-native-vector-icons/MaterialCommunityIcons';+import {SIZE, WEIGHT} from '../../common/common';import {useTracked} from '../../provider';import {ACTIONS} from '../../provider/actions';import {eSendEvent} from '../../services/eventManager';import {eClearSearch,- eScrollEvent,eOpenLoginDialog,+ eScrollEvent,} from '../../services/events';-import {db, ToastEvent, DDS} from '../../utils/utils';-import * as Animatable from 'react-native-animatable';-import {PinnedItemList} from './PinnedItemList';-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import NavigationService from '../../services/NavigationService';-import {Placeholder} from '../ListPlaceholders';-import { PressableButton } from '../PressableButton';+import {db, DDS, ToastEvent} from '../../utils/utils';+import {PressableButton} from '../PressableButton';+import {PinnedItemList} from './PinnedItemList';const sectionListRef = createRef();const AnimatedFlatlist = Animatable.createAnimatableComponent(FlatList);