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
mobile: support pinned editor tabs
Ammar Ahmede91cc2bdca91
diff --git a/apps/mobile/app/components/sheets/editor-tabs/index.tsx b/apps/mobile/app/components/sheets/editor-tabs/index.tsxindex 5a4491ef0..bc9692d4e 100644--- a/apps/mobile/app/components/sheets/editor-tabs/index.tsx+++ b/apps/mobile/app/components/sheets/editor-tabs/index.tsx@@ -20,7 +20,7 @@ import { Note } from "@notesnook/core";import { EVENTS } from "@notesnook/core/dist/common";import { useThemeColors } from "@notesnook/theme";import React, { useEffect } from "react";-import { Platform, View } from "react-native";+import { View } from "react-native";import { FlatList } from "react-native-actions-sheet";import Icon from "react-native-vector-icons/MaterialCommunityIcons";import { db } from "../../../common/database";@@ -43,6 +43,7 @@ type TabItem = {locked?: boolean;noteLocked?: boolean;readonly?: boolean;+ pinned?: boolean;};const TabItemComponent = (props: {@@ -140,24 +141,50 @@ const TabItemComponent = (props: {</Paragraph></View>- <IconButton- name="close"- size={SIZE.lg}- color={colors.primary.icon}- onPress={() => {- const isLastTab = useTabStore.getState().tabs.length === 1;- useTabStore.getState().removeTab(props.tab.id);- // The last tab is not actually removed, it is just cleaned up.- if (isLastTab) {- editorController.current?.reset(props.tab.id, true, true);- props.close?.();- }+ <View+ style={{+ flexDirection: "row",+ gap: 5,+ paddingRight: 12}}- top={0}- left={0}- right={20}- bottom={0}- />+ >+ <IconButton+ name="pin"+ size={SIZE.lg}+ color={props.tab.pinned ? colors.primary.accent : colors.primary.icon}+ onPress={() => {+ useTabStore.getState().updateTab(props.tab.id, {+ pinned: !props.tab.pinned,+ previewTab: false+ });+ }}+ top={0}+ left={0}+ right={20}+ bottom={0}+ />++ {!props.tab?.pinned ? (+ <IconButton+ name="close"+ size={SIZE.lg}+ color={colors.primary.icon}+ onPress={() => {+ const isLastTab = useTabStore.getState().tabs.length === 1;+ useTabStore.getState().removeTab(props.tab.id);+ // The last tab is not actually removed, it is just cleaned up.+ if (isLastTab) {+ editorController.current?.reset(props.tab.id, true, true);+ props.close?.();+ }+ }}+ top={0}+ left={0}+ right={20}+ bottom={0}+ />+ ) : null}+ </View></Pressable>);};@@ -225,7 +252,16 @@ export default function EditorTabs({/></View>- <FlatList windowSize={3} data={tabs} renderItem={renderTabItem} />+ <FlatList+ windowSize={3}+ data={tabs.sort((t1, t2) => {+ if (t1.pinned && t2.pinned) return 0;+ if (t1.pinned) return -1;+ if (t2.pinned) return 1;+ return 0;+ })}+ renderItem={renderTabItem}+ /></View>);}diff --git a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts b/apps/mobile/app/screens/editor/tiptap/use-tab-store.tsindex 1683e01ec..6c3509ec6 100644--- a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts+++ b/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts@@ -76,6 +76,7 @@ export type TabItem = {readonly?: boolean;locked?: boolean;noteLocked?: boolean;+ pinned?: boolean;};const history = new History();diff --git a/packages/editor-mobile/src/hooks/useTabStore.ts b/packages/editor-mobile/src/hooks/useTabStore.tsindex 79b63807a..639b466d9 100644--- a/packages/editor-mobile/src/hooks/useTabStore.ts+++ b/packages/editor-mobile/src/hooks/useTabStore.ts@@ -33,6 +33,7 @@ export type TabItem = {readonly?: boolean;locked?: boolean;noteLocked?: boolean;+ pinned?: boolean;};type NoteState = {