From ad6a0ebfabb3dcea1a5273c5125ac24b66e26e39 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> Date: Mon, 5 Jun 2023 11:16:18 +0500 Subject: [PATCH 1/3] mobie: enable search in readonly mode (#2659) --- apps/mobile/app/screens/editor/index.tsx | 7 +++++-- apps/mobile/app/screens/editor/tiptap/commands.ts | 4 ++-- packages/editor-mobile/src/components/editor.tsx | 9 +++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsx index 36c02f99c..53f42cab4 100755 --- a/apps/mobile/app/screens/editor/index.tsx +++ b/apps/mobile/app/screens/editor/index.tsx @@ -46,6 +46,7 @@ import { useEditor } from "./tiptap/use-editor"; import { useEditorEvents } from "./tiptap/use-editor-events"; import { editorController } from "./tiptap/utils"; import { useLayoutEffect } from "react"; +import useKeyboard from "../../hooks/use-keyboard"; const style: ViewStyle = { height: "100%", @@ -232,6 +233,8 @@ const AppSection = ({ const ReadonlyButton = ({ editor }: { editor: useEditorType }) => { const readonly = useEditorStore((state) => state.readonly); + const keyboard = useKeyboard(); + const onPress = async () => { if (editor.note.current) { await db.notes?.note(editor.note.current.id).readonly(); @@ -241,7 +244,7 @@ const ReadonlyButton = ({ editor }: { editor: useEditorType }) => { } }; - return readonly && IconButton ? ( + return readonly && IconButton && !keyboard.keyboardShown ? ( { color="accent" customStyle={{ position: "absolute", - bottom: 20, + bottom: 60, width: 60, height: 60, right: 12, diff --git a/apps/mobile/app/screens/editor/tiptap/commands.ts b/apps/mobile/app/screens/editor/tiptap/commands.ts index 48871c900..2107b516b 100644 --- a/apps/mobile/app/screens/editor/tiptap/commands.ts +++ b/apps/mobile/app/screens/editor/tiptap/commands.ts @@ -217,7 +217,7 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa ); }; - updateWebclip = async ({ src, hash }: ImageAttributes) => { + updateWebclip = async ({ src, hash }: Partial) => { await this.doAsync( `editor && editor.commands.updateWebClip(${JSON.stringify({ hash @@ -225,7 +225,7 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa ); }; - updateImage = async ({ src, hash }: ImageAttributes) => { + updateImage = async ({ src, hash }: Partial) => { await this.doAsync( `editor && editor.commands.updateImage(${JSON.stringify({ hash diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx index 08276cdca..ae6141dc1 100644 --- a/packages/editor-mobile/src/components/editor.tsx +++ b/packages/editor-mobile/src/components/editor.tsx @@ -251,9 +251,14 @@ const Tiptap = ({ /> - {settings.noToolbar || !layout ? null : ( + {!layout ? null : ( Date: Wed, 31 May 2023 18:35:20 +0500 Subject: [PATCH 2/3] desktop: fix start as minimized on windows --- apps/web/desktop/autolaunch.ts | 6 +++- apps/web/desktop/cli.ts | 8 +++-- apps/web/desktop/electron.js | 30 ++++++++++++------- .../ipc/actions/setDesktopIntegration.js | 7 +++++ apps/web/desktop/tray.ts | 4 +++ 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/apps/web/desktop/autolaunch.ts b/apps/web/desktop/autolaunch.ts index de858fb13..e68ab5d22 100644 --- a/apps/web/desktop/autolaunch.ts +++ b/apps/web/desktop/autolaunch.ts @@ -47,7 +47,11 @@ export class AutoLaunch { LINUX_DESKTOP_ENTRY(hidden) ); } else { - app.setLoginItemSettings({ openAtLogin: true, openAsHidden: hidden }); + app.setLoginItemSettings({ + openAtLogin: true, + openAsHidden: hidden, + args: ["--hidden"] + }); } } diff --git a/apps/web/desktop/cli.ts b/apps/web/desktop/cli.ts index 1498feb3f..9848d0d16 100644 --- a/apps/web/desktop/cli.ts +++ b/apps/web/desktop/cli.ts @@ -24,15 +24,18 @@ export type CLIOptions = { note?: boolean | string; notebook?: boolean | string; reminder?: boolean | string; + hidden?: boolean; }; export async function parseArguments(): Promise { const result: CLIOptions = { note: false, notebook: false, - reminder: false + reminder: false, + hidden: false }; - await yargs(hideBin(process.argv)) + const { hidden } = await yargs(hideBin(process.argv)) + .boolean("hidden") .command("new", "Create a new item", (yargs) => { return yargs .command("note", "Create a new note", {}, () => { @@ -76,5 +79,6 @@ export async function parseArguments(): Promise { ); }) .parse(); + result.hidden = hidden; return result; } diff --git a/apps/web/desktop/electron.js b/apps/web/desktop/electron.js index 8cc221b2e..7ec22070f 100644 --- a/apps/web/desktop/electron.js +++ b/apps/web/desktop/electron.js @@ -64,6 +64,7 @@ async function createWindow() { setTheme(getTheme()); const mainWindow = new BrowserWindow({ + show: false, x: mainWindowState.x, y: mainWindowState.y, width: mainWindowState.width, @@ -87,11 +88,17 @@ async function createWindow() { } }); + mainWindow.on("show", () => { + if (getPrivacyMode()) { + setPrivacyMode({ privacyMode: getPrivacyMode() }); + } + }); + mainWindowState.manage(mainWindow); globalThis.window = mainWindow; setupMenu(); setupJumplist(); - setupDesktopIntegration(); + setupDesktopIntegration(cliOptions.hidden); mainWindow.webContents.session.setSpellCheckerDictionaryDownloadURL( "http://dictionaries.notesnook.com/" @@ -100,10 +107,6 @@ async function createWindow() { if (isDevelopment()) mainWindow.webContents.openDevTools({ mode: "right", activate: true }); - if (getPrivacyMode()) { - setPrivacyMode({ privacyMode: getPrivacyMode() }); - } - try { await mainWindow.loadURL(`${createURL(cliOptions)}`); } catch (e) { @@ -169,7 +172,7 @@ function createURL(options) { return url; } -function setupDesktopIntegration() { +function setupDesktopIntegration(hidden) { const desktopIntegration = getDesktopIntegration(); if ( @@ -179,6 +182,17 @@ function setupDesktopIntegration() { setupTray(); } + globalThis.window.on("ready-to-show", () => { + if (!hidden) { + globalThis.window.show(); + } + + if (hidden && !desktopIntegration.minimizeToSystemTray) { + globalThis.window.show(); + globalThis.window.minimize(); + } + }); + // when close to system tray is enabled, it becomes nigh impossible // to "quit" the app. This is necessary in order to fix that. if (desktopIntegration.closeToSystemTray) { @@ -212,9 +226,5 @@ function setupDesktopIntegration() { if (desktopIntegration.autoStart) { AutoLaunch.enable(desktopIntegration.startMinimized); - - if (process.platform === "win32" && desktopIntegration.startMinimized) { - globalThis.window.minimize(); - } } } diff --git a/apps/web/desktop/ipc/actions/setDesktopIntegration.js b/apps/web/desktop/ipc/actions/setDesktopIntegration.js index e38162921..7d7a7343a 100644 --- a/apps/web/desktop/ipc/actions/setDesktopIntegration.js +++ b/apps/web/desktop/ipc/actions/setDesktopIntegration.js @@ -19,6 +19,7 @@ along with this program. If not, see . import { AutoLaunch } from "../../autolaunch"; import { setDesktopIntegration } from "../../config/desktopIntegration"; +import { destroyTray, setupTray } from "../../tray"; export default (args) => { if (!globalThis.window) return; @@ -29,5 +30,11 @@ export default (args) => { AutoLaunch.disable(); } + if (args.closeToSystemTray || args.minimizeToSystemTray) { + setupTray(); + } else { + destroyTray(); + } + setDesktopIntegration(args); }; diff --git a/apps/web/desktop/tray.ts b/apps/web/desktop/tray.ts index ea5f7b228..257c98f58 100644 --- a/apps/web/desktop/tray.ts +++ b/apps/web/desktop/tray.ts @@ -25,6 +25,10 @@ import { sendMessageToRenderer } from "./ipc/utils"; import { isFlatpak } from "./utils"; let tray: Tray | undefined = undefined; +export function destroyTray() { + if (tray) tray.destroy(); +} + export function setupTray() { if (tray) tray.destroy(); From 25bf4fee82af89c243bfe3134598a595ed09d0a5 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com> Date: Mon, 5 Jun 2023 15:13:19 +0500 Subject: [PATCH 3/3] mobile: redesign onboarding (#2633) --- apps/mobile/app/components/auth/auth-modal.js | 4 +- apps/mobile/app/components/auth/login.js | 143 +++++---- apps/mobile/app/components/auth/signup.js | 176 ++++++----- apps/mobile/app/components/intro/index.js | 259 +++++++++------- apps/mobile/app/components/launcher/index.js | 45 +-- .../components/premium/compact-features.js | 11 +- apps/mobile/app/components/premium/feature.js | 9 +- .../app/components/premium/pricing-plans.js | 6 +- .../app/components/sheet-provider/index.js | 5 +- .../components/sheets/add-notebook/index.js | 1 - .../app/components/sheets/reminder/index.tsx | 1 - .../components/sheets/topic-sheet/index.tsx | 1 - apps/mobile/app/components/tabs/index.tsx | 1 + apps/mobile/app/components/ui/input/index.tsx | 2 +- apps/mobile/app/components/ui/sheet/index.js | 3 + .../app/components/ui/typography/heading.tsx | 19 +- .../mobile/app/navigation/navigation-stack.js | 8 +- apps/mobile/app/navigation/tabs-holder.js | 118 ++++---- apps/mobile/app/package.json | 3 +- apps/mobile/app/screens/settings/app-lock.js | 279 ++++++++++-------- apps/mobile/app/services/premium.js | 5 +- apps/mobile/native/ios/Make Note/Info.plist | 1 + .../ios/Notesnook.xcodeproj/project.pbxproj | 6 + apps/mobile/native/package.json | 4 +- apps/mobile/package-lock.json | 12 +- apps/mobile/package.json | 1 + 26 files changed, 623 insertions(+), 500 deletions(-) diff --git a/apps/mobile/app/components/auth/auth-modal.js b/apps/mobile/app/components/auth/auth-modal.js index 2da011237..459aa36c7 100644 --- a/apps/mobile/app/components/auth/auth-modal.js +++ b/apps/mobile/app/components/auth/auth-modal.js @@ -126,11 +126,11 @@ const AuthModal = () => { {initialAuthMode.current !== AuthMode.welcomeSignup ? null : (