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
feat: add multi-select
ammarahm-ed0dbd0960aa64
diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.jsindex 36f912869..8aa559e67 100644--- a/apps/mobile/src/components/NoteItem/index.js+++ b/apps/mobile/src/components/NoteItem/index.js@@ -1,4 +1,4 @@-import React, {useState} from 'react';+import React, {useState, useRef} from 'react';import {View,Text,@@ -45,7 +45,7 @@ const NoteItem = props => {const [unlock, setUnlock] = useState(false);const [isPerm, setIsPerm] = useState(false);const item = props.item;-+ let actionSheet;let show = null;let setMenuRef = {};let willRefresh = false;@@ -90,7 +90,7 @@ const NoteItem = props => {alignItems: 'center',flexDirection: 'row',marginHorizontal: 12,- width: w - 24,+ width: props.width,paddingRight: 6,alignSelf: 'center',borderBottomWidth: 1,@@ -149,6 +149,7 @@ const NoteItem = props => {<TouchableOpacityactiveOpacity={1}+ onLongPress={() => props.onLongPress()}onPress={() => {if (item.locked) {setUnlock(true);@@ -215,6 +216,7 @@ const NoteItem = props => {}}>{item.colors.map(item => (<View+ key={item}style={{width: SIZE.xs,height: SIZE.xs,@@ -301,12 +303,13 @@ const NoteItem = props => {alignItems: 'center',}}onPress={() => {- ActionSheet._setModalVisible();+ actionSheet._setModalVisible();}}><Icon name="more-horizontal" size={SIZE.lg} color={colors.icon} /></TouchableOpacity><ActionSheet+ ref={ref => (actionSheet = ref)}customStyles={{backgroundColor: colors.bg,}}@@ -316,29 +319,27 @@ const NoteItem = props => {if (willRefresh) {props.refresh();}- }}- children={- <ActionSheetComponent- item={item}- setWillRefresh={value => {- willRefresh = true;- }}- hasColors={true}- hasTags={true}- overlayColor={- colors.night ? 'rgba(225,225,225,0.1)' : 'rgba(0,0,0,0.3)'+ }}>+ <ActionSheetComponent+ item={props.item}+ setWillRefresh={value => {+ willRefresh = true;+ }}+ hasColors={true}+ hasTags={true}+ overlayColor={+ colors.night ? 'rgba(225,225,225,0.1)' : 'rgba(0,0,0,0.3)'+ }+ rowItems={['Add to', 'Share', 'Export', 'Delete']}+ columnItems={['Add to Vault', 'Pin', 'Favorite']}+ close={value => {+ if (value) {+ show = value;}- rowItems={['Add to', 'Share', 'Export', 'Delete']}- columnItems={['Add to Vault', 'Pin', 'Favorite']}- close={value => {- if (value) {- show = value;- }- ActionSheet._setModalVisible();- }}- />- }- />+ ActionSheet._setModalVisible();+ }}+ />+ </ActionSheet></View></View>);diff --git a/apps/mobile/src/components/NotesList/index.js b/apps/mobile/src/components/NotesList/index.jsindex 25a46cd39..01674092f 100644--- a/apps/mobile/src/components/NotesList/index.js+++ b/apps/mobile/src/components/NotesList/index.js@@ -15,6 +15,7 @@ import {useAppContext} from '../../provider/useAppContext';import Icon from 'react-native-vector-icons/Feather';import {NotesPlaceHolder} from '../ListPlaceholders';import {slideRight, slideLeft} from '../../utils/animations';+import {w} from '../../utils/utils';export const NotesList = ({keyword = null,notes,@@ -26,7 +27,14 @@ export const NotesList = ({emptyPlaceholderText = '',refresh = () => {},}) => {- const {colors} = useAppContext();+ const {+ colors,+ selectionMode,+ selectedItemsList,+ changeSelectionMode,+ updateSelectionList,+ } = useAppContext();+const [numColumns, setNumColumns] = useState(1);const [pinned, setPinned] = useState([]);@@ -98,10 +106,10 @@ export const NotesList = ({style={{marginTop:Platform.OS == 'ios'- ? notes[0]+ ? notes[0] && !selectionMode? 135: 135 - 60- : notes[0]+ : notes[0] && !selectionMode? 155: 155 - 60,}}>@@ -109,24 +117,27 @@ export const NotesList = ({<><FlatListdata={pinned}- renderItem={({item, index}) => (- <NoteItem- customStyle={{- backgroundColor: colors.shade,- width: '100%',- paddingHorizontal: '5%',- paddingTop: 20,- marginBottom: 10,- marginTop: 20,- borderBottomWidth: 0,- }}- pinned={true}- refresh={() => refresh()}- item={item}- numColumns={1}- index={index}- />- )}+ keyExtractor={(item, index) => item.dateCreated.toString()}+ renderItem={({item, index}) =>+ item.type === 'note' ? (+ <NoteItem+ customStyle={{+ backgroundColor: colors.shade,+ width: '100%',+ paddingHorizontal: '5%',+ paddingTop: 20,+ marginBottom: 10,+ marginTop: 20,+ borderBottomWidth: 0,+ }}+ pinned={true}+ refresh={() => refresh()}+ item={item}+ numColumns={1}+ index={index}+ />+ ) : null+ }/></>) : null}@@ -157,12 +168,56 @@ export const NotesList = ({) : null}renderItem={({item, index}) => (- <NoteItem- item={item}- refresh={() => refresh()}- numColumns={numColumns}- index={index}- />+ <View+ style={{+ flexDirection: 'row',+ justifyContent: 'space-between',+ alignItems: 'center',+ width: w - 24,+ marginHorizontal: 12,+ }}>+ <TouchableOpacity+ onPress={() => updateSelectionList(item)}+ style={{+ width: 50,+ height: 70,+ justifyContent: 'center',+ alignItems: 'flex-start',+ display: selectionMode ? 'flex' : 'none',+ }}>+ <View+ style={{+ borderWidth: 2,+ borderColor: selectedItemsList.includes(item)+ ? colors.accent+ : colors.icon,+ width: 30,+ height: 30,+ justifyContent: 'center',+ alignItems: 'center',+ borderRadius: 100,+ paddingTop: 4,+ }}>+ {selectedItemsList.includes(item) ? (+ <Icon size={SIZE.md} color={colors.accent} name="check" />+ ) : null}+ </View>+ </TouchableOpacity>++ <NoteItem+ customStyle={{+ width: selectionMode ? w - 74 : '100%',+ marginHorizontal: 0,+ }}+ onLongPress={() => {+ changeSelectionMode(!selectionMode);+ }}+ item={item}+ refresh={() => refresh()}+ numColumns={numColumns}+ index={index}+ />+ </View>)}/>) : (@@ -226,12 +281,56 @@ export const NotesList = ({</View>}renderItem={({item, index}) => (- <NoteItem- item={item}- refresh={() => refresh()}- numColumns={numColumns}- index={index}- />+ <View+ style={{+ flexDirection: 'row',+ justifyContent: 'space-between',+ alignItems: 'center',+ width: w - 24,+ marginHorizontal: 12,+ }}>+ <TouchableOpacity+ onPress={() => updateSelectionList(item)}+ style={{+ width: 50,+ height: 70,+ justifyContent: 'center',+ alignItems: 'flex-start',+ display: selectionMode ? 'flex' : 'none',+ }}>+ <View+ style={{+ borderWidth: 2,+ borderColor: selectedItemsList.includes(item)+ ? colors.accent+ : colors.icon,+ width: 30,+ height: 30,+ justifyContent: 'center',+ alignItems: 'center',+ borderRadius: 100,+ paddingTop: 4,+ }}>+ {selectedItemsList.includes(item) ? (+ <Icon size={SIZE.md} color={colors.accent} name="check" />+ ) : null}+ </View>+ </TouchableOpacity>++ <NoteItem+ customStyle={{+ width: selectionMode ? w - 74 : '100%',+ marginHorizontal: 0,+ }}+ onLongPress={() => {+ changeSelectionMode(!selectionMode);+ }}+ item={item}+ refresh={() => refresh()}+ numColumns={numColumns}+ index={index}+ />+ </View>)}/>);diff --git a/apps/mobile/src/provider/index.js b/apps/mobile/src/provider/index.jsindex e33a320e9..2549bf0ce 100644--- a/apps/mobile/src/provider/index.js+++ b/apps/mobile/src/provider/index.js@@ -25,6 +25,8 @@ const defaultState = {warningBg: '#FEEFB3',warningText: '#9F6000',},+ selectionMode: false,+ selectedItemsList: [],};const AppContext = createContext([defaultState, function() {}]);diff --git a/apps/mobile/src/provider/useAppContext.js b/apps/mobile/src/provider/useAppContext.jsindex b633b9455..bed0a057d 100644--- a/apps/mobile/src/provider/useAppContext.js+++ b/apps/mobile/src/provider/useAppContext.js@@ -15,6 +15,8 @@ const useAppContext = () => {throw new Error('Must have dispatch defined');}+ // Themeing+async function updateAppTheme(colors = state.colors) {let newColors = await getColorScheme(colors);dispatch(draft => {@@ -37,11 +39,37 @@ const useAppContext = () => {changeColorScheme();}+ // Handling Selection Items++ function changeSelectionMode(enabled) {+ dispatch(draft => {+ draft.selectionMode = enabled;+ if (!enabled) {+ draft.selectedItemsList = [...[]];+ }+ });+ }+ function updateSelectionList(item) {+ let selectedItems = [...state.selectedItemsList];++ if (selectedItems.includes(item)) {+ selectedItems.splice(selectedItems.indexOf(item), 1);+ } else {+ selectedItems.push(item);+ }++ dispatch(draft => {+ draft.selectedItemsList = selectedItems;+ });+ }+return {...state,updateAppTheme,changeColorScheme,changeAccentColor,+ changeSelectionMode,+ updateSelectionList,};};diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.jsindex 89d0b023d..616e356aa 100755--- a/apps/mobile/src/views/Home/index.js+++ b/apps/mobile/src/views/Home/index.js@@ -25,7 +25,15 @@ export const AnimatedSafeAreaView = Animatable.createAnimatableComponent(export const Home = ({navigation}) => {// State- const {colors, updateAppTheme, setMenuOpen} = useAppContext();+ const {+ colors,+ updateAppTheme,+ setMenuOpen,+ selectionMode,+ selectedItemsList,+ changeSelectionMode,+ updateSelectionList,+ } = useAppContext();const [search, setSearch] = useState(false);const [text, setText] = useState('');@@ -35,6 +43,7 @@ export const Home = ({navigation}) => {const [notes, setNotes] = useState([]);const [keyword, setKeyword] = useState('');const isFocused = useIsFocused();+// Variableslet offsetY = 0;let countUp = 1;@@ -137,12 +146,107 @@ export const Home = ({navigation}) => {height: '100%',}}><Animatable.View- transition="backgroundColor"+ transition={['backgroundColor', 'opacity', 'height']}+ duration={300}+ style={{+ width: '100%',+ position: 'absolute',+ height: selectionMode ? 50 : 0,+ opacity: selectionMode ? 1 : 0,+ justifyContent: 'flex-end',+ zIndex: 11,+ }}>+ <View+ style={{+ width: w - 24,+ marginHorizontal: 12,+ height: 50,+ flexDirection: 'row',+ justifyContent: 'space-between',+ alignItems: 'center',+ }}>+ <View+ style={{+ justifyContent: 'space-between',+ flexDirection: 'row',+ alignItems: 'center',+ }}>+ <TouchableOpacity+ onPress={() => {+ changeSelectionMode(false);+ }}+ hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}+ style={{+ justifyContent: 'center',+ alignItems: 'flex-start',+ height: 40,+ width: 50,+ marginTop: 2.5,+ }}>+ <Icon+ style={{+ marginLeft: -5,+ }}+ color={colors.pri}+ name={'chevron-left'}+ size={SIZE.xxxl - 3}+ />+ </TouchableOpacity>+ <Text+ style={{+ fontSize: SIZE.lg,+ fontFamily: WEIGHT.regular,+ color: colors.pri,+ textAlignVertical: 'center',+ }}>+ {selectedItemsList.length}+ </Text>+ </View>++ <View+ style={{+ flexDirection: 'row',+ justifyContent: 'space-between',+ alignItems: 'center',+ }}>+ <Icon+ style={{+ paddingLeft: 25,+ }}+ color={colors.accent}+ name={'plus'}+ size={SIZE.xl}+ />+ <Icon+ style={{+ paddingLeft: 25,+ }}+ color={colors.accent}+ name={'star'}+ size={SIZE.xl - 3}+ />++ <Icon+ style={{+ paddingLeft: 25,+ }}+ color={colors.errorText}+ name={'trash'}+ size={SIZE.xl - 3}+ />+ </View>+ </View>+ </Animatable.View>++ <Animatable.View+ transition={['backgroundColor', 'opacity', 'height']}duration={300}style={{position: 'absolute',- backgroundColor: colors.night ? colors.bg : colors.bg,+ backgroundColor: colors.bg,zIndex: 10,+ height: selectionMode ? 0 : null,+ opacity: selectionMode ? 0 : 1,width: '100%',}}><Header@@ -159,6 +263,7 @@ export const Home = ({navigation}) => {canGoBack={false}customIcon="menu"/>+{notes[0] ? (<Searchclear={() => setText('')}