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
update actionsheet ui
ammarahm-ed96e1161f2ec0
diff --git a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.jsindex 31a3ec147..7080d79ac 100644--- a/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js+++ b/apps/mobile/src/components/ActionSheetComponent/ActionSheetColorsSection.js@@ -81,6 +81,7 @@ export const ActionSheetColorsSection = ({item, close}) => {paddingHorizontal: 12,width: '100%',marginVertical: 10,+ marginTop:20,alignItems: 'center',justifyContent: 'space-between',}}>diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.jsindex 9882e9689..b0d6436fb 100644--- a/apps/mobile/src/components/ActionSheetComponent/index.js+++ b/apps/mobile/src/components/ActionSheetComponent/index.js@@ -8,6 +8,7 @@ import {TouchableOpacity,View,} from 'react-native';+import {FlatList} from 'react-native-gesture-handler';import Share from 'react-native-share';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';import {notesnook} from '../../../e2e/test.ids';@@ -133,7 +134,27 @@ export const ActionSheetComponent = ({const rowItemsData = [{- name: 'Add to',+ name: 'Dark Mode',+ title: 'Dark mode',+ icon: 'theme-light-dark',+ func: () => {+ if (!colors.night) {+ MMKV.setStringAsync('theme', JSON.stringify({night: true}));+ changeColorScheme(COLOR_SCHEME_DARK);+ } else {+ MMKV.setStringAsync('theme', JSON.stringify({night: false}));+ changeColorScheme(COLOR_SCHEME_LIGHT);+ }+ },+ switch: true,+ on: colors.night ? true : false,+ close: false,+ nopremium: true,+ id: notesnook.ids.dialogs.actionsheet.night,+ },+ {+ name: 'Add to notebook',+ title: 'Add to notebook',icon: 'book-outline',func: () => {close();@@ -145,39 +166,71 @@ export const ActionSheetComponent = ({},},{- name: 'Share',- icon: 'share-variant',+ name: 'Pin',+ title: note.pinned ? 'Unpin from top' : 'Pin to top',+ icon: note.pinned ? 'pin-off-outline' : 'pin-outline',func: async () => {- if (note.locked) {- close();- openVault({- item: item,- novault: true,- locked: true,- share: true,- title: 'Share note',- description: 'Unlock note to share it.',- });+ if (!note.id) return;+ close();+ if (note.type === 'note') {+ if (db.notes.pinned.length === 3 && !note.pinned) {+ ToastEvent.show({+ heading: 'Cannot pin more than 3 notes',+ type: 'error',+ context: 'local',+ });+ return;+ }+ await db.notes.note(note.id).pin();} else {- let text = await db.notes.note(note.id).export('txt');- let m = `${note.title}\n \n ${text}`;- Share.open({- title: 'Share note to',- failOnCancel: false,- message: m,- });+ if (db.notebooks.pinned.length === 3 && !note.pinned) {+ ToastEvent.show({+ heading: 'Cannot pin more than 3 notebooks',+ type: 'error',+ context: 'local',+ });+ return;+ }+ await db.notebooks.notebook(note.id).pin();}+ localRefresh(item.type);},+ close: false,+ check: true,+ on: note.pinned,+ nopremium: true,+ id: notesnook.ids.dialogs.actionsheet.pin,},{- name: 'Export',- icon: 'export',- func: () => {- close('export');+ name: 'Favorite',+ title: !note.favorite ? 'Add to favorites' : 'Remove from favorites',+ icon: note.favorite ? 'star-off' : 'star-outline',+ func: async () => {+ if (!note.id) return;+ close();+ if (note.type === 'note') {+ await db.notes.note(note.id).favorite();+ } else {+ await db.notebooks.notebook(note.id).favorite();+ }+ Navigation.setRoutesToUpdate([+ Navigation.routeNames.NotesPage,+ Navigation.routeNames.Favorites,+ Navigation.routeNames.Notes,+ ]);+ localRefresh(item.type, true);},+ close: false,+ check: true,+ on: note.favorite,+ nopremium: true,+ id: notesnook.ids.dialogs.actionsheet.favorite,+ color: 'orange',},+{name: 'Edit Notebook',+ title: 'Edit notebook',icon: 'square-edit-outline',func: () => {close('notebook');@@ -185,41 +238,15 @@ export const ActionSheetComponent = ({},{name: 'Edit Topic',+ title: 'Edit topic',icon: 'square-edit-outline',func: () => {close('topic');},},- {- name: 'Delete',- title:- note.type !== 'notebook' && note.type !== 'note'- ? 'Delete ' + item.type- : 'Move to trash',- icon: 'delete-outline',- type: 'error',- func: async () => {- close();- if (note.locked) {- await sleep(300);- openVault({- deleteNote: true,- novault: true,- locked: true,- item: note,- title: 'Delete note',- description: 'Unlock note to delete it.',- });- } else {- try {- close();- await deleteItems(note);- } catch (e) {}- }- },- },{name: 'Copy',+ title: 'Copy',icon: 'content-copy',func: async () => {if (note.locked) {@@ -269,33 +296,10 @@ export const ActionSheetComponent = ({});},},- {- name: 'Delete',- icon: 'delete',- func: async () => {- close();- await sleep(300);- presentDialog({- title: `Permanent delete`,- paragraph: `Are you sure you want to delete this ${note.itemType} permanantly from trash?`,- positiveText: 'Delete',- negativeText: 'Cancel',- positivePress: async () => {- await db.trash.delete(note.id);- useTrashStore.getState().setTrash();- useSelectionStore.getState().setSelectionMode(false);- ToastEvent.show({- heading: 'Permanantly deleted items',- type: 'success',- context: 'local',- });- },- positiveType: 'errorShade',- });- },- },+{name: 'Publish',+ title: 'Publish',icon: 'cloud-upload-outline',func: async () => {if (!user) {@@ -332,27 +336,6 @@ export const ActionSheetComponent = ({eSendEvent(eOpenPublishNoteDialog, note);},},- ];-- const columnItemsData = [- {- name: 'Dark Mode',- icon: 'theme-light-dark',- func: () => {- if (!colors.night) {- MMKV.setStringAsync('theme', JSON.stringify({night: true}));- changeColorScheme(COLOR_SCHEME_DARK);- } else {- MMKV.setStringAsync('theme', JSON.stringify({night: false}));- changeColorScheme(COLOR_SCHEME_LIGHT);- }- },- switch: true,- on: colors.night ? true : false,- close: false,- nopremium: true,- id: notesnook.ids.dialogs.actionsheet.night,- },{name: 'Vault',title: note.locked ? 'Remove from vault' : 'Add to vault',@@ -393,71 +376,10 @@ export const ActionSheetComponent = ({},on: note.locked,},+{- name: 'Pin',- title: note.pinned ? 'Unpin from top' : 'Pin to top',- icon: note.pinned ? 'pin-off-outline' : 'pin-outline',- func: async () => {- if (!note.id) return;- close();- if (note.type === 'note') {- if (db.notes.pinned.length === 3 && !note.pinned) {- ToastEvent.show({- heading: 'Cannot pin more than 3 notes',- type: 'error',- context: 'local',- });- return;- }- await db.notes.note(note.id).pin();- } else {- if (db.notebooks.pinned.length === 3 && !note.pinned) {- ToastEvent.show({- heading: 'Cannot pin more than 3 notebooks',- type: 'error',- context: 'local',- });- return;- }- await db.notebooks.notebook(note.id).pin();- }- localRefresh(item.type);- },- close: false,- check: true,- on: note.pinned,- nopremium: true,- id: notesnook.ids.dialogs.actionsheet.pin,- },- {- name: 'Favorite',- title: !note.favorite ? 'Add to favorites' : 'Remove from favorites',- icon: note.favorite ? 'star-off' : 'star-outline',- func: async () => {- if (!note.id) return;- close();- if (note.type === 'note') {- await db.notes.note(note.id).favorite();- } else {- await db.notebooks.notebook(note.id).favorite();- }- Navigation.setRoutesToUpdate([- Navigation.routeNames.NotesPage,- Navigation.routeNames.Favorites,- Navigation.routeNames.Notes,- ]);- localRefresh(item.type, true);- },- close: false,- check: true,- on: note.favorite,- nopremium: true,- id: notesnook.ids.dialogs.actionsheet.favorite,- color: 'orange',- },- {- name: 'Add Shortcut to Menu',- title: isPinnedToMenu ? 'Remove Shortcut' : 'Add Shortcut to Menu',+ name: 'Add Shortcut',+ title: isPinnedToMenu ? 'Remove Shortcut' : 'Add Shortcut',icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant',func: async () => {close();@@ -484,6 +406,40 @@ export const ActionSheetComponent = ({nopremium: true,id: notesnook.ids.dialogs.actionsheet.pinMenu,},+ {+ name: 'Share',+ title: 'Share',+ icon: 'share-variant',+ func: async () => {+ if (note.locked) {+ close();+ openVault({+ item: item,+ novault: true,+ locked: true,+ share: true,+ title: 'Share note',+ description: 'Unlock note to share it.',+ });+ } else {+ let text = await db.notes.note(note.id).export('txt');+ let m = `${note.title}\n \n ${text}`;+ Share.open({+ title: 'Share note to',+ failOnCancel: false,+ message: m,+ });+ }+ },+ },+ {+ name: 'Export',+ title: 'Export',+ icon: 'export',+ func: () => {+ close('export');+ },+ },{name: 'RemoveTopic',title: 'Remove from topic',@@ -532,18 +488,35 @@ export const ActionSheetComponent = ({}},},+ {+ name: 'PermDelete',+ icon: 'delete',+ func: async () => {+ close();+ await sleep(300);+ presentDialog({+ title: `Permanent delete`,+ paragraph: `Are you sure you want to delete this ${note.itemType} permanantly from trash?`,+ positiveText: 'Delete',+ negativeText: 'Cancel',+ positivePress: async () => {+ await db.trash.delete(note.id);+ useTrashStore.getState().setTrash();+ useSelectionStore.getState().setSelectionMode(false);+ ToastEvent.show({+ heading: 'Permanantly deleted items',+ type: 'success',+ context: 'local',+ });+ },+ positiveType: 'errorShade',+ });+ },+ },];- const isFullWidthButton = index => {- let filtered = columnItemsData.filter(- i => columnItems.indexOf(i.name) > -1 && !i.hidden,- );- let colLength = filtered.length;-- if (colLength % 2 === 0) return false;- if (index === colLength - 1) return true;- };-+ const columnItemsData = [];+ let columnsCount = rowItems.length < 5 ? rowItems.length : 5;const _renderRowItem = rowItem => (<TouchableOpacityonPress={rowItem.func}@@ -553,17 +526,20 @@ export const ActionSheetComponent = ({alignItems: 'center',width: DDS.isTab? (400 - 24) / rowItems.length- : (w - 25) / rowItems.length,+ : (w - 24) / columnsCount,+ marginBottom: 5,}}><Viewstyle={{- height: 40,- borderRadius: 100,+ height: 50,+ width: 50,+ borderRadius: 5,justifyContent: 'center',alignItems: 'center',textAlign: 'center',textAlignVertical: 'center',marginBottom: DDS.isTab ? 7 : 3.5,+ backgroundColor: colors.nav,}}><Iconname={rowItem.icon}@@ -572,26 +548,12 @@ export const ActionSheetComponent = ({/></View>- <Paragraph>{rowItem.name}</Paragraph>+ <Paragraph size={SIZE.sm} style={{textAlign: 'center'}}>+ {rowItem.title}+ </Paragraph></TouchableOpacity>);- const _renderColumnItem = (item, index) =>- item.hidden ? null : (- <Button- key={item.title}- title={item.title}- type={item.type ? item.type : item.on ? 'accent' : 'grayBg'}- onPress={item.func}- style={{- marginTop: 12,- }}- width={isFullWidthButton(index) ? '100%' : '48%'}- icon={item.icon}- height={50}- />- );-const onScrollEnd = () => {getRef().current?.handleChildScrollEnd();};@@ -688,49 +650,6 @@ export const ActionSheetComponent = ({: null}</Paragraph>- {note.type === 'notebook' && (- <View- style={{- flexDirection: 'row',- alignItems: 'center',- justifyContent: 'center',- width: '90%',- maxWidth: '90%',- flexWrap: 'wrap',- }}>- {note && note.topics && note.topics.length > 0- ? note.topics- .slice()- .sort((a, b) => a.dateEdited - b.dateEdited)- .slice(0, 6)- .map(topic => (- <View- key={topic.id}- style={{- borderRadius: 2.5,- backgroundColor: colors.accent,- paddingHorizontal: 5,- paddingVertical: 2,- marginRight: 5,- marginVertical: 2.5,- }}>- <Paragraph- size={SIZE.xs}- numberOfLines={1}- color="white"- style={{- maxWidth: '100%',- }}>- {topic.title.length > 16- ? topic.title.slice(0, 16) + '...'- : topic.title}- </Paragraph>- </View>- ))- : null}- </View>- )}-{hasTags && note ? (<ActionSheetTagsSectionclose={close}@@ -743,7 +662,47 @@ export const ActionSheetComponent = ({style={{flexDirection: 'row',marginTop: 5,+ width: '90%',+ maxWidth: '90%',+ flexWrap: 'wrap',+ justifyContent: 'center',}}>+ {note.type === 'notebook' &&+ note &&+ note.topics &&+ note.topics.length > 0+ ? note.topics+ .sort((a, b) => a.dateEdited - b.dateEdited)+ .slice(0, 6)+ .map(topic => (+ <Button+ key={topic.id}+ title={topic.title}+ type="accent"+ height={30}+ onPress={() => {+ close();+ let routeName = 'NotesPage';+ let params = {...topic, menu: false, get: 'topics'};+ let headerState = {+ heading: topic.title,+ id: topic.id,+ type: topic.type,+ };+ Navigation.navigate(routeName, params, headerState);+ }}+ fontSize={SIZE.sm - 1}+ style={{+ marginRight: 5,+ paddingHorizontal: 0,+ borderRadius: 100,+ paddingHorizontal: 12,+ marginTop: 5,+ }}+ />+ ))+ : null}+{note.type === 'note' && isPublished && (<Buttontitle="Published"@@ -804,39 +763,28 @@ export const ActionSheetComponent = ({</View>)}- {note.id || note.dateCreated ? (- <View- style={{- width: '100%',- justifyContent: 'space-between',- alignItems: 'center',- paddingVertical: 10,- flexDirection: 'row',- paddingHorizontal: 12,- }}>- {rowItemsData- .filter(i => rowItems.indexOf(i.name) > -1)- .map(_renderRowItem)}- </View>- ) : null}-{hasColors && note.id ? (<ActionSheetColorsSection close={close} item={note} />) : null}- {note.id && columnItems.length > 0 ? (- <View+ {note.id || note.dateCreated ? (+ <FlatList+ data={rowItemsData.filter(+ i => rowItems.indexOf(i.name) > -1 && !i.hidden,+ )}+ keyExtractor={(item) => item.title}+ numColumns={rowItems.length < 5 ? rowItems.length : 5}style={{- paddingHorizontal: 12,- flexDirection: 'row',- justifyContent: 'space-between',- flexWrap: 'wrap',- marginTop: 6,- }}>- {columnItemsData- .filter(i => columnItems.indexOf(i.name) > -1 && !i.hidden)- .map(_renderColumnItem)}- </View>+ marginTop: note.type !== 'note' ? 10 : 0,+ }}+ columnWrapperStyle={{+ justifyContent: 'flex-start',+ }}+ contentContainerStyle={{+ alignSelf: 'center',+ }}+ renderItem={({item, index}) => _renderRowItem(item)}+ />) : null}{note.type === 'note' && user && lastSynced >= note.dateEdited ? (diff --git a/apps/mobile/src/components/NoteItem/index.js b/apps/mobile/src/components/NoteItem/index.jsindex 52dfd0ea8..f87a515be 100644--- a/apps/mobile/src/components/NoteItem/index.js+++ b/apps/mobile/src/components/NoteItem/index.js@@ -23,7 +23,7 @@ const NoteItem = ({item, isTrash}) => {isTrash ? false : true,isTrash? ['Remove', 'Restore']- : ['Add to', 'Share', 'Export','Copy','Publish'],+ : ['Add to notebook', 'Share', 'Export','Copy','Publish','Pin', 'Favorite', 'Vault','Delete','RemoveTopic'],isTrash ? [] : ['Pin', 'Favorite', 'Vault','Delete','RemoveTopic'],);};diff --git a/apps/mobile/src/components/NotebookItem/index.js b/apps/mobile/src/components/NotebookItem/index.jsindex 3538b0f6f..7fbb4ae9e 100644--- a/apps/mobile/src/components/NotebookItem/index.js+++ b/apps/mobile/src/components/NotebookItem/index.js@@ -19,13 +19,13 @@ export const NotebookItem = ({item, isTopic = false, notebookID, isTrash}) => {const showActionSheet = () => {let rowItems = isTrash? ['Restore', 'Remove']- : [item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook'];+ : [item.type == 'topic' ? 'Edit Topic' : 'Edit Notebook','Pin', 'Add Shortcut','Delete'];let columnItems = isTrash? []: item.type === 'topic'- ? ['Add Shortcut to Menu', 'Delete']- : ['Pin', 'Add Shortcut to Menu','Delete'];+ ? ['Add Shortcut', 'Delete']+ : ['Pin', 'Add Shortcut','Delete'];ActionSheetEvent(item, false, false, rowItems, columnItems, {notebookID: notebookID,diff --git a/apps/mobile/src/components/SimpleList/announcement.js b/apps/mobile/src/components/SimpleList/announcement.jsindex 630afccc2..4f4ccd416 100644--- a/apps/mobile/src/components/SimpleList/announcement.js+++ b/apps/mobile/src/components/SimpleList/announcement.js@@ -22,7 +22,6 @@ export const Announcement = () => {const remove = useMessageStore(state => state.remove);let announcement = announcements.length > 0 ? announcements[0] : null;const selectionMode = useSelectionStore(state => state.selectionMode);-return !announcement || selectionMode ? null : (<View