Compare commits

..

15 Commits

Author SHA1 Message Date
ammarahm-ed
67a732360b ci: undo workflow changes 2023-06-26 21:43:16 +05:00
ammarahm-ed
e3d75a0696 ci: update workflow 2023-06-26 20:39:48 +05:00
ammarahm-ed
25d0b136e2 mobile: fix 2023-06-26 17:52:19 +05:00
ammarahm-ed
27b3a50ba8 mobile: fix ui 2023-06-26 16:23:44 +05:00
ammarahm-ed
ba0676c9d2 mobile: ensure editor is ready before note loading 2023-06-26 15:05:27 +05:00
ammarahm-ed
e13f49eeba mobile: add logs on upload 2023-06-26 14:19:01 +05:00
ammarahm-ed
fb18b0dcba mobile: increase delay 2023-06-26 13:50:20 +05:00
ammarahm-ed
7ea182eb5b mobile: cleanup 2023-06-26 13:12:11 +05:00
ammarahm-ed
1b165af118 mobile: update patch files 2023-06-26 13:07:37 +05:00
ammarahm-ed
335c63f769 mobile: fix bootsplash logo in dark mode 2023-06-26 12:39:18 +05:00
ammarahm-ed
cb5a9fc358 mobile: fix editor stuck in loading state 2023-06-24 14:38:43 +05:00
ammarahm-ed
bc78ee7a89 mobile: fix release build on android 2023-06-23 17:11:52 +05:00
Ammar Ahmed
24f17af268 Merge branch 'master' into chore/update-react-native-71
Signed-off-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com>
2023-06-23 12:11:47 +05:00
ammarahm-ed
46bf118d62 mobile: update to react-native 0.72.0 2023-06-23 11:57:20 +05:00
ammarahm-ed
f1d64c2ff7 mobile: upgrade to react-native 0.71 2023-06-21 18:07:16 +05:00
1121 changed files with 99592 additions and 103277 deletions

View File

@@ -14,16 +14,13 @@ const SCOPES = [
"mobile",
"web",
"vericrypt",
"desktop",
"crypto",
"editor",
"logger",
"theme",
"server",
"core",
"fs",
"ui",
"clipper",
"config",
"ci",
@@ -33,8 +30,7 @@ const SCOPES = [
"misc",
"common",
"global",
"docs",
"themebuilder"
"docs"
];
module.exports = {

1
.gitattributes vendored
View File

@@ -1 +0,0 @@
* text=auto eol=lf

View File

@@ -1,5 +1,5 @@
name: "Setup node with cache action"
description: "Setups node with cache"
name: 'Setup node with cache action'
description: 'Setups node with cache'
runs:
using: "composite"
@@ -19,8 +19,9 @@ runs:
packages/crypto/package-lock.json
packages/sodium/package-lock.json
packages/clipper/package-lock.json
packages/crypto-worker/package-lock.json
packages/editor-mobile/package-lock.json
packages/editor/package-lock.json
packages/logger/package-lock.json
packages/streamable-fs/package-lock.json
packages/theme/package-lock.json
packages/theme/package-lock.json

4
.github/dco.yml vendored Normal file
View File

@@ -0,0 +1,4 @@
allowRemediationCommits:
individual: true
require:
members: false

View File

@@ -17,14 +17,12 @@ jobs:
- name: Use specific Java version for the builds
uses: joschi/setup-jdk@v2
with:
java-version: "11"
architecture: "x64"
java-version: '11'
architecture: 'x64'
- name: Install node modules
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=mobile
npm ci
- name: Make Gradlew Executable
run: cd apps/mobile/native/android && chmod +x ./gradlew
@@ -39,7 +37,7 @@ jobs:
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
- name: Publish to Playstore
id: deploy
@@ -50,4 +48,4 @@ jobs:
releaseFile: ${{steps.sign_app.outputs.signedReleaseFile}}
track: internal
status: completed
whatsNewDirectory: apps/mobile/native/android/releasenotes/
whatsNewDirectory: apps/mobile/native/android/releasenotes/

View File

@@ -22,9 +22,7 @@ jobs:
- name: Install node modules
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=mobile
npm ci
- name: Make Gradlew Executable
run: cd apps/mobile/native/android && chmod +x ./gradlew

View File

@@ -8,7 +8,7 @@ on:
paths:
- "packages/core/**"
# re-run workflow if workflow file changes
- ".github/workflows/core.tests.yml"
- ".github/workflows/core.tests.yml"
pull_request:
types:
- "ready_for_review"
@@ -28,8 +28,7 @@ jobs:
- name: Prepare environment
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=core
npm ci --prefer-offline --no-audit
- name: Add environment variables
run: |
echo "USER_EMAIL=${{ secrets.USER_EMAIL }}" >> $GITHUB_ENV

View File

@@ -32,8 +32,8 @@ jobs:
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=web
npm i --ignore-scripts --prefer-offline --no-audit
npx lerna bootstrap --ignore=@notesnook/mobile -- --prefer-offline --no-audit
- name: Setup environment
run: |
@@ -93,7 +93,7 @@ jobs:
echo ::set-output name=app_bundle_id::$(cat package.json | jq -r .build.appId)
echo ::set-output name=app_version::$(cat package.json | jq -r .version)
echo ::set-output name=bundle_version::$(cat package.json | jq -r .build.mac.bundleVersion)
- name: Get App Store Version
id: appstore
uses: streetwriters/appstore-connect-app-version@develop
@@ -108,13 +108,13 @@ jobs:
uses: actions/download-artifact@v3
with:
name: build
path: ./apps/web/build
path: ./apps/desktop/build
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=desktop
npm i --ignore-scripts --prefer-offline --no-audit
npx lerna bootstrap --ignore=@notesnook/mobile -- --prefer-offline --no-audit
- name: Install provisioning profile
run: echo "${{ secrets.MAC_PROVISIONING_PROFILE }}" | base64 --decode > embedded.provisionprofile
working-directory: ./apps/desktop
@@ -151,7 +151,7 @@ jobs:
env:
API_KEY_ID: ${{ secrets.api_key_id }}
API_KEY_ISSUER_ID: ${{ secrets.api_key_issuer_id }}
run: |
run: |
package=$(find ./output/mas-universal/notesnook*.pkg)
echo "Uploading ${package} using altool..."
@@ -183,12 +183,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: build
path: ./apps/web/build
path: ./apps/desktop/build
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=desktop
npm i --ignore-scripts --prefer-offline --no-audit
npx lerna bootstrap --ignore=@notesnook/mobile -- --prefer-offline --no-audit
- name: Build Electron wrapper
run: npx nx run release --project @notesnook/desktop
@@ -233,12 +233,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: build
path: ./apps/web/build
path: ./apps/desktop/build
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=desktop
npm i --ignore-scripts --prefer-offline --no-audit
npx lerna bootstrap --ignore=@notesnook/mobile -- --prefer-offline --no-audit
- name: Build
run: npx nx run release --project @notesnook/desktop
@@ -252,4 +252,4 @@ jobs:
} else {
yarn electron-builder --win --publish never
}
working-directory: ./apps/desktop
working-directory: ./apps/desktop

View File

@@ -29,8 +29,8 @@ jobs:
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=editor
npm i --ignore-scripts --prefer-offline --no-audit
npx lerna bootstrap --ignore=@notesnook/mobile -- --prefer-offline --no-audit
- name: Setup environment
run: |

View File

@@ -1,35 +0,0 @@
name: Publish Notesnook Help
on:
workflow_dispatch:
push:
branches:
- "master"
paths:
- "docs/help/**"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install docgen
run: cargo install --git https://github.com/thecodrr/docgen
- name: Build site
run: docgen build --release
working-directory: docs/help
- name: Setup environment
run: |
echo "CLOUDFLARE_ACCOUNT_ID=${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" >> $GITHUB_ENV
echo "CLOUDFLARE_API_TOKEN=${{ secrets.CLOUDFLARE_API_TOKEN }}" >> $GITHUB_ENV
- name: Publish on Cloudflare Pages
run: npx --yes wrangler pages deploy --project-name notesnook-help ./docs/help/site/ --branch main

View File

@@ -11,4 +11,4 @@ jobs:
steps:
- name: Run ats-diagnostics
run: nscurl --ats-diagnostics https://payments.streetwriters.co
run: nscurl --ats-diagnostics https://payments.streetwriters.co

View File

@@ -1,31 +0,0 @@
name: Publish @notesnook/theme-builder
on: workflow_dispatch
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: ./.github/actions/setup-node-with-cache
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=themebuilder
- name: Setup environment
run: |
echo "NX_CLOUD_ACCESS_TOKEN=${{ secrets.NX_CLOUD_ACCESS_TOKEN }}" >> $GITHUB_ENV
echo "CLOUDFLARE_ACCOUNT_ID=${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" >> $GITHUB_ENV
echo "CLOUDFLARE_API_TOKEN=${{ secrets.CLOUDFLARE_API_TOKEN }}" >> $GITHUB_ENV
- name: Generate build
run: npm run build:theme-builder
- name: Publish to Cloudflare Pages
run: npx --yes wrangler pages deploy --project-name=notesnook-theme-builder ./apps/theme-builder/build/

View File

@@ -1,31 +0,0 @@
name: Publish @notesnook/vericrypt
on: workflow_dispatch
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: ./.github/actions/setup-node-with-cache
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=vericrypt
- name: Setup environment
run: |
echo "NX_CLOUD_ACCESS_TOKEN=${{ secrets.NX_CLOUD_ACCESS_TOKEN }}" >> $GITHUB_ENV
echo "CLOUDFLARE_ACCOUNT_ID=${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" >> $GITHUB_ENV
echo "CLOUDFLARE_API_TOKEN=${{ secrets.CLOUDFLARE_API_TOKEN }}" >> $GITHUB_ENV
- name: Generate build
run: npm run build:vericrypt
- name: Publish on Cloudflare Pages
run: npx --yes wrangler pages deploy --project-name=vericrypt ./apps/vericrypt/build/

View File

@@ -1,67 +0,0 @@
name: Publish @notesnook/web Beta
on:
workflow_dispatch:
push:
branches:
- master
paths-ignore:
- "apps/mobile/**"
- "packages/editor-mobile/**"
- "apps/desktop/**"
- "apps/vericrypt/**"
- "servers/**"
- "packages/clipper/**"
- "extensions/web-clipper/**"
pull_request:
types:
- closed
- ready_for_review
- reopened
- opened
- synchronize
branches:
- master
paths-ignore:
- "apps/mobile/**"
- "packages/editor-mobile/**"
- "apps/desktop/**"
- "apps/vericrypt/**"
- "servers/**"
- "packages/clipper/**"
- "extensions/web-clipper/**"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: ./.github/actions/setup-node-with-cache
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=web
- name: Setup environment
run: |
echo "NX_CLOUD_ACCESS_TOKEN=${{ secrets.NX_CLOUD_ACCESS_TOKEN }}" >> $GITHUB_ENV
echo "CLOUDFLARE_ACCOUNT_ID=${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" >> $GITHUB_ENV
echo "CLOUDFLARE_API_TOKEN=${{ secrets.CLOUDFLARE_API_TOKEN }}" >> $GITHUB_ENV
- name: Generate beta build
run: npm run build:beta:web
- name: Publish to Cloudflare Pages
uses: unlike-ltd/github-actions-cloudflare-pages@v0.1.1
id: pages
with:
cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
cloudflare-account-id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
cloudflare-project-name: notesnook-beta-app
directory: ./apps/web/build
github-token: ${{ secrets.GITHUB_TOKEN }}
github-environment: ${{ (github.ref == 'refs/heads/master' && 'beta') || 'preview' }}

View File

@@ -15,8 +15,8 @@ jobs:
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=web
npm i --ignore-scripts --prefer-offline --no-audit
npx lerna bootstrap --ignore=@notesnook/mobile -- --prefer-offline --no-audit
- name: Setup environment
run: |
@@ -24,8 +24,8 @@ jobs:
echo "CLOUDFLARE_ACCOUNT_ID=${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" >> $GITHUB_ENV
echo "CLOUDFLARE_API_TOKEN=${{ secrets.CLOUDFLARE_API_TOKEN }}" >> $GITHUB_ENV
- name: Generate build
- name: Generate desktop build
run: npm run build:web
- name: Publish to Cloudflare Pages
run: npx --yes wrangler pages deploy --project-name=notesnook-app ./apps/web/build/
- name: Publish on Cloudflare Pages
run: npx --yes wrangler pages publish --project-name=notesnook-app ./apps/web/build/

View File

@@ -29,8 +29,8 @@ jobs:
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm run bootstrap -- --scope=web
npm i --ignore-scripts --prefer-offline --no-audit
npx lerna bootstrap --ignore=@notesnook/mobile -- --prefer-offline --no-audit
- name: Setup environment
run: |
@@ -66,7 +66,7 @@ jobs:
- name: Install packages
run: |
npm ci --ignore-scripts --prefer-offline --no-audit
npm i --ignore-scripts --prefer-offline --no-audit
npm install -D @playwright/test otplib
- name: Validate build extraction

1
.gitignore vendored
View File

@@ -9,4 +9,3 @@ nx-cloud.env
.env.local
.nyc_output
site
node_modules.backup

View File

@@ -5,6 +5,5 @@ module.exports = {
printWidth: 80,
useTabs: false,
tabWidth: 2,
bracketSpacing: true,
endOfLine: "lf"
bracketSpacing: true
};

72
.vscode/notesnook.code-workspace vendored Normal file
View File

@@ -0,0 +1,72 @@
{
"folders": [
{
"name": "✨ notesnook",
"path": ".."
},
{
"name": "🚀 @notesnook/mobile",
"path": "../apps/mobile"
},
{
"name": "🚀 @notesnook/web",
"path": "../apps/web"
},
{
"name": "🚀 @notesnook/desktop",
"path": "../apps/web/desktop"
},
{
"name": "🚀 @notesnook/web-clipper",
"path": "../extensions/web-clipper"
},
{
"name": "📦 @notesnook/clipper",
"path": "../packages/clipper"
},
{
"name": "📦 @notesnook/core",
"path": "../packages/core"
},
{
"name": "📦 @notesnook/crypto",
"path": "../packages/crypto"
},
{
"name": "📦 @notesnook/crypto-worker",
"path": "../packages/crypto-worker"
},
{
"name": "📦 @notesnook/editor",
"path": "../packages/editor"
},
{
"name": "📦 @notesnook/editor-mobile",
"path": "../packages/editor-mobile"
},
{
"name": "📦 @notesnook/logger",
"path": "../packages/logger"
},
{
"name": "📦 @notesnook/streamable-fs",
"path": "../packages/streamable-fs"
},
{
"name": "📦 @notesnook/theme",
"path": "../packages/theme"
}
],
"settings": {
"typescript.tsdk": "node_modules/typescript/lib",
"javascript.format.enable": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modificationsIfAvailable",
"eslint.packageManager": "npm",
"eslint.run": "onSave",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.execArgv": ["--cache"]
}
}

15
.vscode/settings.json vendored
View File

@@ -1,15 +0,0 @@
{
"files.eol": "\n",
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"eslint.run": "onSave",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"eslint.options": {
"cache": true,
"cacheStrategy": "content"
},
"git.rebaseWhenSync": true
}

View File

@@ -103,7 +103,7 @@ All commits must include valid scopes in the commit message. **Valid commit scop
**Packages:**
1. `crypto`: changes related to the cryptographic core
1. `crypto`: changes related to the cryptographic core (including `@notesnook/crypto-worker`)
2. `editor`: changes related to the editor (including `@notesnook/editor-mobile`)
3. `logger`: changes related to the logger
4. `theme`: changes related to the theme

View File

@@ -27,7 +27,7 @@ Notesnook is built using the following technologies:
3. React Native — For mobile apps we are using React Native
4. Electron — For desktop app
5. NPM — listed here because we **don't** use Yarn or PNPM or XYZ across any of our projects.
6. Nx — maintaining monorepos is hard but Nx makes it easier.
6. Lerna & Nx — maintaining monorepos is hard but Nx makes it easier.
> **Note: Each project in the monorepo contains its own architecture details which you can refer to.**
@@ -46,6 +46,7 @@ Notesnook is built using the following technologies:
| `@notesnook/editor-mobile` | [/packages/editor-mobile](/packages/editor-mobile) | A very thin wrapper around `@notesnook/editor` for mobile clients |
| `@notesnook/logger` | [/packages/logger](/packages/logger) | Simple & pluggable logger |
| `@notesnook/sodium` | [/packages/sodium](/packages/sodium) | Wrapper around libsodium to support Node.js & Browser |
| `@notesnook/crypto-worker` | [/packages/crypto-worker](/packages/crypto-worker) | Helpers to use `@notesnook/crypto` from a Worker |
| `@notesnook/streamable-fs` | [/packages/streamable-fs](/packages/streamable-fs) | Streaming interface around an IndexedDB based file system |
| `@notesnook/theme` | [/packages/theme](/packages/theme) | The core theme used in web & desktop clients |

View File

@@ -19,40 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* eslint-disable no-var */
import { BrowserWindow } from "electron";
import {
type FormData as FormDataType,
type Headers as HeadersType,
type Request as RequestType,
type Response as ResponseType
} from "undici";
declare global {
var window: BrowserWindow | null;
var RELEASE: boolean;
var MAC_APP_STORE: boolean;
// Re-export undici fetch function and various classes to global scope.
// These are classes and functions expected to be at global scope according to Node.js v18 API
// documentation.
// See: https://nodejs.org/dist/latest-v18.x/docs/api/globals.html
// eslint-disable-next-line no-var
export var {
FormData,
Headers,
Request,
Response,
fetch
}: typeof import("undici");
type FormData = FormDataType;
type Headers = HeadersType;
type Request = RequestType;
type Response = ResponseType;
}
// NOTE: the import in the global block above needs to be a var for this to work properly.
globalThis.fetch = fetch;
globalThis.FormData = FormData;
globalThis.Headers = Headers;
globalThis.Request = Request;
globalThis.Response = Response;

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
"name": "@notesnook/desktop",
"productName": "Notesnook",
"description": "Your private note taking space",
"version": "2.6.3",
"version": "2.5.3",
"appAppleId": "1544027013",
"private": true,
"main": "./dist/index.js",
@@ -11,34 +11,34 @@
"repository": "https://github.com/streetwriters/notesnook",
"license": "GPL-3.0-or-later",
"dependencies": {
"@notesnook/crypto": "file:../../packages/crypto",
"@trpc/client": "10.31.0",
"@trpc/server": "10.31.0",
"electron-trpc": "0.5.2",
"electron-updater": "6.1.4",
"@notesnook/crypto": "*",
"@trpc/client": "^10.29.1",
"@trpc/server": "^10.29.1",
"diary": "^0.3.1",
"electron-trpc": "^0.5.2",
"electron-updater": "^5.3.0",
"icojs": "^0.17.1",
"typed-emitter": "^2.1.0",
"yargs": "^17.6.2",
"zod": "^3.21.4"
},
"devDependencies": {
"@types/node": "18.16.1",
"@types/yargs": "^17.0.24",
"chokidar": "^3.5.3",
"electron": "25.8.0",
"electron-builder": "^24.6.4",
"@electron/rebuild": "^3.2.13",
"@types/node": "^18.15.0",
"electron": "^24.4.0",
"electron-builder": "^23.6.0",
"electron-builder-notarize": "^1.5.1",
"electron-reloader": "^1.2.3",
"esbuild": "^0.17.19",
"tree-kill": "^1.2.2",
"undici": "^5.23.0"
"node-fetch": "^3.3.1"
},
"optionalDependencies": {
"dmg-license": "^1.0.11"
},
"scripts": {
"start": "node scripts/dev.mjs",
"staging": "node scripts/build.mjs --run",
"release": "node scripts/build.mjs",
"start": "turbowatch scripts/dev.ts",
"staging": "zx scripts/build.mjs --run",
"release": "zx scripts/build.mjs",
"build": "tsc",
"bundle": "esbuild electron=./src/main.ts ./src/preload.ts --external:electron --external:fsevents --minify --bundle --outdir=./build --platform=node --tsconfig=tsconfig.json --define:MAC_APP_STORE=false --define:RELEASE=true",
"bundle:mas": "esbuild electron=./src/main.ts ./src/preload.ts --minify --external:electron --external:fsevents --bundle --outdir=./build --platform=node --tsconfig=tsconfig.json --define:MAC_APP_STORE=true --define:RELEASE=true",
@@ -55,15 +55,11 @@
"copyright": "Copyright © 2023 Streetwriters (Private) Limited",
"artifactName": "notesnook_${os}_${arch}.${ext}",
"npmRebuild": false,
"asar": false,
"files": [
"!*.chunk.js.map",
"!*.chunk.js.LICENSE.txt",
"build/",
"!build/screenshots${/*}",
"!build/banner.jpg",
"!build/*.ico",
"!build/*.png",
"!node_modules${/*}"
],
"afterSign": "electron-builder-notarize",

View File

@@ -1,20 +1,20 @@
diff --git a/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js b/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js
index fcb7f54..cb1c7f7 100644
index ffcc8bd..7e57c9e 100644
--- a/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js
+++ b/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js
@@ -116,6 +116,7 @@ class LinuxTargetHelper {
@@ -105,6 +105,7 @@ class LinuxTargetHelper {
StartupWMClass: appInfo.productName,
...extra,
...targetSpecificOptions.desktop,
+ actions: undefined
};
const description = this.getDescription(targetSpecificOptions);
if (!(0, builder_util_1.isEmptyOrSpaces)(description)) {
@@ -159,6 +160,23 @@ class LinuxTargetHelper {
if (!builder_util_1.isEmptyOrSpaces(description)) {
@@ -148,6 +149,23 @@ class LinuxTargetHelper {
data += `\n${name}=${desktopMeta[name]}`;
}
data += "\n";
+
+
+ if (targetSpecificOptions.desktop.actions) {
+ let actionsData = "";
+ const validActions = [];

View File

@@ -20,14 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import path from "path";
import fs from "fs/promises";
import { existsSync } from "fs";
import yargs from "yargs-parser";
import os from "os";
import { argv, os } from "zx";
import * as childProcess from "child_process";
import { fileURLToPath } from "url";
const args = yargs(process.argv);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const sodiumNativePrebuildPath = (arch) =>
path.join(
`node_modules`,
@@ -42,19 +37,18 @@ const sodiumNativePrebuildPath = (arch) =>
`${os.platform()}-${arch}`
);
const webAppPath = path.resolve(path.join(__dirname, "..", "..", "web"));
if (argv.rebuild) {
await fs.rm("./build/", { force: true, recursive: true });
await fs.rm("./build/", { force: true, recursive: true });
if (args.rebuild || !existsSync(path.join(webAppPath, "build"))) {
await exec(`cd ${webAppPath} && npm run build:desktop`);
await fs.cp(path.join(webAppPath, "build"), "build", {
recursive: true,
force: true
});
}
await fs.cp(path.join(webAppPath, "build"), "build", {
recursive: true,
force: true
});
if (args.variant === "mas") {
if (argv.variant === "mas") {
await exec(`npm run bundle:mas`);
} else {
await exec(`npm run bundle`);
@@ -98,14 +92,13 @@ if (existsSync(sodiumNativePrebuildPath("arm64"))) {
);
}
if (args.run) {
await exec(`npx electron-builder --dir --x64`);
if (argv.run) {
if (process.platform === "win32") {
await exec(`.\\output\\win-unpacked\\Notesnook.exe`);
} else if (process.platform === "darwin") {
await exec(`./output/darwin-unpacked/Notesnook`);
await exec(`npx electron-builder --win --x64`);
// await exec(`.\\output\\notesnook_win_x64_portable.exe`);
} else {
await exec(`./output/linux-unpacked/Notesnook`);
await exec(`npx electron-builder --linux AppImage:x64`);
await exec(`./output/notesnook_linux_x86_64.AppImage`);
}
}

View File

@@ -1,197 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import path from "path";
import fs from "fs/promises";
import chokidar from "chokidar";
import { execSync, spawn } from "child_process";
import { fileURLToPath } from "url";
import treekill from "tree-kill";
import crypto from "crypto";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const sodiumNativePrebuildPath = path.join(
`node_modules`,
`@notesnook`,
`crypto`,
`node_modules`,
`@notesnook`,
`sodium`,
`node_modules`,
`sodium-native`,
`prebuilds`
);
const RUNNING_PROCESSES = [];
const RESTARTABLE_PROCESSES = [];
let lastBundleHash = null;
await onChange(true);
console.log("Watching...");
const watcher = chokidar.watch("src/", { ignoreInitial: true });
watcher.on("all", () => {
onChange(false);
});
process.on("SIGINT", async (s) => {
await cleanup();
});
async function onChange(first) {
if (first) {
await fs.rm("./build/", { force: true, recursive: true });
}
await exec(`npm run bundle`);
execAsync(`npx`, [`tsc`]);
if (await isBundleSame()) {
console.log("Bundle is same. Doing nothing.");
return;
}
if (first) {
await fs.cp(sodiumNativePrebuildPath, "build/prebuilds", {
recursive: true,
force: true
});
}
if (first) {
await spawnAndWaitUntil(
["npx", "nx", "start:desktop", "@notesnook/web"],
path.join(__dirname, "..", "..", ".."),
(data) => data.includes("Network: use --host to expose")
);
}
if (!first) {
console.log("Restarting...", RESTARTABLE_PROCESSES.length);
await killProcesses(RESTARTABLE_PROCESSES);
}
execAsync(
"npx",
["electron", path.join("build", "electron.js")],
true,
cleanup
);
}
function spawnAndWaitUntil(cmd, cwd, predicate) {
return new Promise((resolve) => {
console.log(">", ...cmd);
const s = spawn(cmd[0], cmd.slice(1), {
cwd,
env: { ...process.env, NO_COLOR: "true" },
shell: false
});
RUNNING_PROCESSES.push(s);
s.stderr.pipe(process.stderr);
s.stdout.on("data", (data) => {
process.stdout.write(data);
if (predicate(data)) resolve(undefined); //
});
});
}
async function exec(cmd) {
try {
console.log(">", cmd);
return execSync(cmd, {
env: process.env,
stdio: "inherit",
shell: false
});
} catch {
//ignore
}
}
function execAsync(cmd, args, restartable, onExit) {
try {
console.log(">", cmd, ...args);
const proc = spawn(cmd, args, {
stdio: "inherit",
env: process.env,
shell: false
});
const array = restartable ? RESTARTABLE_PROCESSES : RUNNING_PROCESSES;
array.push(proc);
proc.on("exit", (code, signal) => {
console.log(cmd, ...args, "closed with code", code);
if (code === 0 && !signal) {
array.splice(array.indexOf(proc), 1);
onExit && onExit();
}
});
} catch {
//ignore
}
}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function killProcesses(processes) {
for (const process of processes.slice()) {
processes.splice(processes.indexOf(process), 1);
await new Promise((resolve, reject) =>
treekill(process.pid, (err) => (err ? reject(err) : resolve()))
);
}
}
async function cleanup() {
console.log("Cleaning up");
await killProcesses(RESTARTABLE_PROCESSES);
await killProcesses(RUNNING_PROCESSES);
await sleep(1000);
await fs.rm("./build/", { force: true, recursive: true });
process.exit();
}
async function isBundleSame() {
const bundle = await fs.readFile(
path.join(__dirname, "..", "build", "electron.js")
);
const hashSum = crypto.createHash("sha256");
hashSum.update(bundle);
const hex = hashSum.digest("hex");
if (!lastBundleHash) {
lastBundleHash = hex;
return false;
}
if (hex === lastBundleHash) return true;
lastBundleHash = hex;
return false;
}

116
apps/desktop/scripts/dev.ts Normal file
View File

@@ -0,0 +1,116 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import path from "path";
import fs from "fs/promises";
import { watch } from "turbowatch";
import { $, within } from "zx";
const sodiumNativePrebuildPath = path.join(
`node_modules`,
`@notesnook`,
`crypto`,
`node_modules`,
`@notesnook`,
`sodium`,
`node_modules`,
`sodium-native`,
`prebuilds`
);
let isServerRunning = false;
async function main() {
const { shutdown } = await watch({
project: path.join(__dirname, ".."),
cwd: path.join(__dirname, ".."),
triggers: [
{
expression: [
"allof",
["not", ["dirname", "node_modules"]],
["match", "*.ts", "basename"]
],
name: "dev",
// retry: { retries: 0 },
onTeardown: async () => {
await fs.rm("./build/", { force: true, recursive: true });
},
onChange: async ({ spawn: $, first, log }) => {
if (first) {
await fs.rm("./build/", { force: true, recursive: true });
}
await $`npm run bundle`;
await $`npx tsc`;
if (first) {
await fs.cp(sodiumNativePrebuildPath, "build/prebuilds", {
recursive: true,
force: true
});
}
if (!isServerRunning) {
await spawnAndWaitUntil(
path.join(__dirname, "..", "..", "web"),
"npm run start:desktop",
(data) => data.includes("Network: use --host to expose")
);
isServerRunning = true;
}
await $`npx electron ${path.join("build", "electron.js")}`;
}
}
]
});
// SIGINT is the signal sent when we press Ctrl+C
process.once("SIGINT", () => {
void shutdown();
});
}
main();
function spawnAndWaitUntil(
cwd: string,
cmd: string,
predicate: (data: string) => boolean
) {
return new Promise((resolve) => {
within(async () => {
$.env = process.env;
$.env.NO_COLOR = "true";
$.quote = (c) => c;
try {
const s = $`cd ${cwd} && ${cmd}`;
s.stdout.on("data", (data) => {
if (predicate(data)) resolve(undefined); //
});
await s;
} catch (e) {
//ignore
} finally {
isServerRunning = false;
}
});
});
}

View File

@@ -25,10 +25,10 @@ import { config, DesktopIntegration } from "../utils/config";
import { bringToFront } from "../utils/bring-to-front";
import { getTheme, setTheme, Theme } from "../utils/theme";
import { mkdirSync, writeFileSync } from "fs";
import { dirname } from "path";
import { dirname, join } from "path";
import { platform } from "os";
import { resolvePath } from "../utils/resolve-path";
import { observable } from "@trpc/server/observable";
import { AssetManager } from "../utils/asset-manager";
const t = initTRPC.create();
@@ -52,21 +52,21 @@ export const osIntegrationRouter = t.router({
privacyMode: t.procedure.query(() => config.privacyMode),
setPrivacyMode: t.procedure
.input(z.object({ enabled: z.boolean() }))
.mutation(({ input: { enabled } }) => {
.input(z.boolean().optional())
.mutation(({ input: privacyMode }) => {
if (!globalThis.window || !["win32", "darwin"].includes(process.platform))
return;
globalThis.window.setContentProtection(enabled);
globalThis.window.setContentProtection(!!privacyMode);
if (process.platform === "win32") {
globalThis.window.setThumbnailClip(
enabled
privacyMode
? { x: 0, y: 0, width: 1, height: 1 }
: { x: 0, y: 0, width: 0, height: 0 }
);
}
config.privacyMode = enabled;
config.privacyMode = !!privacyMode;
}),
desktopIntegration: t.procedure.query(() => config.desktopSettings),
@@ -122,10 +122,10 @@ export const osIntegrationRouter = t.router({
.query(({ input }) => {
const notification = new Notification({
...input,
icon: AssetManager.appIcon({
size: 64,
format: process.platform === "win32" ? "ico" : "png"
})
icon: join(
__dirname,
platform() === "win32" ? "app.ico" : "favicon-72x72.png"
)
});
notification.show();
if (input.urgency === "critical") {

View File

@@ -114,9 +114,9 @@ export const spellCheckerRouter = t.router({
globalThis.window?.webContents.session.setSpellCheckerLanguages(languages)
),
toggle: t.procedure
.input(z.object({ enabled: z.boolean() }))
.mutation(({ input: { enabled } }) => {
globalThis.window?.webContents.session.setSpellCheckerEnabled(enabled);
config.isSpellCheckerEnabled = enabled;
.input(z.boolean().optional())
.mutation(({ input: enabled }) => {
globalThis.window?.webContents.session.setSpellCheckerEnabled(!!enabled);
config.isSpellCheckerEnabled = !!enabled;
})
});

View File

@@ -21,8 +21,6 @@ import { initTRPC } from "@trpc/server";
import { observable } from "@trpc/server/observable";
import { CancellationToken, autoUpdater } from "electron-updater";
import type { AppUpdaterEvents } from "electron-updater/out/AppUpdater";
import { z } from "zod";
import { config } from "../utils/config";
type UpdateInfo = { version: string };
type Progress = { percent: number };
@@ -30,7 +28,6 @@ type Progress = { percent: number };
const t = initTRPC.create();
export const updaterRouter = t.router({
autoUpdates: t.procedure.query(() => config.automaticUpdates),
install: t.procedure.query(() => autoUpdater.quitAndInstall()),
download: t.procedure.query(async () => {
const cancellationToken = new CancellationToken();
@@ -40,12 +37,6 @@ export const updaterRouter = t.router({
await autoUpdater.checkForUpdates();
}),
toggleAutoUpdates: t.procedure
.input(z.object({ enabled: z.boolean() }))
.mutation(({ input: { enabled } }) => {
config.automaticUpdates = enabled;
}),
onChecking: createSubscription("checking-for-update"),
onDownloaded: createSubscription<"update-downloaded", UpdateInfo>(
"update-downloaded"

View File

@@ -16,6 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* global MAC_APP_STORE, RELEASE */
import { app, BrowserWindow, nativeTheme, shell } from "electron";
import { isDevelopment } from "./utils";
@@ -33,12 +34,9 @@ import { createIPCHandler } from "electron-trpc/main";
import { router, api } from "./api";
import { config } from "./utils/config";
import path from "path";
import { bringToFront } from "./utils/bring-to-front";
// only run a single instance
if (!MAC_APP_STORE && !app.requestSingleInstanceLock()) {
console.log("Another instance is already running!");
app.exit();
if (!RELEASE) {
require("electron-reloader")(module);
}
if (process.platform == "win32" && process.env.PORTABLE_EXECUTABLE_DIR) {
@@ -48,34 +46,32 @@ if (process.platform == "win32" && process.env.PORTABLE_EXECUTABLE_DIR) {
app.setPath("documents", path.join(root, "Documents"));
app.setPath("userData", path.join(root, "UserData"));
}
// only run a single instance
if (!MAC_APP_STORE && !app.requestSingleInstanceLock()) {
app.exit();
}
if (process.platform === "win32") {
app.setAppUserModelId(app.name);
}
process.on("uncaughtException", (error) => {
console.error("uncaughtException:", error);
});
process.on("unhandledRejection", (reason) => {
console.error("unhandledRejection:", reason);
});
app.commandLine.appendSwitch("lang", "en-US");
async function createWindow() {
await AssetManager.loadIcons();
const cliOptions = await parseArguments();
setTheme(getTheme());
const mainWindowState = new WindowState({});
setTheme(getTheme());
const mainWindow = new BrowserWindow({
show: !cliOptions.hidden,
show: false,
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
darkTheme: getTheme() === "dark",
backgroundColor: getBackgroundColor(),
opacity: 0,
autoHideMenuBar: true,
icon: AssetManager.appIcon({
size: 512,
@@ -83,44 +79,44 @@ async function createWindow() {
}),
webPreferences: {
zoomFactor: config.zoomFactor,
nodeIntegration: true,
devTools: true, // isDev,
nodeIntegration: true, //true,
contextIsolation: false,
spellcheck: config.isSpellCheckerEnabled,
preload: __dirname + "/preload.js"
}
});
globalThis.window = mainWindow;
mainWindow.on("show", async () => {
if (config.privacyMode) {
await api.integration.setPrivacyMode(config.privacyMode);
}
});
mainWindowState.manage(mainWindow);
if (cliOptions.hidden && !config.desktopSettings.minimizeToSystemTray)
mainWindow.minimize();
await mainWindow.webContents.loadURL(`${createURL(cliOptions, "/")}`);
mainWindow.setOpacity(1);
if (config.privacyMode) {
await api.integration.setPrivacyMode({ enabled: config.privacyMode });
}
await AssetManager.loadIcons();
setupDesktopIntegration();
globalThis.window = mainWindow;
setupMenu();
setupJumplist();
setupDesktopIntegration(cliOptions.hidden);
createIPCHandler({ router, windows: [mainWindow] });
mainWindow.webContents.session.setSpellCheckerDictionaryDownloadURL(
"http://dictionaries.notesnook.com/"
);
mainWindow.once("closed", () => {
globalThis.window = null;
});
setupMenu();
setupJumplist();
if (isDevelopment())
mainWindow.webContents.openDevTools({ mode: "right", activate: true });
try {
await mainWindow.loadURL(`${createURL(cliOptions)}`);
} catch (e) {
if (e instanceof Error) console.error(e);
}
mainWindow.on("closed", () => {
globalThis.window = null;
});
mainWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url);
return { action: "deny" };
@@ -132,7 +128,8 @@ async function createWindow() {
});
}
app.once("ready", async () => {
app.commandLine.appendSwitch("lang", "en-US");
app.on("ready", async () => {
console.info("App ready. Opening window.");
if (!isDevelopment()) registerProtocol();
@@ -140,27 +137,21 @@ app.once("ready", async () => {
configureAutoUpdater();
});
app.once("window-all-closed", () => {
app.on("window-all-closed", () => {
if (process.platform !== "darwin" || MAC_APP_STORE) {
app.quit();
}
});
app.on("second-instance", () => {
if (!globalThis.window) return;
bringToFront();
});
app.on("activate", () => {
if (globalThis.window === null) {
createWindow();
}
});
function createURL(options: CLIOptions, path = "/") {
function createURL(options: CLIOptions) {
const url = new URL(isDevelopment() ? "http://localhost:3000" : PROTOCOL_URL);
url.pathname = path;
if (options.note === true) url.hash = "/notes/create/1";
else if (options.notebook === true) url.hash = "/notebooks/create";
else if (options.reminder === true) url.hash = "/reminders/create";
@@ -172,7 +163,7 @@ function createURL(options: CLIOptions, path = "/") {
return url;
}
function setupDesktopIntegration() {
function setupDesktopIntegration(hidden: boolean) {
const desktopIntegration = config.desktopSettings;
if (
@@ -182,13 +173,24 @@ 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) {
app.on("before-quit", () => app.exit(0));
}
globalThis.window?.once("close", (e) => {
globalThis.window?.on("close", (e) => {
if (config.desktopSettings.closeToSystemTray) {
e.preventDefault();
if (process.platform == "darwin") {

View File

@@ -22,10 +22,9 @@ import { ELECTRON_TRPC_CHANNEL } from "electron-trpc/main";
import { type RendererGlobalElectronTRPC } from "electron-trpc/src/types";
import type { NNCrypto } from "@notesnook/crypto";
import { ipcRenderer } from "electron";
import { platform } from "os";
declare global {
var os: () => "mas" | ReturnType<typeof platform>;
var os: string;
var electronTRPC: RendererGlobalElectronTRPC;
var NativeNNCrypto: (new () => NNCrypto) | undefined;
}
@@ -48,4 +47,4 @@ globalThis.NativeNNCrypto =
? undefined
: require("@notesnook/crypto").NNCrypto;
globalThis.os = () => (MAC_APP_STORE ? "mas" : platform());
globalThis.os = MAC_APP_STORE ? "mas" : process.platform;

View File

@@ -21,8 +21,8 @@ import { NativeImage, nativeImage } from "electron";
import path from "path";
import { isDevelopment } from "./index";
import { parse, ParsedImage } from "icojs";
import { readFileSync } from "fs";
import { getSystemTheme } from "./theme";
import { readFile } from "fs/promises";
type Formats = "ico" | "png" | "icns";
type IconOptions<TFormat extends Formats> = {
@@ -70,7 +70,7 @@ export class AssetManager {
"icons",
`${icon}${prefix}.ico`
);
const icoBuffer = await readFile(icoPath);
const icoBuffer = readFileSync(icoPath);
const images = await parse(icoBuffer, "image/png");
ALL_ICONS.push({ id: icon, images, prefix });
}
@@ -80,10 +80,10 @@ export class AssetManager {
static appIcon(options: IconOptions<Formats>) {
const { size = 32, format = "png" } = options;
if (format === "ico") return "assets\\icons\\app.ico";
if (format === "icns") return "assets/icons/app.icns";
if (format === "ico") return path.join("assets", "icons", "app.ico");
if (format === "icns") return path.join("assets", "icons", "app.icns");
return `assets/icons/${size}x${size}.png`;
return path.join("assets", "icons", `${size}x${size}.png`);
}
static icon<TFormat extends Formats>(

View File

@@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { autoUpdater } from "electron-updater";
import { config } from "./config";
async function configureAutoUpdater() {
autoUpdater.setFeedURL({
@@ -27,7 +26,7 @@ async function configureAutoUpdater() {
useMultipleRangeRequest: false
});
autoUpdater.autoDownload = config.automaticUpdates;
autoUpdater.autoDownload = false;
autoUpdater.allowDowngrade = false;
autoUpdater.allowPrerelease = false;
autoUpdater.autoInstallOnAppQuit = true;

View File

@@ -38,10 +38,9 @@ export const config = {
closeToSystemTray: false
},
privacyMode: false,
isSpellCheckerEnabled: true,
zoomFactor: 1,
theme: nativeTheme.themeSource,
automaticUpdates: true
isSpellCheckerEnabled: false,
zoomFactor: 0,
theme: nativeTheme.themeSource
};
type ConfigKey = keyof typeof config;

View File

@@ -18,8 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { app } from "electron";
import { join } from "path";
import { existsSync } from "fs";
export const APP_ICON_PATH = join(
__dirname,
process.platform === "win32" ? "app.ico" : "favicon-72x72.png"
);
export function isDevelopment() {
return process.env.ELECTRON_IS_DEV
? Number.parseInt(process.env.ELECTRON_IS_DEV, 10) === 1

View File

@@ -101,26 +101,6 @@ function setupMenu() {
})
);
if (params.linkURL?.length) {
menu.append(
new MenuItem({
label: "Copy link",
click() {
clipboard.writeText(params.linkURL);
}
})
);
menu.append(
new MenuItem({
label: "Copy link text",
click() {
clipboard.writeText(params.linkText);
}
})
);
}
if (params.selectionText.length) {
menu.append(
new MenuItem({

View File

@@ -17,14 +17,16 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { protocol, net } from "electron";
import { protocol, ProtocolRequest } from "electron";
import { isDevelopment } from "./index";
import { createReadStream } from "fs";
import { extname, normalize } from "path";
import { createReadStream, statSync } from "fs";
import { extname, join, normalize } from "path";
import { URL } from "url";
import fetch, { Response } from "node-fetch";
const BASE_PATH = isDevelopment() ? "../public" : "";
const HOSTNAME = `app.notesnook.com`;
const FILE_NOT_FOUND = -6;
const SCHEME = "https";
const extensionToMimeType: Record<string, string> = {
html: "text/html",
@@ -32,42 +34,102 @@ const extensionToMimeType: Record<string, string> = {
js: "application/javascript",
css: "text/css",
svg: "image/svg+xml",
png: "image/png",
jpg: "image/jpg",
ttf: "font/ttf",
woff: "font/woff",
woff2: "font/woff2"
png: "image/png"
};
function registerProtocol() {
protocol.handle(SCHEME, async (request) => {
const url = new URL(request.url);
if (shouldInterceptRequest(url)) {
console.info("Intercepting request:", request.url);
const loadIndex = !extname(url.pathname);
const filePath = normalize(
`${__dirname}${
loadIndex ? `${BASE_PATH}/index.html` : `${BASE_PATH}/${url.pathname}`
}`
);
if (!filePath) {
console.error("Local asset file not found at", filePath);
return new Response(undefined, {
status: 404,
statusText: "FILE_NOT_FOUND"
const protocolInterceptionResult = protocol.interceptStreamProtocol(
SCHEME,
async (request, callback) => {
const url = new URL(request.url);
if (shouldInterceptRequest(url)) {
console.info("Intercepting request:", request.url);
const loadIndex = !extname(url.pathname);
const absoluteFilePath = normalize(
`${__dirname}${
loadIndex
? `${BASE_PATH}/index.html`
: `${BASE_PATH}/${url.pathname}`
}`
);
const filePath = getPath(absoluteFilePath);
if (!filePath) {
console.error("Local asset file not found at", filePath);
callback({ error: FILE_NOT_FOUND });
return;
}
const fileExtension = extname(filePath).replace(".", "");
const data = createReadStream(filePath);
callback({
data,
mimeType: extensionToMimeType[fileExtension]
});
} else {
let response: Response;
try {
const body = await getBody(request);
response = await fetch(request.url, {
...request,
body,
headers: {
...request.headers
// origin: `${PROTOCOL}://${HOSTNAME}/`
},
referrer: request.referrer,
redirect: "manual"
});
} catch (e) {
console.error(e);
console.error(`Error sending request to `, request.url, "Error: ", e);
callback({ statusCode: 400 });
return;
}
callback({
statusCode: response.status,
data: response.body || undefined,
headers: Object.fromEntries(response.headers.entries()),
mimeType: response.headers.get("Content-Type") || undefined
});
}
const fileExtension = extname(filePath).replace(".", "");
return new Response(createReadStream(filePath), {
headers: { "Content-Type": extensionToMimeType[fileExtension] }
});
} else {
return net.fetch(request, {
bypassCustomProtocolHandlers: true
});
}
});
console.info(`${SCHEME} protocol inteception "successful"`);
);
console.info(
`${SCHEME} protocol inteception ${
protocolInterceptionResult ? "successful" : "failed"
}.`
);
// protocol.handle(SCHEME, (request) => {
// const url = new URL(request.url);
// if (shouldInterceptRequest(url)) {
// console.info("Intercepting request:", request.url);
// const loadIndex = !extname(url.pathname);
// const absoluteFilePath = normalize(
// `${__dirname}${
// loadIndex ? `${BASE_PATH}/index.html` : `${BASE_PATH}/${url.pathname}`
// }`
// );
// const filePath = getPath(absoluteFilePath);
// if (!filePath) {
// console.error("Local asset file not found at", filePath);
// return new Response(undefined, {
// status: 404,
// statusText: "FILE_NOT_FOUND"
// });
// }
// const fileExtension = extname(filePath).replace(".", "");
// const data = createReadStream(filePath);
// return new Response(data, {
// headers: { "Content-Type": extensionToMimeType[fileExtension] }
// });
// } else {
// return net.fetch(request);
// }
// });
// console.info(`${SCHEME} protocol inteception "successful"`);
}
const bypassedRoutes: string[] = [];
@@ -78,3 +140,37 @@ function shouldInterceptRequest(url: URL) {
const PROTOCOL_URL = `${SCHEME}://${HOSTNAME}/`;
export { registerProtocol, PROTOCOL_URL };
async function getBody(request: ProtocolRequest) {
const session = globalThis?.window?.webContents?.session;
const blobParts = [];
if (!request.uploadData || !request.uploadData.length) return null;
for (const data of request.uploadData) {
if (data.bytes) {
blobParts.push(new Uint8Array(data.bytes));
} else if (session && data.blobUUID) {
const buffer = await session.getBlobData(data.blobUUID);
if (!buffer) continue;
blobParts.push(new Uint8Array(buffer));
}
}
const blob = new Blob(blobParts);
return blob;
}
function getPath(filePath: string): string | undefined {
try {
const result = statSync(filePath);
if (result.isFile()) {
return filePath;
}
if (result.isDirectory()) {
return getPath(join(filePath, "index.html"));
}
} catch (_) {
// ignore
}
}

View File

@@ -5,6 +5,7 @@ artifacts/
.DS_Store
native/android/app/src/main/assets/
*Issues.md
build_cache/
#

View File

@@ -25,4 +25,4 @@
"request": "attach"
}
]
}
}

View File

@@ -16,12 +16,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import "@azure/core-asynciterator-polyfill";
import SettingsService from "./services/settings";
import {
THEME_COMPATIBILITY_VERSION,
useThemeEngineStore
} from "@notesnook/theme";
import React, { useEffect } from "react";
import { View } from "react-native";
import "react-native-gesture-handler";
@@ -33,11 +27,11 @@ import GlobalSafeAreaProvider from "./components/globalsafearea";
import { useAppEvents } from "./hooks/use-app-events";
import { ApplicationHolder } from "./navigation";
import Notifications from "./services/notifications";
import SettingsService from "./services/settings";
import { TipManager } from "./services/tip-manager";
import { useThemeStore } from "./stores/use-theme-store";
import { useUserStore } from "./stores/use-user-store";
import { themeTrpcClient } from "./screens/settings/theme-selector";
SettingsService.init();
SettingsService.checkOrientation();
const App = () => {
const init = useAppEvents();
@@ -46,7 +40,6 @@ const App = () => {
if (appLockMode && appLockMode !== "none") {
useUserStore.getState().lockApp(true);
}
globalThis["IS_MAIN_APP_RUNNING"] = true;
init();
setTimeout(async () => {
SettingsService.onFirstLaunch();
@@ -94,53 +87,4 @@ const App = () => {
);
};
let currTheme =
useThemeStore.getState().colorScheme === "dark"
? SettingsService.getProperty("darkTheme")
: SettingsService.getProperty("lightTheme");
useThemeEngineStore.getState().setTheme(currTheme);
export const withTheme = (Element) => {
return function AppWithThemeProvider() {
const [colorScheme, darkTheme, lightTheme] = useThemeStore((state) => [
state.colorScheme,
state.darkTheme,
state.lightTheme
]);
useEffect(() => {
setTimeout(() => {
const currentTheme = colorScheme === "dark" ? darkTheme : lightTheme;
if (!currentTheme) return;
themeTrpcClient.updateTheme
.query({
version: currentTheme.version,
compatibilityVersion: THEME_COMPATIBILITY_VERSION,
id: currentTheme.id
})
.then((theme) => {
if (theme) {
console.log(theme.version, "theme updated");
theme.colorScheme === "dark"
? useThemeStore.getState().setDarkTheme(theme)
: useThemeStore.getState().setLightTheme(theme);
}
})
.catch(console.log);
}, 1000);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const nextTheme = colorScheme === "dark" ? darkTheme : lightTheme;
if (JSON.stringify(nextTheme) !== JSON.stringify(currTheme)) {
useThemeEngineStore
.getState()
.setTheme(colorScheme === "dark" ? darkTheme : lightTheme);
currTheme = nextTheme;
}
return <Element />;
};
};
export default withTheme(withErrorBoundry(App, "App"));
export default withErrorBoundry(App, "App");

View File

@@ -126,18 +126,6 @@ export async function decrypt(password, data) {
return await Sodium.decrypt(password, _data);
}
export async function decryptMulti(password, data) {
if (!password.password && !password.key) return undefined;
if (password.password && password.password === "" && !password.key)
return undefined;
data = data.map((d) => {
d.output = "plain";
return d;
});
return await Sodium.decryptMulti(password, data);
}
export function parseAlgorithm(alg) {
if (!alg) return {};
const [enc, kdf, compressed, compressionAlg, base64variant] = alg.split("-");
@@ -166,24 +154,3 @@ export async function encrypt(password, data) {
alg: getAlgorithm(7)
};
}
export async function encryptMulti(password, data) {
if (!password.password && !password.key) return undefined;
if (password.password && password.password === "" && !password.key)
return undefined;
let results = await Sodium.encryptMulti(
password,
data.map((item) => ({
type: "plain",
data: item
}))
);
return !results
? []
: results.map((result) => ({
...result,
alg: getAlgorithm(7)
}));
}

View File

@@ -17,37 +17,18 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { database } from "@notesnook/common";
import { logger as dbLogger } from "@notesnook/core/dist/logger";
import { initalize, logger as dbLogger } from "@notesnook/core/logger";
import { Platform } from "react-native";
import * as Gzip from "react-native-gzip";
import { MMKVLoader } from "react-native-mmkv-storage";
import filesystem from "../filesystem";
import EventSource from "../../utils/sse/even-source-ios";
import AndroidEventSource from "../../utils/sse/event-source";
import filesystem from "../filesystem";
import "./logger";
import Storage from "./storage";
import Storage, { KV } from "./storage";
import * as Gzip from "react-native-gzip";
database.host(
__DEV__
? {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
// API_HOST: "http://192.168.43.108:5264",
// AUTH_HOST: "http://192.168.43.108:8264",
// SSE_HOST: "http://192.168.43.108:7264",
// SUBSCRIPTIONS_HOST: "http://192.168.43.108:9264",
// ISSUES_HOST: "http://192.168.43.108:2624"
}
: {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
}
);
const LoggerStorage = new MMKVLoader()
.withInstanceID("notesnook_logs")
.initialize();
database.setup(
Storage,
@@ -59,5 +40,30 @@ database.setup(
}
);
database.host(
__DEV__
? {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
// API_HOST: "http://192.168.8.101:5264",
// AUTH_HOST: "http://192.168.8.101:8264",
// SSE_HOST: "http://192.168.8.101:7264",
// SUBSCRIPTIONS_HOST: "http://192.168.8.101:9264",
// ISSUES_HOST: "http://192.168.8.101:2624"
}
: {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
}
);
initalize(new KV(LoggerStorage), true);
export const db = database;
export const DatabaseLogger = dbLogger;

View File

@@ -18,13 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Platform } from "react-native";
import { ProcessingModes, MMKVLoader } from "react-native-mmkv-storage";
import MMKVStorage, { ProcessingModes } from "react-native-mmkv-storage";
export const MMKV = new MMKVLoader()
export const MMKV = new MMKVStorage.Loader()
.setProcessingMode(
Platform.OS === "ios"
? ProcessingModes.MULTI_PROCESS
: ProcessingModes.SINGLE_PROCESS
)
.disableIndexing()
.initialize();

View File

@@ -27,16 +27,11 @@ import {
getCryptoKey,
getRandomBytes,
hash,
removeCryptoKey,
decryptMulti,
encryptMulti
removeCryptoKey
} from "./encryption";
import { MMKV } from "./mmkv";
export class KV {
/**
* @type {typeof MMKV}
*/
storage = null;
constructor(storage) {
this.storage = storage;
@@ -58,7 +53,6 @@ export class KV {
key,
typeof data === "string" ? data : JSON.stringify(data)
);
return true;
}
@@ -66,32 +60,27 @@ export class KV {
if (keys.length <= 0) {
return [];
} else {
try {
let data = await this.storage.getMultipleItemsAsync(
keys.slice(),
"string"
);
return data.map(([key, value]) => {
let obj;
try {
obj = JSON.parse(value);
} catch (e) {
obj = value;
}
return [key, obj];
});
} catch (e) {
console.log(e);
}
let data = await this.storage.getMultipleItemsAsync(keys.slice());
return data.map(([key, value]) => {
let obj;
try {
obj = JSON.parse(value);
} catch (e) {
obj = value;
}
return [key, obj];
});
}
}
async remove(key) {
return this.storage.removeItem(key);
return await this.storage.removeItem(key);
}
async clear() {
return this.storage.clearStore();
return await this.storage.clearStore();
}
async getAllKeys() {
@@ -107,10 +96,6 @@ export class KV {
);
return keys;
}
async writeMulti(items) {
return this.storage.setMultipleItemsAsync(items, "object");
}
}
const DefaultStorage = new KV(MMKV);
@@ -144,10 +129,8 @@ export default {
remove: (key) => DefaultStorage.remove(key),
clear: () => DefaultStorage.clear(),
getAllKeys: () => DefaultStorage.getAllKeys(),
writeMulti: (items) => DefaultStorage.writeMulti(items),
encrypt,
decrypt,
decryptMulti,
getRandomBytes,
checkAndCreateDir,
requestPermission,
@@ -155,6 +138,5 @@ export default {
getCryptoKey,
removeCryptoKey,
hash,
generateCryptoKey,
encryptMulti
generateCryptoKey
};

View File

@@ -22,7 +22,7 @@ import {
getFileNameWithExtension,
isImage,
isDocument
} from "@notesnook/core/dist/utils/filename";
} from "@notesnook/core/utils/filename";
import React from "react";
import { Platform } from "react-native";
import * as ScopedStorage from "react-native-scoped-storage";

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import hosts from "@notesnook/core/dist/utils/constants";
import hosts from "@notesnook/core/utils/constants";
import NetInfo from "@react-native-community/netinfo";
import RNFetchBlob from "react-native-blob-util";
import { ToastEvent } from "../../services/event-manager";

View File

@@ -21,7 +21,7 @@ import RNFetchBlob from "react-native-blob-util";
import { useAttachmentStore } from "../../stores/use-attachment-store";
import { DatabaseLogger, db } from "../database";
import { cacheDir } from "./utils";
import { isImage, isDocument } from "@notesnook/core/dist/utils/filename";
import { isImage, isDocument } from "@notesnook/core/utils/filename";
import { Platform } from "react-native";
import { IOS_APPGROUPID } from "../../utils/constants";
@@ -51,7 +51,6 @@ export async function uploadFile(filename, data, cancelToken) {
uploadFilePath = appGroupPath;
}
DatabaseLogger.info(`Starting upload: ${filename}`);
let request = RNFetchBlob.config({
IOSBackgroundTask: !globalThis["IS_SHARE_EXTENSION"]
})
@@ -67,11 +66,8 @@ export async function uploadFile(filename, data, cancelToken) {
useAttachmentStore
.getState()
.setProgress(sent, total, filename, 0, "upload");
DatabaseLogger.info(
`File upload progress: ${filename}, ${sent}/${total}`
);
DatabaseLogger.info(`uploading file: ${sent}/${total}`);
});
cancelToken.cancel = request.cancel;
let response = await request;
@@ -80,9 +76,6 @@ export async function uploadFile(filename, data, cancelToken) {
let result = status >= 200 && status < 300 && text.length === 0;
useAttachmentStore.getState().remove(filename);
if (result) {
DatabaseLogger.info(
`File upload status: ${filename}, ${status}, ${text}`
);
let attachment = db.attachments.attachment(filename);
if (!attachment) return result;
if (
@@ -91,15 +84,8 @@ export async function uploadFile(filename, data, cancelToken) {
) {
RNFetchBlob.fs.unlink(`${cacheDir}/${filename}`).catch(console.log);
}
} else {
const fileInfo = await RNFetchBlob.fs.stat(uploadFilePath);
throw new Error(
`${status}, ${text}, name: ${fileInfo.filename}, length: ${
fileInfo.size
}, info: ${JSON.stringify(response.info())}`
);
}
DatabaseLogger.info(`File uploaded: ${filename}`);
return result;
} catch (e) {
useAttachmentStore.getState().remove(filename);

View File

@@ -21,18 +21,18 @@ import React from "react";
import { FlatList, View } from "react-native";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useMessageStore } from "../../stores/use-message-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { allowedOnPlatform, renderItem } from "./functions";
export const Announcement = ({ color }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const announcements = useMessageStore((state) => state.announcements);
let announcement = announcements.length > 0 ? announcements[0] : null;
const selectionMode = useSelectionStore((state) => state.selectionMode);
return !announcement || selectionMode ? null : (
<View
style={{
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
width: "100%",
paddingHorizontal: 12,
paddingTop: 12,
@@ -44,26 +44,28 @@ export const Announcement = ({ color }) => {
width: "100%",
borderRadius: 10,
overflow: "hidden",
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
paddingBottom: 12
}}
>
<View
style={{
width: "100%",
marginTop: 12
}}
>
{announcement?.body
.filter((item) => allowedOnPlatform(item.platforms))
.map((item, index) =>
<View>
<FlatList
style={{
width: "100%",
marginTop: 12
}}
data={announcement?.body.filter((item) =>
allowedOnPlatform(item.platforms)
)}
renderItem={({ item, index }) =>
renderItem({
item: item,
index: index,
color: colors[color],
inline: true
})
)}
}
/>
</View>
</View>
</View>

View File

@@ -22,7 +22,7 @@ import { Linking, View } from "react-native";
//import SettingsBackupAndRestore from '../../screens/settings/backup-restore';
import { eSendEvent, presentSheet } from "../../services/event-manager";
import Sync from "../../services/sync";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { eCloseAnnouncementDialog, eCloseSheet } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
@@ -33,7 +33,7 @@ import { Button } from "../ui/button";
import { allowedOnPlatform, getStyle } from "./functions";
export const Cta = ({ actions, style = {}, color, inline }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
let buttons =
actions.filter((item) => allowedOnPlatform(item.platforms)) || [];
@@ -92,7 +92,8 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
style={{
height: 30,
alignSelf: "flex-start",
paddingHorizontal: 0
paddingHorizontal: 0,
marginTop: -6
}}
/>
))}
@@ -110,6 +111,7 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
style={{
alignSelf: "flex-start",
paddingHorizontal: 0,
marginTop: -6,
marginLeft: 12
}}
textStyle={{
@@ -127,11 +129,9 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
title={item.title}
fontSize={SIZE.md}
buttonType={{
color: color ? color : colors.primary.accent,
text: color
? colors.static.white
: colors.primary.accentForeground,
selected: color ? color : colors.primary.accent,
color: color ? color : colors.accent,
text: colors.light,
selected: color ? color : colors.accent,
opacity: 1
}}
onPress={() => onPress(item)}

View File

@@ -25,7 +25,7 @@ import {
eUnSubscribeEvent
} from "../../services/event-manager";
import { useMessageStore } from "../../stores/use-message-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import {
eCloseAnnouncementDialog,
eOpenAnnouncementDialog
@@ -35,7 +35,7 @@ import { allowedOnPlatform, renderItem } from "./functions";
import { useCallback } from "react";
export const AnnouncementDialog = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [info, setInfo] = useState(null);
const remove = useMessageStore((state) => state.remove);
@@ -73,7 +73,7 @@ export const AnnouncementDialog = () => {
<View
style={{
width: DDS.isTab ? 600 : "100%",
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
maxHeight: DDS.isTab ? "90%" : "100%",
borderRadius: DDS.isTab ? 10 : 0,
overflow: "hidden",

View File

@@ -24,7 +24,7 @@ import { db } from "../../common/database";
import { useAppState } from "../../hooks/use-app-state";
import BiometricService from "../../services/biometrics";
import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { useUserStore } from "../../stores/use-user-store";
import { NotesnookModule } from "../../utils/notesnook-module";
import { SIZE } from "../../utils/size";
@@ -36,7 +36,7 @@ import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
const AppLockedOverlay = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const user = useUserStore((state) => state.user);
const appLocked = useUserStore((state) => state.appLocked);
const lockApp = useUserStore((state) => state.lockApp);
@@ -100,7 +100,7 @@ const AppLockedOverlay = () => {
appLocked && (
<View
style={{
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
width: "100%",
height: "100%",
position: "absolute",
@@ -134,10 +134,10 @@ const AppLockedOverlay = () => {
marginTop: user ? 0 : 50
}}
onPress={onUnlockAppRequested}
color={colors.primary.border}
color={colors.border}
/>
<Heading
color={colors.primary.heading}
color={colors.heading}
style={{
alignSelf: "center",
textAlign: "center"
@@ -160,7 +160,7 @@ const AppLockedOverlay = () => {
style={{
width: "100%",
padding: 12,
backgroundColor: colors.primary.background
backgroundColor: colors.bg
}}
>
{user ? (

View File

@@ -33,7 +33,7 @@ import {
} from "../../services/event-manager";
import PremiumService from "../../services/premium";
import { useAttachmentStore } from "../../stores/use-attachment-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { eCloseAttachmentDialog, eCloseSheet } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
@@ -49,7 +49,7 @@ import Paragraph from "../ui/typography/paragraph";
import { formatBytes } from "@notesnook/common";
const Actions = ({ attachment, setAttachments, fwdRef }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const contextId = attachment.metadata.hash;
const [filename, setFilename] = useState(attachment.metadata.filename);
const [currentProgress] = useAttachmentProgress(attachment);
@@ -194,7 +194,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
<View
style={{
borderBottomWidth: 1,
borderBottomColor: colors.secondary.background,
borderBottomColor: colors.nav,
marginBottom: notes && notes.length > 0 ? 0 : 12
}}
>
@@ -219,7 +219,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
style={{
marginRight: 10
}}
color={colors.secondary.paragraph}
color={colors.icon}
>
{attachment.metadata.type}
</Paragraph>
@@ -228,7 +228,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
marginRight: 10
}}
size={SIZE.xs}
color={colors.secondary.paragraph}
color={colors.icon}
>
{formatBytes(attachment.length)}
</Paragraph>
@@ -239,7 +239,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
marginRight: 10
}}
size={SIZE.xs}
color={colors.secondary.paragraph}
color={colors.icon}
>
{attachment.noteIds.length} note
{attachment.noteIds.length > 1 ? "s" : ""}
@@ -255,7 +255,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
});
}}
size={SIZE.xs}
color={colors.secondary.paragraph}
color={colors.icon}
>
{attachment.metadata.hash}
</Paragraph>
@@ -268,7 +268,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
<View
style={{
borderBottomWidth: 1,
borderBottomColor: colors.secondary.background,
borderBottomColor: colors.nav,
marginBottom: 12,
paddingVertical: 12
}}
@@ -322,10 +322,10 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
key={item.name}
buttonType={{
text: item.on
? colors.primary.accent
? colors.accent
: item.name === "Delete" || item.name === "PermDelete"
? colors.error.paragraph
: colors.primary.paragraph
? colors.errorText
: colors.pri
}}
onPress={item.onPress}
title={item.name}

View File

@@ -17,14 +17,15 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { formatBytes } from "@notesnook/common";
import React from "react";
import { TouchableOpacity, View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { db } from "../../common/database";
import { useAttachmentProgress } from "../../hooks/use-attachment-progress";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { formatBytes } from "@notesnook/common";
import { SIZE } from "../../utils/size";
import SheetProvider from "../sheet-provider";
import { IconButton } from "../ui/icon-button";
import { ProgressCircleComponent } from "../ui/svg/lazy";
import Paragraph from "../ui/typography/paragraph";
@@ -40,17 +41,17 @@ export const AttachmentItem = ({
encryption,
setAttachments,
pressable = true,
hideWhenNotDownloading,
context
hideWhenNotDownloading
}) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [currentProgress, setCurrentProgress] = useAttachmentProgress(
attachment,
encryption
);
const onPress = () => {
if (!pressable) return;
Actions.present(attachment, setAttachments, context);
Actions.present(attachment, setAttachments, attachment.metadata.hash);
};
return hideWhenNotDownloading &&
@@ -65,10 +66,11 @@ export const AttachmentItem = ({
padding: 12,
paddingVertical: 6,
borderRadius: 5,
backgroundColor: colors.secondary.background
backgroundColor: colors.nav
}}
type="grayBg"
>
<SheetProvider context={attachment.metadata.hash} />
<View
style={{
flexShrink: 1,
@@ -83,12 +85,12 @@ export const AttachmentItem = ({
marginLeft: -5
}}
>
<Icon name="file" size={SIZE.xxxl} color={colors.primary.icon} />
<Icon name="file" size={SIZE.xxxl} color={colors.icon} />
<Paragraph
adjustsFontSizeToFit
size={6}
color={colors.static.white}
color={colors.light}
style={{
position: "absolute"
}}
@@ -111,13 +113,13 @@ export const AttachmentItem = ({
}}
numberOfLines={1}
lineBreakMode="middle"
color={colors.primary.paragraph}
color={colors.pri}
>
{attachment.metadata.filename}
</Paragraph>
{!hideWhenNotDownloading ? (
<Paragraph color={colors.secondary.paragraph} size={SIZE.xs}>
<Paragraph color={colors.icon} size={SIZE.xs}>
{formatBytes(attachment.length)}{" "}
{currentProgress?.type
? "(" + currentProgress.type + "ing - tap to cancel)"
@@ -149,7 +151,7 @@ export const AttachmentItem = ({
textStyle={{
fontSize: 10
}}
color={colors.primary.accent}
color={colors.accent}
formatText={(progress) => (progress * 100).toFixed(0)}
borderWidth={0}
thickness={2}
@@ -161,7 +163,7 @@ export const AttachmentItem = ({
<IconButton
onPress={onPress}
name="alert-circle-outline"
color={colors.error.paragraph}
color={colors.errorText}
/>
) : null}
</>

View File

@@ -26,12 +26,12 @@ import { Button } from "../ui/button";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
import { ProgressBarComponent } from "../ui/svg/lazy";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { FlatList } from "react-native-actions-sheet";
import { AttachmentItem } from "./attachment-item";
const DownloadAttachments = ({ close, attachments, isNote, update }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [downloading, setDownloading] = useState(false);
const [progress, setProgress] = useState({
value: 0,
@@ -158,8 +158,8 @@ const DownloadAttachments = ({ close, attachments, isNote, update }) => {
animated={true}
useNativeDriver
progress={progress.value ? progress.value / attachments.length : 0}
unfilledColor={colors.secondary.background}
color={colors.primary.accent}
unfilledColor={colors.nav}
color={colors.accent}
borderWidth={0}
/>
</View>
@@ -170,7 +170,7 @@ const DownloadAttachments = ({ close, attachments, isNote, update }) => {
maxHeight: 300,
width: "100%",
minHeight: 60,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
marginVertical: 12
}}
@@ -184,9 +184,7 @@ const DownloadAttachments = ({ close, attachments, isNote, update }) => {
height: 60
}}
>
<Paragraph color={colors.secondary.paragraph}>
No downloads in progress.
</Paragraph>
<Paragraph color={colors.icon}>No downloads in progress.</Paragraph>
</View>
}
keyExtractor={(item) => item.id}

View File

@@ -24,7 +24,7 @@ import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { db } from "../../common/database";
import filesystem from "../../common/filesystem";
import { presentSheet } from "../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import SheetProvider from "../sheet-provider";
import { IconButton } from "../ui/icon-button";
@@ -40,12 +40,12 @@ import {
isDocument,
isImage,
isVideo
} from "@notesnook/core/dist/utils/filename";
} from "@notesnook/core/utils/filename";
import { useSettingStore } from "../../stores/use-setting-store";
import { FlashList } from "react-native-actions-sheet/dist/src/views/FlashList";
export const AttachmentDialog = ({ note }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const { height } = useSettingStore((state) => state.dimensions);
const [attachments, setAttachments] = useState(
note
@@ -82,11 +82,7 @@ export const AttachmentDialog = ({ note }) => {
};
const renderItem = ({ item }) => (
<AttachmentItem
setAttachments={setAttachments}
attachment={item}
context="attachments-list"
/>
<AttachmentItem setAttachments={setAttachments} attachment={item} />
);
const onCheck = async () => {
@@ -201,7 +197,7 @@ export const AttachmentDialog = ({ note }) => {
width: 40,
marginRight: 10
}}
color={colors.primary.paragraph}
color={colors.pri}
size={SIZE.lg}
onPress={onCheck}
/>
@@ -213,7 +209,7 @@ export const AttachmentDialog = ({ note }) => {
height: 40,
width: 40
}}
color={colors.primary.paragraph}
color={colors.pri}
onPress={() => {
DownloadAttachments.present(
"attachments-list",
@@ -241,7 +237,7 @@ export const AttachmentDialog = ({ note }) => {
width: "100%",
height: 50,
flexDirection: "row",
backgroundColor: colors.primary.background
backgroundColor: colors.bg
}}
contentContainerStyle={{
minWidth: "100%",
@@ -264,7 +260,7 @@ export const AttachmentDialog = ({ note }) => {
borderBottomColor:
currentFilter !== item.filterBy
? "transparent"
: colors.primary.accent
: colors.accent
}}
onPress={() => {
setCurrentFilter(item.filterBy);
@@ -285,7 +281,7 @@ export const AttachmentDialog = ({ note }) => {
alignItems: "center"
}}
>
<Icon name="attachment" size={60} color={colors.secondary.icon} />
<Icon name="attachment" size={60} color={colors.icon} />
<Paragraph>
{note ? "No attachments on this note" : "No attachments"}
</Paragraph>
@@ -304,18 +300,14 @@ export const AttachmentDialog = ({ note }) => {
/>
<Paragraph
color={colors.secondary.paragraph}
color={colors.icon}
size={SIZE.xs}
style={{
textAlign: "center",
marginTop: 10
}}
>
<Icon
name="shield-key-outline"
size={SIZE.xs}
color={colors.primary.icon}
/>
<Icon name="shield-key-outline" size={SIZE.xs} color={colors.icon} />
{" "}All attachments are end-to-end encrypted.
</Paragraph>
</View>

View File

@@ -24,7 +24,7 @@ import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { eCloseLoginDialog, eOpenLoginDialog } from "../../utils/events";
import { sleep } from "../../utils/time";
import BaseDialog from "../dialog/base-dialog";
@@ -44,7 +44,7 @@ export const AuthMode = {
};
const AuthModal = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [currentAuthMode, setCurrentAuthMode] = useState(AuthMode.login);
const actionSheetRef = useRef();
@@ -82,7 +82,7 @@ const AuthModal = () => {
onClose={close}
useSafeArea={false}
bounce={false}
background={colors.primary.background}
background={colors.bg}
transparent={false}
animated={false}
>
@@ -90,7 +90,11 @@ const AuthModal = () => {
style={{
width: "100%"
}}
contentContainerStyle={{
height: Platform.OS === "android" ? "100%" : "100%"
}}
keyboardShouldPersistTaps="handled"
bounces={false}
>
{currentAuthMode !== AuthMode.login ? (
<Signup
@@ -112,7 +116,7 @@ const AuthModal = () => {
paddingTop: Platform.OS === "android" ? 0 : insets.top,
top: 0,
zIndex: 999,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
width: "100%"
}}
>
@@ -135,7 +139,7 @@ const AuthModal = () => {
onPress={() => {
hideAuth();
}}
color={colors.primary.paragraph}
color={colors.pri}
/>
)}

View File

@@ -24,7 +24,7 @@ import { db } from "../../common/database";
import { DDS } from "../../services/device-detection";
import { ToastEvent } from "../../services/event-manager";
import SettingsService from "../../services/settings";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import DialogHeader from "../dialog/dialog-header";
import { Button } from "../ui/button";
import { IconButton } from "../ui/icon-button";
@@ -34,7 +34,7 @@ import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
export const ForgotPassword = () => {
const { colors } = useThemeColors("sheet");
const colors = useThemeStore((state) => state.colors);
const email = useRef();
const emailInputRef = useRef();
const [error, setError] = useState(false);
@@ -117,7 +117,7 @@ export const ForgotPassword = () => {
width: null,
height: null
}}
color={colors.primary.accent}
color={colors.accent}
name="email"
size={50}
/>
@@ -134,7 +134,7 @@ export const ForgotPassword = () => {
<View
style={{
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
zIndex: 10,
width: "100%",
padding: 12

View File

@@ -65,7 +65,7 @@ const Auth = ({ navigation, route }) => {
onPress={() => {
hideAuth();
}}
color={colors.primary.paragraph}
color={colors.pri}
customStyle={{
position: 'absolute',
zIndex: 999,

View File

@@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useEffect, useState } from "react";
import { TouchableOpacity, View, useWindowDimensions } from "react-native";
import { TouchableOpacity, View } from "react-native";
import { SheetManager } from "react-native-actions-sheet";
import { DDS } from "../../services/device-detection";
import { eSendEvent } from "../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
import SheetProvider from "../sheet-provider";
@@ -46,7 +46,7 @@ const LoginSteps = {
};
export const Login = ({ changeMode }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [focused, setFocused] = useState(false);
const {
step,
@@ -71,7 +71,7 @@ export const Login = ({ changeMode }) => {
}, 5000);
});
const deviceMode = useSettingStore((state) => state.deviceMode);
const { width, height } = useWindowDimensions();
useEffect(() => {
async () => {
setStep(LoginSteps.emailAuth);
@@ -92,27 +92,29 @@ export const Login = ({ changeMode }) => {
<View
style={{
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
zIndex: 10,
width: "100%",
alignSelf: "center"
alignSelf: "center",
height: "100%",
minHeight: "100%"
}}
>
<View
style={{
flexGrow: 0.8,
justifyContent: "flex-end",
paddingHorizontal: 20,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderBottomWidth: 1,
marginBottom: 12,
borderBottomColor: colors.primary.border,
borderBottomColor: colors.border,
alignSelf: deviceMode !== "mobile" ? "center" : undefined,
borderWidth: deviceMode !== "mobile" ? 1 : null,
borderColor: deviceMode !== "mobile" ? colors.primary.border : null,
borderColor: deviceMode !== "mobile" ? colors.border : null,
borderRadius: deviceMode !== "mobile" ? 20 : null,
marginTop: deviceMode !== "mobile" ? 50 : null,
width: deviceMode === "mobile" ? null : "50%",
minHeight: height * 0.4
width: deviceMode === "mobile" ? null : "50%"
}}
>
<View
@@ -124,7 +126,7 @@ export const Login = ({ changeMode }) => {
style={{
width: 100,
height: 5,
backgroundColor: colors.primary.accent,
backgroundColor: colors.accent,
borderRadius: 2,
marginRight: 7
}}
@@ -134,7 +136,7 @@ export const Login = ({ changeMode }) => {
style={{
width: 20,
height: 5,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 2
}}
/>
@@ -160,9 +162,10 @@ export const Login = ({ changeMode }) => {
: focused
? "100%"
: "99.9%",
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
alignSelf: "center",
paddingHorizontal: 20
paddingHorizontal: 20,
flexGrow: 1
}}
>
<Input
@@ -281,14 +284,11 @@ export const Login = ({ changeMode }) => {
paddingVertical: 12
}}
>
<Paragraph
size={SIZE.xs + 1}
color={colors.secondary.paragraph}
>
<Paragraph size={SIZE.xs + 1} color={colors.icon}>
Don't have an account?{" "}
<Paragraph
size={SIZE.xs + 1}
style={{ color: colors.primary.accent }}
style={{ color: colors.accent }}
>
Sign up
</Paragraph>

View File

@@ -17,22 +17,18 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
import { Modal, View } from "react-native";
import { db } from "../../common/database";
import { MMKV } from "../../common/database/mmkv";
import BiometricService from "../../services/biometrics";
import {
ToastEvent,
eSendEvent,
eSubscribeEvent
} from "../../services/event-manager";
import { setLoginMessage } from "../../services/message";
import SettingsService from "../../services/settings";
import Sync from "../../services/sync";
import { clearAllStores } from "../../stores";
import { useUserStore } from "../../stores/use-user-store";
import { useThemeStore } from "../../stores/use-theme-store";
import { eLoginSessionExpired, eUserLoggedIn } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
@@ -60,7 +56,7 @@ function getObfuscatedEmail(email) {
}
export const SessionExpired = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [focused, setFocused] = useState(false);
const { step, password, email, passwordInputRef, loading, login } = useLogin(
@@ -75,12 +71,9 @@ export const SessionExpired = () => {
try {
await db.user.logout();
await BiometricService.resetCredentials();
setLoginMessage();
SettingsService.resetSettings();
useUserStore.getState().setUser(null);
useUserStore.getState().setSyncing(false);
MMKV.clearStore();
clearAllStores();
SettingsService.set({
introCompleted: true
});
setVisible(false);
} catch (e) {
ToastEvent.show({
@@ -145,7 +138,7 @@ export const SessionExpired = () => {
padding: 12,
justifyContent: "center",
flex: 1,
backgroundColor: colors.primary.background
backgroundColor: colors.bg
}}
>
<View
@@ -164,10 +157,10 @@ export const SessionExpired = () => {
height: 60
}}
name="alert"
color={colors.error.icon}
color={colors.errorText}
size={50}
/>
<Heading size={SIZE.xxxl} color={colors.primary.heading}>
<Heading size={SIZE.xxxl} color={colors.heading}>
Session expired
</Heading>
<Paragraph

View File

@@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { useRef, useState } from "react";
import { TouchableOpacity, View, useWindowDimensions } from "react-native";
import { TouchableOpacity, View } from "react-native";
import { db } from "../../common/database";
import { DDS } from "../../services/device-detection";
import { ToastEvent } from "../../services/event-manager";
import { clearMessage, setEmailVerifyMessage } from "../../services/message";
import PremiumService from "../../services/premium";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { useUserStore } from "../../stores/use-user-store";
import { openLinkInBrowser } from "../../utils/functions";
import { SIZE } from "../../utils/size";
@@ -37,7 +37,7 @@ import { hideAuth } from "./common";
import { useSettingStore } from "../../stores/use-setting-store";
export const Signup = ({ changeMode, trial }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const email = useRef();
const emailInputRef = useRef();
const passwordInputRef = useRef();
@@ -49,7 +49,7 @@ export const Signup = ({ changeMode, trial }) => {
const setUser = useUserStore((state) => state.setUser);
const setLastSynced = useUserStore((state) => state.setLastSynced);
const deviceMode = useSettingStore((state) => state.deviceMode);
const { width, height } = useWindowDimensions();
const validateInfo = () => {
if (!password.current || !email.current || !confirmPassword.current) {
ToastEvent.show({
@@ -67,7 +67,6 @@ export const Signup = ({ changeMode, trial }) => {
const signup = async () => {
if (!validateInfo() || error) return;
if (loading) return;
setLoading(true);
try {
await db.user.signup(email.current.toLowerCase(), password.current);
@@ -99,27 +98,28 @@ export const Signup = ({ changeMode, trial }) => {
<View
style={{
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
zIndex: 10,
width: "100%",
alignSelf: "center"
alignSelf: "center",
height: "100%"
}}
>
<View
style={{
flexGrow: 1,
justifyContent: "flex-end",
paddingHorizontal: 20,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
marginBottom: 20,
borderBottomWidth: 1,
borderBottomColor: colors.primary.border,
borderBottomColor: colors.border,
alignSelf: deviceMode !== "mobile" ? "center" : undefined,
borderWidth: deviceMode !== "mobile" ? 1 : null,
borderColor: deviceMode !== "mobile" ? colors.primary.border : null,
borderColor: deviceMode !== "mobile" ? colors.border : null,
borderRadius: deviceMode !== "mobile" ? 20 : null,
marginTop: deviceMode !== "mobile" ? 50 : null,
width: deviceMode === "mobile" ? null : "50%",
minHeight: height * 0.4
width: deviceMode === "mobile" ? null : "50%"
}}
>
<View
@@ -131,7 +131,7 @@ export const Signup = ({ changeMode, trial }) => {
style={{
width: 100,
height: 5,
backgroundColor: colors.primary.accent,
backgroundColor: colors.accent,
borderRadius: 2,
marginRight: 7
}}
@@ -141,7 +141,7 @@ export const Signup = ({ changeMode, trial }) => {
style={{
width: 20,
height: 5,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 2
}}
/>
@@ -162,8 +162,9 @@ export const Signup = ({ changeMode, trial }) => {
style={{
width: DDS.isTab ? "50%" : "100%",
paddingHorizontal: 20,
backgroundColor: colors.primary.background,
alignSelf: "center"
backgroundColor: colors.bg,
alignSelf: "center",
flexGrow: 0.5
}}
>
<Input
@@ -231,7 +232,7 @@ export const Signup = ({ changeMode, trial }) => {
marginBottom: 25
}}
size={SIZE.xs}
color={colors.secondary.paragraph}
color={colors.icon}
>
By signing up, you agree to our{" "}
<Paragraph
@@ -242,7 +243,7 @@ export const Signup = ({ changeMode, trial }) => {
style={{
textDecorationLine: "underline"
}}
color={colors.primary.accent}
color={colors.accent}
>
Terms of Service{" "}
</Paragraph>
@@ -255,7 +256,7 @@ export const Signup = ({ changeMode, trial }) => {
style={{
textDecorationLine: "underline"
}}
color={colors.primary.accent}
color={colors.accent}
>
Privacy Policy.
</Paragraph>{" "}
@@ -288,12 +289,9 @@ export const Signup = ({ changeMode, trial }) => {
paddingVertical: 12
}}
>
<Paragraph size={SIZE.xs + 1} color={colors.secondary.paragraph}>
<Paragraph size={SIZE.xs + 1} color={colors.icon}>
Already have an account?{" "}
<Paragraph
size={SIZE.xs + 1}
style={{ color: colors.primary.accent }}
>
<Paragraph size={SIZE.xs + 1} style={{ color: colors.accent }}>
Login
</Paragraph>
</Paragraph>

View File

@@ -26,7 +26,7 @@ import {
presentSheet,
ToastEvent
} from "../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { eCloseSheet } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { Button } from "../ui/button";
@@ -39,7 +39,7 @@ import Paragraph from "../ui/typography/paragraph";
import { useCallback } from "react";
const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const code = useRef();
const [currentMethod, setCurrentMethod] = useState({
method: mfaInfo?.primaryMethod,
@@ -157,7 +157,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
}}
size={50}
name="key"
color={colors.primary.accent}
color={colors.accent}
/>
<Heading
style={{
@@ -214,7 +214,6 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
code.current = value;
//onNext();
}}
caretHidden
inputStyle={{
fontSize: SIZE.lg,
height: 60,
@@ -282,7 +281,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
marginRight: 10
}}
size={15}
color={colors.primary.accent}
color={colors.accent}
name={item.icon}
/>
<View

View File

@@ -64,7 +64,6 @@ export const useLogin = (onFinishLogin) => {
const login = async () => {
if (!validateInfo() || error) return;
try {
if (loading) return;
setLoading(true);
switch (step) {
case LoginSteps.emailAuth: {

View File

@@ -17,24 +17,24 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { PropsWithChildren } from "react";
import React from "react";
import { View } from "react-native";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
export const ContainerHeader = (props: PropsWithChildren) => {
const { colors } = useThemeColors();
export const ContainerHeader = ({ children }) => {
const colors = useThemeStore((state) => state.colors);
const selectionMode = useSelectionStore((state) => state.selectionMode);
return !selectionMode ? (
<View
style={{
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
width: "100%",
overflow: "hidden"
}}
>
{props.children}
{children}
</View>
) : null;
};

View File

@@ -17,9 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React, { useCallback, useEffect } from "react";
import { Keyboard, View } from "react-native";
import { Keyboard, Platform, View } from "react-native";
import Animated, {
Easing,
useAnimatedStyle,
@@ -36,20 +35,12 @@ import { SIZE, normalize } from "../../utils/size";
import NativeTooltip from "../../utils/tooltip";
import { PressableButton } from "../ui/pressable";
interface FloatingButton {
title?: string;
onPress: () => void;
color?: string;
alwaysVisible?: boolean;
}
const FloatingButton = ({
export const FloatingButton = ({
title,
onPress,
color,
alwaysVisible = false
}: FloatingButton) => {
const { colors } = useThemeColors();
color = "accent",
shouldShow = false
}) => {
const deviceMode = useSettingStore((state) => state.deviceMode);
const selectionMode = useSelectionStore((state) => state.selectionMode);
const translate = useSharedValue(0);
@@ -67,8 +58,12 @@ const FloatingButton = ({
};
});
useEffect(() => {
animate(selectionMode ? 150 : 0);
}, [animate, selectionMode]);
const animate = useCallback(
(toValue: number) => {
(toValue) => {
translate.value = withTiming(toValue, {
duration: 250,
easing: Easing.elastic(1)
@@ -77,39 +72,39 @@ const FloatingButton = ({
[translate]
);
useEffect(() => {
animate(selectionMode ? 150 : 0);
}, [animate, selectionMode]);
const onKeyboardHide = useCallback(async () => {
editorState().keyboardState = false;
if (deviceMode !== "mobile") return;
animate(0);
}, [animate, deviceMode]);
const onKeyboardShow = useCallback(async () => {
editorState().keyboardState = true;
if (deviceMode !== "mobile") return;
animate(150);
}, [animate, deviceMode]);
useEffect(() => {
const onKeyboardHide = () => {
editorState().keyboardState = false;
if (deviceMode !== "mobile") return;
animate(0);
};
const onKeyboardShow = () => {
editorState().keyboardState = true;
if (deviceMode !== "mobile") return;
animate(150);
};
const sub = [
Keyboard.addListener("keyboardDidShow", onKeyboardShow),
Keyboard.addListener("keyboardDidHide", onKeyboardHide)
];
let sub1 = Keyboard.addListener("keyboardDidShow", onKeyboardShow);
let sub2 = Keyboard.addListener("keyboardDidHide", onKeyboardHide);
return () => {
sub.forEach((sub) => sub?.remove?.());
sub1?.remove();
sub2?.remove();
};
}, [deviceMode, animate]);
}, [deviceMode, onKeyboardHide, onKeyboardShow]);
const paddings = {
ios: 20,
android: 20,
iPad: 20
};
return deviceMode !== "mobile" && !alwaysVisible ? null : (
return deviceMode !== "mobile" && !shouldShow ? null : (
<Animated.View
style={[
{
position: "absolute",
right: 12,
bottom: 20,
bottom: paddings[Platform.isPad ? "iPad" : Platform.OS],
zIndex: 10
},
animatedStyle
@@ -118,15 +113,14 @@ const FloatingButton = ({
<PressableButton
testID={notesnook.buttons.add}
type="accent"
accentColor={colors.static[color as keyof typeof colors.static]}
accentColor={color || "accent"}
accentText="light"
customStyle={{
...getElevationStyle(5),
borderRadius: 100
}}
onLongPress={(event) => {
if (title) {
NativeTooltip.show(event, title, NativeTooltip.POSITIONS.LEFT);
}
NativeTooltip.show(event, title, NativeTooltip.POSITIONS.LEFT);
}}
onPress={onPress}
>
@@ -140,7 +134,7 @@ const FloatingButton = ({
>
<Icon
name={title === "Clear all trash" ? "delete" : "plus"}
color={colors.primary.accentForeground}
color="white"
size={SIZE.xxl}
/>
</View>
@@ -148,5 +142,3 @@ const FloatingButton = ({
</Animated.View>
);
};
export { FloatingButton };

View File

@@ -17,40 +17,44 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { PropsWithChildren } from "react";
import { KeyboardAvoidingView, Platform } from "react-native";
import React from "react";
import { KeyboardAvoidingView, Platform, View } from "react-native";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import useIsFloatingKeyboard from "../../hooks/use-is-floating-keyboard";
import { useSettingStore } from "../../stores/use-setting-store";
import { Header } from "../header";
import SelectionHeader from "../selection-header";
export const Container = ({ children }: PropsWithChildren) => {
export const Container = ({ children }) => {
const floating = useIsFloatingKeyboard();
const introCompleted = useSettingStore(
(state) => state.settings.introCompleted
);
const insets = useGlobalSafeAreaInsets();
return (
<KeyboardAvoidingView
behavior="padding"
enabled={Platform.OS === "ios" && !floating}
style={{
flex: 1,
overflow: "hidden",
paddingTop: Platform.OS === "android" ? 0 : insets.top,
paddingBottom: Platform.OS === "android" ? 0 : insets.bottom
flex: 1
}}
>
{!introCompleted ? null : (
<>
<SelectionHeader />
<Header />
</>
)}
<View
style={{
flex: 1,
overflow: "hidden",
paddingTop: Platform.OS === "android" ? 0 : insets.top,
paddingBottom: Platform.OS === "android" ? 0 : insets.bottom
}}
>
{!introCompleted ? null : (
<>
<SelectionHeader />
<Header title="Header" screen="Header" />
</>
)}
{children}
{children}
</View>
</KeyboardAvoidingView>
);
};

View File

@@ -20,21 +20,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { View } from "react-native";
import { useMessageStore } from "../../stores/use-message-store";
import { useThemeColors } from "@notesnook/theme";
import { ColorValues } from "../../utils/colors";
import { hexToRGBA } from "../../utils/colors";
import { useThemeStore } from "../../stores/use-theme-store";
import { COLORS_NOTE } from "../../utils/color-scheme";
import { hexToRGBA } from "../../utils/color-scheme/utils";
export const DefaultPlaceholder = ({ color }: { color: string }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const message = useMessageStore((state) => state.message);
const annoucements = useMessageStore((state) => state.announcements);
const hasAnnoucements = annoucements.length > 0;
const shadeColor = color
? hexToRGBA(
ColorValues[color?.toLowerCase() as keyof typeof ColorValues],
COLORS_NOTE[color?.toLowerCase() as keyof typeof COLORS_NOTE],
0.15
)
: colors.primary.shade;
: colors.shade;
return (
<View
@@ -50,7 +50,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
height: 100,
borderRadius: 10,
marginBottom: 20,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
padding: 12
}}
>
@@ -58,7 +58,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 150,
height: 20,
backgroundColor: colors.primary.hover,
backgroundColor: colors.transGray,
borderRadius: 5,
marginBottom: 10
}}
@@ -67,7 +67,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 250,
height: 14,
backgroundColor: colors.primary.hover,
backgroundColor: colors.transGray,
borderRadius: 5
}}
/>
@@ -110,7 +110,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 150,
height: 12,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
marginBottom: 10
}}
@@ -119,7 +119,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 250,
height: 16,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5
}}
/>
@@ -131,7 +131,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: "100%",
height: 30,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 10,
marginBottom: 20,
padding: 5,
@@ -158,7 +158,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 15,
height: 15,
backgroundColor: colors.primary.hover,
backgroundColor: colors.transGray,
borderRadius: 100,
marginRight: 10
}}
@@ -167,7 +167,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 60,
height: 15,
backgroundColor: colors.primary.hover,
backgroundColor: colors.transGray,
borderRadius: 3
}}
/>
@@ -178,7 +178,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 200,
height: 16,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5
}}
/>
@@ -186,7 +186,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: "85%",
height: 13,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
marginTop: 10
}}
@@ -202,7 +202,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 50,
height: 10,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5
}}
/>
@@ -210,7 +210,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
style={{
width: 60,
height: 10,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
marginLeft: 10
}}

View File

@@ -21,7 +21,7 @@ import React from "react";
import { ViewProps } from "react-native";
import Animated, { FadeOutUp } from "react-native-reanimated";
import { useDelayLayout } from "../../hooks/use-delay-layout";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { DefaultPlaceholder } from "./default-placeholder";
import { SettingsPlaceholder } from "./settings-placeholder";
@@ -42,7 +42,7 @@ export default function DelayLayout({
animated = true,
...props
}: IDelayLayoutProps) {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const loading = useDelayLayout(
!props.delay || props.delay < 300 ? 300 : props.delay
);
@@ -52,12 +52,12 @@ export default function DelayLayout({
<Animated.View
exiting={animated ? FadeOutUp : undefined}
style={{
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
flex: 1,
paddingTop: 20
}}
>
<Placeholder color={props.color || colors.primary.accent} />
<Placeholder color={props.color || colors.accent} />
</Animated.View>
) : (
<>{props.children}</>

View File

@@ -19,10 +19,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { View } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
export const SettingsPlaceholder = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
return (
<View>
@@ -30,7 +30,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 100,
height: 12,
backgroundColor: colors.primary.shade,
backgroundColor: colors.shade,
borderRadius: 5,
marginLeft: 12,
marginBottom: 12
@@ -51,7 +51,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 40,
height: 40,
backgroundColor: colors.primary.hover,
backgroundColor: colors.transGray,
borderRadius: 100,
marginRight: 20
}}
@@ -61,7 +61,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 150,
height: 12,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
marginBottom: 10
}}
@@ -70,7 +70,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 250,
height: 16,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5
}}
/>
@@ -93,7 +93,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 40,
height: 40,
backgroundColor: colors.primary.shade,
backgroundColor: colors.shade,
borderRadius: 100,
marginRight: 20
}}
@@ -103,7 +103,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 150,
height: 12,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
marginBottom: 10
}}
@@ -112,7 +112,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 250,
height: 16,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5
}}
/>
@@ -122,7 +122,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 40,
height: 20,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 100,
marginLeft: 15,
alignItems: "flex-end",
@@ -134,7 +134,7 @@ export const SettingsPlaceholder = () => {
style={{
width: 15,
height: 15,
backgroundColor: colors.primary.shade,
backgroundColor: colors.shade,
borderRadius: 100,
marginLeft: 15
}}

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { useNoteStore } from "../../stores/use-notes-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { AnnouncementDialog } from "../announcements";
import AuthModal from "../auth/auth-modal";
import { SessionExpired } from "../auth/session-expired";
@@ -39,7 +39,7 @@ import RestoreDataSheet from "../sheets/restore-data";
import PDFPreview from "../dialogs/pdf-preview";
const DialogProvider = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const loading = useNoteStore((state) => state.loading);
return (

View File

@@ -30,7 +30,6 @@ import {
import useIsFloatingKeyboard from "../../hooks/use-is-floating-keyboard";
import { useSettingStore } from "../../stores/use-setting-store";
import { BouncingView } from "../ui/transitions/bouncing-view";
import { ScopedThemeProvider } from "@notesnook/theme";
const BaseDialog = ({
visible,
@@ -61,71 +60,69 @@ const BaseDialog = ({
const Wrapper = useSafeArea ? SafeAreaView : View;
return (
<ScopedThemeProvider value="dialog">
<Modal
visible={visible}
transparent={true}
animated
statusBarTranslucent={statusBarTranslucent}
supportedOrientations={[
"portrait",
"portrait-upside-down",
"landscape",
"landscape-left",
"landscape-right"
]}
onShow={() => {
if (onShow) {
onShow();
useSettingStore.getState().setSheetKeyboardHandler(false);
}
}}
animationType={animation}
onRequestClose={() => {
if (!closeOnTouch) return null;
useSettingStore.getState().setSheetKeyboardHandler(true);
onRequestClose && onRequestClose();
<Modal
visible={visible}
transparent={true}
animated
statusBarTranslucent={statusBarTranslucent}
supportedOrientations={[
"portrait",
"portrait-upside-down",
"landscape",
"landscape-left",
"landscape-right"
]}
onShow={() => {
if (onShow) {
onShow();
useSettingStore.getState().setSheetKeyboardHandler(false);
}
}}
animationType={animation}
onRequestClose={() => {
if (!closeOnTouch) return null;
useSettingStore.getState().setSheetKeyboardHandler(true);
onRequestClose && onRequestClose();
}}
>
<Wrapper
style={{
backgroundColor: background
? background
: transparent
? "transparent"
: "rgba(0,0,0,0.3)"
}}
>
<Wrapper
style={{
backgroundColor: background
? background
: transparent
? "transparent"
: "rgba(0,0,0,0.3)"
}}
<KeyboardAvoidingView
enabled={!floating && Platform.OS === "ios" && !avoidKeyboardResize}
behavior="padding"
>
<KeyboardAvoidingView
enabled={!floating && Platform.OS === "ios" && !avoidKeyboardResize}
behavior="padding"
<BouncingView
duration={400}
animated={animated}
initialScale={bounce ? 0.9 : 1}
style={[
styles.backdrop,
{
justifyContent: centered
? "center"
: bottom
? "flex-end"
: "flex-start"
}
]}
>
<BouncingView
duration={400}
animated={animated}
initialScale={bounce ? 0.9 : 1}
style={[
styles.backdrop,
{
justifyContent: centered
? "center"
: bottom
? "flex-end"
: "flex-start"
}
]}
>
<TouchableOpacity
onPress={closeOnTouch ? onRequestClose : null}
style={styles.overlayButton}
/>
{premium}
{children}
</BouncingView>
</KeyboardAvoidingView>
</Wrapper>
</Modal>
</ScopedThemeProvider>
<TouchableOpacity
onPress={closeOnTouch ? onRequestClose : null}
style={styles.overlayButton}
/>
{premium}
{children}
</BouncingView>
</KeyboardAvoidingView>
</Wrapper>
</Modal>
);
};

View File

@@ -21,7 +21,7 @@ import React from "react";
import { ActivityIndicator, StyleSheet, View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { notesnook } from "../../../e2e/test.ids";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { Button } from "../ui/button";
import Paragraph from "../ui/typography/paragraph";
@@ -35,14 +35,14 @@ const DialogButtons = ({
doneText,
positiveType
}) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
return (
<View
style={[
styles.container,
{
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
height: 60,
borderBottomRightRadius: 10,
borderBottomLeftRadius: 10,
@@ -51,7 +51,7 @@ const DialogButtons = ({
]}
>
{loading ? (
<ActivityIndicator color={colors.primary.accent} size={SIZE.lg} />
<ActivityIndicator color={colors.accent} size={SIZE.lg} />
) : doneText ? (
<View
style={{
@@ -60,11 +60,11 @@ const DialogButtons = ({
}}
>
<Icon
color={colors.primary.accent}
color={colors.accent}
name="check-circle-outline"
size={SIZE.md}
/>
<Paragraph color={colors.primary.accent}>{" " + doneText}</Paragraph>
<Paragraph color={colors.accent}>{" " + doneText}</Paragraph>
</View>
) : (
<View />

View File

@@ -20,11 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { View } from "react-native";
import { DDS } from "../../services/device-detection";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { getElevationStyle } from "../../utils/elevation";
const DialogContainer = ({ width, height, ...restProps }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
return (
<View
@@ -34,7 +34,7 @@ const DialogContainer = ({ width, height, ...restProps }) => {
width: width || DDS.isTab ? 500 : "85%",
maxHeight: height || 450,
borderRadius: 10,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
paddingTop: 12
}}
/>

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { Text, View, ViewStyle } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { Button } from "../ui/button";
import { PressableButtonProps } from "../ui/pressable";
@@ -54,7 +54,7 @@ const DialogHeader = ({
titlePart,
style
}: DialogHeaderProps) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
return (
<>
@@ -86,7 +86,7 @@ const DialogHeader = ({
>
{title}{" "}
{titlePart ? (
<Text style={{ color: colors.primary.accent }}>{titlePart}</Text>
<Text style={{ color: colors.accent }}>{titlePart}</Text>
) : null}
</Heading>
@@ -114,7 +114,7 @@ const DialogHeader = ({
maxWidth: centered ? "90%" : "100%",
alignSelf: centered ? "center" : "flex-start"
}}
color={paragraphColor || colors.secondary.paragraph}
color={paragraphColor || colors.icon}
>
{paragraph}
</Paragraph>

View File

@@ -24,7 +24,7 @@ import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { getElevationStyle } from "../../utils/elevation";
import { eCloseSimpleDialog, eOpenSimpleDialog } from "../../utils/events";
import { sleep } from "../../utils/time";
@@ -38,7 +38,7 @@ import { useCallback } from "react";
import { Button } from "../ui/button";
export const Dialog = ({ context = "global" }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [inputValue, setInputValue] = useState(null);
const inputRef = useRef();
@@ -51,7 +51,7 @@ export const Dialog = ({ context = "global" }) => {
onClose: () => {},
positiveType: "transparent",
icon: null,
paragraphColor: colors.primary.paragraph,
paragraphColor: colors.pri,
input: false,
inputPlaceholder: "Enter some text",
defaultValue: "",
@@ -115,7 +115,7 @@ export const Dialog = ({ context = "global" }) => {
width: DDS.isTab ? 400 : "85%",
maxHeight: 450,
borderRadius: 5,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
paddingTop: 12
};

View File

@@ -25,7 +25,7 @@ import {
eUnSubscribeEvent
} from "../../../services/event-manager";
import { useMessageStore } from "../../../stores/use-message-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import { getElevationStyle } from "../../../utils/elevation";
import {
eCloseJumpToDialog,
@@ -41,10 +41,10 @@ import { useCallback } from "react";
const offsets = [];
let timeout = null;
const JumpToSectionDialog = ({ scrollRef, data, type }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const notes = data;
const [visible, setVisible] = useState(false);
const [currentIndex, setCurrentIndex] = useState(0);
const [currentIndex, setCurrentIndex] = useState(null);
const onPress = (item) => {
let ind = notes.findIndex(
@@ -77,7 +77,7 @@ const JumpToSectionDialog = ({ scrollRef, data, type }) => {
}
timeout = setTimeout(() => {
let index = offsets.findIndex((o, i) => o <= y && offsets[i + 1] > y);
setCurrentIndex(index || 0);
setCurrentIndex(index);
}, 200);
};
@@ -113,6 +113,7 @@ const JumpToSectionDialog = ({ scrollRef, data, type }) => {
offsets.push(offset);
});
}, [notes]);
return !visible ? null : (
<BaseDialog
onShow={() => {
@@ -125,7 +126,7 @@ const JumpToSectionDialog = ({ scrollRef, data, type }) => {
style={{
...getElevationStyle(5),
width: DDS.isTab ? 500 : "85%",
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
zIndex: 100,
bottom: 20,
maxHeight: "65%",
@@ -156,7 +157,7 @@ const JumpToSectionDialog = ({ scrollRef, data, type }) => {
<PressableButton
key={item.title}
onPress={() => onPress(item, index)}
type={currentIndex === index ? "selected" : "transparent"}
type={currentIndex === index ? "accent" : "transparent"}
customStyle={{
minWidth: "20%",
width: null,
@@ -170,9 +171,7 @@ const JumpToSectionDialog = ({ scrollRef, data, type }) => {
<Paragraph
size={SIZE.sm}
color={
currentIndex === index
? colors.selected.accent
: colors.primary.accent
currentIndex === index ? colors.light : colors.accent
}
style={{
textAlign: "center"

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import { View } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import BaseDialog from "../../dialog/base-dialog";
import { ProgressBarComponent } from "../../ui/svg/lazy";
import { useEffect } from "react";
@@ -30,7 +30,7 @@ import { useState } from "react";
import { eCloseLoading, eOpenLoading } from "../../../utils/events";
export const LoadingDialog = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
useEffect(() => {
@@ -58,7 +58,7 @@ export const LoadingDialog = () => {
style={{
width: "100%",
height: "100%",
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
justifyContent: "center",
alignItems: "center"
}}
@@ -77,8 +77,8 @@ export const LoadingDialog = () => {
useNativeDriver
indeterminate
indeterminateAnimationDuration={2000}
unfilledColor={colors.secondary.background}
color={colors.primary.accent}
unfilledColor={colors.nav}
color={colors.accent}
borderWidth={0}
/>
</View>

View File

@@ -33,7 +33,7 @@ import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import { SIZE } from "../../../utils/size";
import { Dialog } from "../../dialog";
import BaseDialog from "../../dialog/base-dialog";
@@ -64,7 +64,7 @@ const usePDFSnapshot = (attachment) => {
};
const PDFPreview = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [pdfSource, setPDFSource] = useState();
const [loading, setLoading] = useState(false);
@@ -172,7 +172,7 @@ const PDFPreview = () => {
>
<ProgressBarComponent
indeterminate={!progress}
color={colors.primary.accent}
color={colors.accent}
borderColor="transparent"
progress={parseInt(progress?.value || "100") / 100}
/>
@@ -180,7 +180,7 @@ const PDFPreview = () => {
style={{
marginTop: 10
}}
color={colors.static.white}
color={colors.light}
>
Loading {`${progress?.percent ? `(${progress?.percent})` : ""}`}
... Please wait
@@ -205,7 +205,7 @@ const PDFPreview = () => {
}}
>
<IconButton
color={colors.static.white}
color={colors.light}
name="arrow-left"
onPress={close}
customStyle={{
@@ -226,7 +226,7 @@ const PDFPreview = () => {
ref={inputRef}
defaultValue={currentPage + ""}
style={{
color: colors.primary.paragraph,
color: colors.pri,
padding: 0,
paddingTop: 0,
paddingBottom: 0,
@@ -234,7 +234,7 @@ const PDFPreview = () => {
marginBottom: 0,
paddingVertical: 0,
height: 25,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
width: 40,
textAlign: "center",
marginRight: 4,
@@ -249,7 +249,7 @@ const PDFPreview = () => {
}}
blurOnSubmit
/>
<Paragraph color={colors.static.white}>/{numPages}</Paragraph>
<Paragraph color={colors.light}>/{numPages}</Paragraph>
</View>
<View
@@ -258,7 +258,7 @@ const PDFPreview = () => {
}}
>
<IconButton
color={colors.static.white}
color={colors.light}
name="download"
onPress={() => {
downloadAttachment(attachment.metadata.hash, false);

View File

@@ -24,7 +24,7 @@ import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import { getElevationStyle } from "../../../utils/elevation";
import { eCloseResultDialog, eOpenResultDialog } from "../../../utils/events";
import { SIZE } from "../../../utils/size";
@@ -36,7 +36,7 @@ import Paragraph from "../../ui/typography/paragraph";
import { ProFeatures } from "./pro-features";
const ResultDialog = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [dialogData, setDialogData] = useState({
title: "Thank you for signing up!",
@@ -72,7 +72,7 @@ const ResultDialog = () => {
width: DDS.isTab ? 350 : "85%",
maxHeight: 500,
borderRadius: 10,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
paddingTop: 20,
justifyContent: "center",
alignItems: "center"
@@ -94,7 +94,7 @@ const ResultDialog = () => {
</Heading>
<Paragraph
color={colors.secondary.paragraph}
color={colors.icon}
size={SIZE.md}
style={{
alignSelf: "center",
@@ -121,7 +121,7 @@ const ResultDialog = () => {
<Seperator />
<View
style={{
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
width: "100%",
borderBottomRightRadius: 10,
borderBottomLeftRadius: 10,

View File

@@ -21,7 +21,7 @@ import React from "react";
import { View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { eSendEvent } from "../../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import {
eCloseSheet,
eCloseResultDialog,
@@ -31,7 +31,7 @@ import { SIZE } from "../../../utils/size";
import { sleep } from "../../../utils/time";
import Paragraph from "../../ui/typography/paragraph";
export const ProFeatures = ({ count = 6 }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
return (
<>
@@ -73,7 +73,7 @@ export const ProFeatures = ({ count = 6 }) => {
justifyContent: "flex-start"
}}
>
<Icon size={SIZE.lg} color={colors.primary.accent} name="check" />
<Icon size={SIZE.lg} color={colors.accent} name="check" />
<Paragraph style={{ marginLeft: 5, flexShrink: 1 }}>
{item.content}
</Paragraph>
@@ -89,7 +89,7 @@ export const ProFeatures = ({ count = 6 }) => {
size={SIZE.xs}
style={{
textDecorationLine: "underline",
color: colors.secondary.paragraph
color: colors.icon
}}
>
See all features included in Notesnook Pro

View File

@@ -682,7 +682,7 @@ export class VaultDialog extends Component {
...getElevationStyle(5),
width: DDS.isTab ? 350 : "85%",
borderRadius: 10,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
paddingTop: 12
}}
>
@@ -867,12 +867,7 @@ export class VaultDialog extends Component {
icon="fingerprint"
width="100%"
title="Biometric unlocking"
iconColor={
this.state.biometricUnlock
? colors.selected.icon
: colors.primary.icon
}
type={this.state.biometricUnlock ? "transparent" : "selected"}
type={this.state.biometricUnlock ? "transparent" : "gray"}
/>
) : null}
</View>

View File

@@ -27,14 +27,14 @@ import {
} from "../../services/event-manager";
import useNavigationStore from "../../stores/use-navigation-store";
import { useSelectionStore } from "../../stores/use-selection-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { eScrollEvent } from "../../utils/events";
import { LeftMenus } from "./left-menus";
import { RightMenus } from "./right-menus";
import { Title } from "./title";
const _Header = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const insets = useGlobalSafeAreaInsets();
const [hide, setHide] = useState(true);
const selectionMode = useSelectionStore((state) => state.selectionMode);
@@ -43,7 +43,7 @@ const _Header = () => {
);
const onScroll = useCallback(
(data: { x: number; y: number }) => {
(data) => {
if (data.y > 150) {
if (!hide) return;
setHide(false);
@@ -69,12 +69,10 @@ const _Header = () => {
styles.container,
{
marginTop: Platform.OS === "android" ? insets.top : null,
backgroundColor: colors.primary.background,
backgroundColor: colors.bg,
overflow: "hidden",
borderBottomWidth: 1,
borderBottomColor: hide
? "transparent"
: colors.secondary.background,
borderBottomColor: hide ? "transparent" : colors.nav,
justifyContent: "space-between"
}
]}

View File

@@ -23,12 +23,12 @@ import { DDS } from "../../services/device-detection";
import Navigation from "../../services/navigation";
import useNavigationStore from "../../stores/use-navigation-store";
import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { tabBarRef } from "../../utils/global-refs";
import { IconButton } from "../ui/icon-button";
export const LeftMenus = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const deviceMode = useSettingStore((state) => state.deviceMode);
const canGoBack = useNavigationStore((state) => state.canGoBack);
const isTablet = deviceMode === "tablet";
@@ -43,6 +43,12 @@ export const LeftMenus = () => {
return;
}
Navigation.goBack();
if (
useNavigationStore.getState().currentScreen.name === "Signup" ||
useNavigationStore.getState().currentScreen.name === "Login"
) {
tabBarRef.current.unlock();
}
};
return isTablet && !canGoBack ? null : (
@@ -55,17 +61,17 @@ export const LeftMenus = () => {
width: 40,
borderRadius: 100,
marginLeft: -5,
marginRight: DDS.isLargeTablet() ? 10 : 7
marginRight: DDS.isLargeTablet() ? 10 : 25
}}
left={40}
top={40}
right={DDS.isLargeTablet() ? 10 : 10}
right={DDS.isLargeTablet() ? 10 : 25}
onPress={onLeftButtonPress}
onLongPress={() => {
Navigation.popToTop();
}}
name={canGoBack ? "arrow-left" : "menu"}
color={colors.primary.paragraph}
color={colors.pri}
iconStyle={{
marginLeft: canGoBack ? -5 : 0
}}

View File

@@ -19,30 +19,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React, { useRef } from "react";
import { Platform, StyleSheet, View } from "react-native";
//@ts-ignore
import Menu from "react-native-reanimated-material-menu";
import { notesnook } from "../../../e2e/test.ids";
import Navigation from "../../services/navigation";
import SearchService from "../../services/search";
import useNavigationStore from "../../stores/use-navigation-store";
import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../stores/use-theme-store";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
import { Button } from "../ui/button";
import { IconButton } from "../ui/icon-button";
export const RightMenus = () => {
const { colors } = useThemeColors();
const { colors: contextMenuColors } = useThemeColors("contextMenu");
const colors = useThemeStore((state) => state.colors);
const deviceMode = useSettingStore((state) => state.deviceMode);
const buttons = useNavigationStore((state) => state.headerRightButtons);
const rightButtons = useNavigationStore((state) => state.headerRightButtons);
const currentScreen = useNavigationStore((state) => state.currentScreen.name);
const buttonAction = useNavigationStore((state) => state.buttonAction);
const menuRef = useRef<{
show: () => void;
hide: () => void;
}>();
const menuRef = useRef();
return (
<View style={styles.rightBtnContainer}>
@@ -50,16 +45,13 @@ export const RightMenus = () => {
<IconButton
onPress={async () => {
SearchService.prepareSearch();
Navigation.navigate(
{
name: "Search"
},
{}
);
Navigation.navigate({
name: "Search"
});
}}
testID="icon-search"
name="magnify"
color={colors.primary.paragraph}
color={colors.pri}
customStyle={styles.rightBtn}
/>
) : null}
@@ -84,34 +76,34 @@ export const RightMenus = () => {
borderRadius: 5,
paddingHorizontal: 0,
borderWidth: 1,
borderColor: colors.primary.accent
borderColor: colors.accent
}}
/>
) : null}
{buttons && buttons.length > 0 ? (
{rightButtons && rightButtons.length > 0 ? (
<Menu
ref={menuRef}
animationDuration={200}
style={{
borderRadius: 5,
backgroundColor: contextMenuColors.primary.background
backgroundColor: colors.bg
}}
onRequestClose={() => {
menuRef.current?.hide();
}}
anchor={
button={
<IconButton
onPress={() => {
menuRef.current?.show();
}}
name="dots-vertical"
color={colors.primary.paragraph}
color={colors.pri}
customStyle={styles.rightBtn}
/>
}
>
{buttons.map((item) => (
{rightButtons.map((item) => (
<Button
style={{
width: 150,
@@ -120,7 +112,7 @@ export const RightMenus = () => {
}}
type="gray"
buttonType={{
text: contextMenuColors.primary.paragraph
text: colors.pri
}}
key={item.title}
title={item.title}

View File

@@ -17,9 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React, { useCallback, useEffect, useState } from "react";
import { Platform } from "react-native";
import React, { useEffect, useState } from "react";
import { Platform, View } from "react-native";
import { db } from "../../common/database";
import Notebook from "../../screens/notebook";
import {
@@ -27,26 +26,28 @@ import {
eUnSubscribeEvent
} from "../../services/event-manager";
import useNavigationStore from "../../stores/use-navigation-store";
import { useThemeStore } from "../../stores/use-theme-store";
import { eScrollEvent } from "../../utils/events";
import { SIZE } from "../../utils/size";
import Tag from "../ui/tag";
import Heading from "../ui/typography/heading";
import { useCallback } from "react";
import Tag from "../ui/tag";
const titleState: { [name: string]: boolean } = {};
const titleState = {};
export const Title = () => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const currentScreen = useNavigationStore((state) => state.currentScreen);
const isNotebook = currentScreen.name === "Notebook";
const isTopic = currentScreen?.name === "TopicNotes";
const [hide, setHide] = useState(
isNotebook
? typeof titleState[currentScreen.id as string] === "boolean"
? titleState[currentScreen.id as string]
? typeof titleState[currentScreen.id] === "boolean"
? titleState[currentScreen.id]
: true
: false
);
const isHidden = titleState[currentScreen.id as string];
const isHidden = titleState[currentScreen.id];
const notebook =
isTopic && currentScreen.notebookId
? db.notebooks?.notebook(currentScreen.notebookId)?.data
@@ -55,18 +56,18 @@ export const Title = () => {
const isTag = currentScreen?.name === "TaggedNotes";
const onScroll = useCallback(
(data: { x: number; y: number }) => {
(data) => {
if (currentScreen.name !== "Notebook") {
setHide(false);
return;
}
if (data.y > 150) {
if (!hide) return;
titleState[currentScreen.id as string] = false;
titleState[currentScreen.id] = false;
setHide(false);
} else {
if (hide) return;
titleState[currentScreen.id as string] = true;
titleState[currentScreen.id] = true;
setHide(true);
}
},
@@ -75,13 +76,13 @@ export const Title = () => {
useEffect(() => {
if (currentScreen.name === "Notebook") {
const value =
typeof titleState[currentScreen.id as string] === "boolean"
? titleState[currentScreen.id as string]
let value =
typeof titleState[currentScreen.id] === "boolean"
? titleState[currentScreen.id]
: true;
setHide(value);
} else {
setHide(titleState[currentScreen.id as string]);
setHide(titleState[currentScreen.id]);
}
}, [currentScreen.id, currentScreen.name]);
@@ -97,34 +98,34 @@ export const Title = () => {
Notebook.navigate(notebook, true);
}
return (
<>
<View
style={{
opacity: 1,
flexShrink: 1,
flexDirection: "row",
alignItems: "center"
}}
>
{!hide && !isHidden ? (
<Heading
onPress={navigateToNotebook}
numberOfLines={1}
size={SIZE.lg}
size={SIZE.xl}
style={{
flexWrap: "wrap",
marginTop: Platform.OS === "ios" ? -1 : 0
}}
color={currentScreen.color || colors.primary.heading}
color={currentScreen.color || colors.heading}
>
{isTag ? (
<Heading size={SIZE.xl} color={colors.primary.accent}>
<Heading size={SIZE.xl} color={colors.accent}>
#
</Heading>
) : null}
{title}{" "}
<Tag
visible={currentScreen.beta}
text="BETA"
style={{
backgroundColor: "transparent"
}}
textColor={colors.primary.accent}
/>
{title}
</Heading>
) : null}
</>
<Tag visible={currentScreen.beta} text="BETA" />
</View>
);
};

View File

@@ -17,9 +17,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Sodium from "@ammarahmed/react-native-sodium";
import dataurl from "@notesnook/core/dist/utils/dataurl";
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
import { Platform, View } from "react-native";
import ImageViewer from "react-native-image-zoom-viewer";
@@ -29,13 +26,15 @@ import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../../services/event-manager";
import { useThemeStore } from "../../stores/use-theme-store";
import BaseDialog from "../dialog/base-dialog";
import { IconButton } from "../ui/icon-button";
import { ProgressBarComponent } from "../ui/svg/lazy";
import Sodium from "@ammarahmed/react-native-sodium";
import dataurl from "@notesnook/core/utils/dataurl";
const ImagePreview = () => {
const { colors } = useThemeColors("dialog");
const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [image, setImage] = useState("");
const [loading, setLoading] = useState(false);
@@ -98,7 +97,7 @@ const ImagePreview = () => {
>
<ProgressBarComponent
indeterminate
color={colors.primary.accent}
color={colors.accent}
borderColor="transparent"
/>
</View>

View File

@@ -17,34 +17,32 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import {
Linking,
ScrollView,
TouchableOpacity,
useWindowDimensions,
View
} from "react-native";
import { SwiperFlatList } from "react-native-swiper-flatlist";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { getElevationStyle } from "../../utils/elevation";
import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets";
import SettingsService from "../../services/settings";
import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeStore } from "../../stores/use-theme-store";
import { getElevationStyle } from "../../utils/elevation";
import { SIZE } from "../../utils/size";
import { Button } from "../ui/button";
import Heading from "../ui/typography/heading";
import Paragraph from "../ui/typography/paragraph";
const Intro = ({ navigation }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const isTelemetryEnabled = useSettingStore(
(state) => state.settings.telemetry
);
const { width, height } = useWindowDimensions();
const { width } = useWindowDimensions();
const deviceMode = useSettingStore((state) => state.deviceMode);
const insets = useGlobalSafeAreaInsets();
const renderItem = React.useCallback(
({ item }) => (
<View
@@ -64,7 +62,7 @@ const Intro = ({ navigation }) => {
style={{
width: 100,
height: 5,
backgroundColor: colors.primary.accent,
backgroundColor: colors.accent,
borderRadius: 2,
marginRight: 7
}}
@@ -74,7 +72,7 @@ const Intro = ({ navigation }) => {
style={{
width: 20,
height: 5,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 2
}}
/>
@@ -82,6 +80,7 @@ const Intro = ({ navigation }) => {
<View
style={{
marginTop: 10,
marginBottom: 20,
maxWidth: "90%",
width: "100%"
}}
@@ -117,31 +116,30 @@ const Intro = ({ navigation }) => {
</View>
</View>
),
[colors.primary.accent, colors.secondary.background, deviceMode, width]
[colors.accent, colors.nav, deviceMode, width]
);
return (
<ScrollView
<View
testID="notesnook.splashscreen"
style={{
width: "100%"
width: "100%",
height: "100%"
}}
>
<View
style={{
flex: 0.65,
width: deviceMode !== "mobile" ? width / 2 : "100%",
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
marginBottom: 20,
borderBottomWidth: 1,
borderBottomColor: colors.primary.border,
borderBottomColor: colors.border,
alignSelf: deviceMode !== "mobile" ? "center" : undefined,
borderWidth: deviceMode !== "mobile" ? 1 : null,
borderColor: deviceMode !== "mobile" ? colors.primary.border : null,
borderColor: deviceMode !== "mobile" ? colors.border : null,
borderRadius: deviceMode !== "mobile" ? 20 : null,
marginTop: deviceMode !== "mobile" ? 50 : null,
paddingTop: insets.top + 10,
paddingBottom: insets.top + 10,
minHeight: height * 0.7
marginTop: deviceMode !== "mobile" ? 50 : null
}}
>
<SwiperFlatList
@@ -171,14 +169,14 @@ const Intro = ({ navigation }) => {
user: "@andrewsayer on Twitter"
}
]}
paginationActiveColor={colors.primary.accent}
paginationActiveColor={colors.accent}
paginationStyleItem={{
width: 10,
height: 5,
marginRight: 4,
marginLeft: 4
}}
paginationDefaultColor={colors.primary.border}
paginationDefaultColor={colors.border}
renderItem={renderItem}
/>
</View>
@@ -186,8 +184,8 @@ const Intro = ({ navigation }) => {
<View
style={{
width: "100%",
justifyContent: "center",
minHeight: height * 0.3
flex: 0.3,
justifyContent: "center"
}}
>
<Button
@@ -229,9 +227,7 @@ const Intro = ({ navigation }) => {
name={
isTelemetryEnabled ? "checkbox-marked" : "checkbox-blank-outline"
}
color={
isTelemetryEnabled ? colors.primary.accent : colors.primary.icon
}
color={isTelemetryEnabled ? colors.accent : colors.icon}
/>
<Paragraph
@@ -246,7 +242,7 @@ const Intro = ({ navigation }) => {
</Paragraph>
</TouchableOpacity>
</View>
</ScrollView>
</View>
);
};

File diff suppressed because one or more lines are too long

View File

@@ -19,9 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { View } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import { useMessageStore } from "../../../stores/use-message-store";
import { ColorValues } from "../../../utils/colors";
import { COLORS_NOTE } from "../../../utils/color-scheme";
import { Announcement } from "../../announcements/announcement";
import { Card } from "../../list/card";
import Paragraph from "../../ui/typography/paragraph";
@@ -37,7 +37,7 @@ export const Header = React.memo(
noAnnouncement,
warning
}) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const announcements = useMessageStore((state) => state.announcements);
const selectionMode = useSelectionStore((state) => state.selectionMode);
@@ -47,7 +47,7 @@ export const Header = React.memo(
<View
style={{
padding: 12,
backgroundColor: colors.error.background,
backgroundColor: colors.errorBg,
width: "95%",
alignSelf: "center",
borderRadius: 5,
@@ -55,18 +55,13 @@ export const Header = React.memo(
alignItems: "center"
}}
>
<Icon
name="sync-alert"
size={SIZE.md}
color={colors.error.icon}
f
/>
<Paragraph style={{ marginLeft: 5 }} color={colors.error.icon}>
<Icon name="sync-alert" size={SIZE.md} color={colors.red} f />
<Paragraph style={{ marginLeft: 5 }} color={colors.red}>
{warning.title}
</Paragraph>
</View>
) : announcements.length !== 0 && !noAnnouncement ? (
<Announcement color={color || colors.primary.accent} />
<Announcement color={color || colors.accent} />
) : type === "search" ? null : !shouldShow ? (
<View
style={{
@@ -79,9 +74,7 @@ export const Header = React.memo(
>
{messageCard ? (
<Card
color={
ColorValues[color?.toLowerCase()] || colors.primary.accent
}
color={COLORS_NOTE[color?.toLowerCase()] || colors.accent}
/>
) : null}
</View>

View File

@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { useRef, useState } from "react";
import React from "react";
import { View } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import { useMenuStore } from "../../../stores/use-menu-store";
import { ToastEvent } from "../../../services/event-manager";
import { getTotalNotes } from "@notesnook/common";
@@ -31,7 +31,7 @@ import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
export const NotebookHeader = ({ notebook, onEditNotebook }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const [isPinnedToMenu, setIsPinnedToMenu] = useState(
db.shortcuts.exists(notebook.id)
);
@@ -75,7 +75,7 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
paddingTop: 25
}}
>
<Paragraph color={colors.secondary.paragraph} size={SIZE.xs}>
<Paragraph color={colors.icon} size={SIZE.xs}>
{new Date(notebook.dateEdited).toLocaleString()}
</Paragraph>
<View
@@ -110,7 +110,7 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
height: 40
}}
type={isPinnedToMenu ? "grayBg" : "grayBg"}
color={isPinnedToMenu ? colors.primary.accent : colors.primary.icon}
color={isPinnedToMenu ? colors.accent : colors.icon}
size={SIZE.lg}
/>
<IconButton
@@ -119,7 +119,7 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
tooltipText="Edit this notebook"
name="pencil"
type="grayBg"
color={colors.primary.icon}
color={colors.icon}
customStyle={{
width: 40,
height: 40
@@ -129,7 +129,7 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
</View>
{notebook.description ? (
<Paragraph size={SIZE.md} color={colors.primary.paragraph}>
<Paragraph size={SIZE.md} color={colors.pri}>
{notebook.description}
</Paragraph>
) : null}
@@ -141,7 +141,7 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
fontFamily: null
}}
size={SIZE.xs}
color={colors.secondary.paragraph}
color={colors.icon}
>
{notebook.topics.length === 1
? "1 topic"

View File

@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import React, { useEffect, useRef, useState } from "react";
import { TouchableOpacity, useWindowDimensions, View } from "react-native";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import { useSettingStore } from "../../../stores/use-setting-store";
import {
eSendEvent,
@@ -29,7 +29,7 @@ import {
} from "../../../services/event-manager";
import SettingsService from "../../../services/settings";
import { GROUP } from "../../../utils/constants";
import { ColorValues } from "../../../utils/colors";
import { COLORS_NOTE } from "../../../utils/color-scheme";
import { db } from "../../../common/database";
import { eOpenJumpToDialog } from "../../../utils/events";
import { SIZE } from "../../../utils/size";
@@ -41,7 +41,7 @@ import { useCallback } from "react";
export const SectionHeader = React.memo(
function SectionHeader({ item, index, type, color, screen }) {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const { fontScale } = useWindowDimensions();
const [groupOptions, setGroupOptions] = useState(
db.settings?.getGroupOptions(type)
@@ -85,7 +85,7 @@ export const SectionHeader = React.memo(
justifyContent: "space-between",
paddingHorizontal: 12,
height: 35 * fontScale,
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
alignSelf: "center",
borderRadius: 5,
marginVertical: 5
@@ -104,7 +104,7 @@ export const SectionHeader = React.memo(
}}
>
<Heading
color={ColorValues[color?.toLowerCase()] || colors.primary.accent}
color={COLORS_NOTE[color?.toLowerCase()] || colors.accent}
size={SIZE.sm}
style={{
minWidth: 60,
@@ -168,7 +168,7 @@ export const SectionHeader = React.memo(
: "Switch to compact mode"
}
fwdRef={compactModeRef}
color={colors.secondary.icon}
color={colors.icon}
name={listMode == "compact" ? "view-list" : "view-list-outline"}
onPress={() => {
let settings = {};

View File

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { getUpcomingReminder } from "@notesnook/core/dist/collections/reminders";
import { getUpcomingReminder } from "@notesnook/core/collections/reminders";
import { decode, EntityLevel } from "entities";
import React from "react";
import { View } from "react-native";
@@ -29,8 +29,9 @@ import { TaggedNotes } from "../../../screens/notes/tagged";
import { TopicNotes } from "../../../screens/notes/topic-notes";
import useNavigationStore from "../../../stores/use-navigation-store";
import { useRelationStore } from "../../../stores/use-relation-store";
import { useThemeColors } from "@notesnook/theme";
import { ColorValues } from "../../../utils/colors";
import { useSettingStore } from "../../../stores/use-setting-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { COLORS_NOTE } from "../../../utils/color-scheme";
import { SIZE } from "../../../utils/size";
import { Properties } from "../../properties";
import { Button } from "../../ui/button";
@@ -39,8 +40,6 @@ import { ReminderTime } from "../../ui/reminder-time";
import { TimeSince } from "../../ui/time-since";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import { useIsCompactModeEnabled } from "../../../hooks/use-is-compact-mode-enabled";
import { useEditorStore } from "../../../stores/use-editor-store";
function navigateToTag(item) {
const tag = db.tags.tag(item.id);
@@ -99,22 +98,19 @@ const NoteItem = ({
dateBy = "dateCreated",
noOpen = false
}) => {
const currentEditingNote = useEditorStore(
(state) => state.currentEditingNote
const colors = useThemeStore((state) => state.colors);
const notesListMode = useSettingStore(
(state) => state.settings.notesListMode
);
const { colors } = useThemeColors();
const compactMode = useIsCompactModeEnabled(item);
const compactMode = notesListMode === "compact";
const attachmentCount = db.attachments?.ofNote(item.id, "all")?.length || 0;
const _update = useRelationStore((state) => state.updater);
// eslint-disable-next-line react-hooks/exhaustive-deps
const notebooks = React.useMemo(() => getNotebook(item), [item, _update]);
const reminders = db.relations.from(item, "reminder");
const reminder = getUpcomingReminder(reminders);
const noteColor = ColorValues[item.color?.toLowerCase()];
const noteColor = COLORS_NOTE[item.color?.toLowerCase()];
const tags = getTags(item);
const primaryColors =
currentEditingNote === item.id ? colors.selected : colors.primary;
return (
<>
<View
@@ -155,7 +151,7 @@ const NoteItem = ({
borderRadius: 5,
marginRight: 5,
borderWidth: 0.5,
borderColor: primaryColors.border,
borderColor: colors.icon,
paddingHorizontal: 6,
marginBottom: 5
}}
@@ -185,9 +181,7 @@ const NoteItem = ({
{compactMode ? (
<Paragraph
numberOfLines={1}
color={
ColorValues[item.color?.toLowerCase()] || primaryColors.heading
}
color={COLORS_NOTE[item.color?.toLowerCase()] || colors.heading}
style={{
flexWrap: "wrap"
}}
@@ -198,9 +192,7 @@ const NoteItem = ({
) : (
<Heading
numberOfLines={1}
color={
ColorValues[item.color?.toLowerCase()] || primaryColors.heading
}
color={COLORS_NOTE[item.color?.toLowerCase()] || colors.heading}
style={{
flexWrap: "wrap"
}}
@@ -215,7 +207,6 @@ const NoteItem = ({
style={{
flexWrap: "wrap"
}}
color={primaryColors.paragraph}
numberOfLines={2}
>
{decode(item.headline, {
@@ -244,13 +235,13 @@ const NoteItem = ({
marginRight: 6
}}
size={SIZE.sm}
color={colors.error.accent}
color={colors.red}
/>
) : null}
<TimeSince
style={{
fontSize: SIZE.xs,
color: colors.secondary.paragraph,
color: colors.icon,
marginRight: 6
}}
time={item[dateBy]}
@@ -270,12 +261,9 @@ const NoteItem = ({
<Icon
name="attachment"
size={SIZE.md}
color={primaryColors.icon}
color={colors.icon}
/>
<Paragraph
color={colors.secondary.paragraph}
size={SIZE.xs}
>
<Paragraph color={colors.icon} size={SIZE.xs}>
{attachmentCount}
</Paragraph>
</View>
@@ -290,8 +278,7 @@ const NoteItem = ({
marginRight: 6
}}
color={
ColorValues[item.color?.toLowerCase()] ||
primaryColors.accent
COLORS_NOTE[item.color?.toLowerCase()] || colors.accent
}
/>
) : null}
@@ -304,7 +291,7 @@ const NoteItem = ({
style={{
marginRight: 6
}}
color={primaryColors.icon}
color={colors.icon}
/>
) : null}
@@ -349,7 +336,7 @@ const NoteItem = ({
) : (
<>
<Paragraph
color={colors.secondary.paragraph}
color={colors.icon}
size={SIZE.xs}
style={{
marginRight: 6
@@ -362,7 +349,7 @@ const NoteItem = ({
</Paragraph>
<Paragraph
color={primaryColors.accent}
color={colors.accent}
size={SIZE.xs}
style={{
marginRight: 6
@@ -390,7 +377,7 @@ const NoteItem = ({
marginRight: 6
}}
size={SIZE.sm}
color={colors.error.accent}
color={colors.red}
/>
) : null}
@@ -402,7 +389,7 @@ const NoteItem = ({
style={{
marginRight: 6
}}
color={colors.secondary.background}
color={colors.icon}
/>
) : null}
@@ -421,7 +408,7 @@ const NoteItem = ({
<TimeSince
style={{
fontSize: SIZE.xs,
color: colors.secondary.paragraph,
color: colors.icon,
marginRight: 6
}}
time={item[dateBy]}
@@ -432,7 +419,7 @@ const NoteItem = ({
<IconButton
testID={notesnook.listitem.menu}
color={primaryColors.paragraph}
color={colors.pri}
name="dots-horizontal"
size={SIZE.xl}
onPress={() => !noOpen && showActionSheet(item, isTrash)}

View File

@@ -23,7 +23,8 @@ import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { notesnook } from "../../../../e2e/test.ids";
import { TopicNotes } from "../../../screens/notes/topic-notes";
import { useSelectionStore } from "../../../stores/use-selection-store";
import { useThemeColors } from "@notesnook/theme";
import { useSettingStore } from "../../../stores/use-setting-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { SIZE } from "../../../utils/size";
import { Properties } from "../../properties";
import { Button } from "../../ui/button";
@@ -31,7 +32,6 @@ import { IconButton } from "../../ui/icon-button";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
import { getFormattedDate } from "@notesnook/common";
import { useIsCompactModeEnabled } from "../../../hooks/use-is-compact-mode-enabled";
const showActionSheet = (item) => {
Properties.present(item);
@@ -49,8 +49,11 @@ export const NotebookItem = ({
dateBy,
totalNotes
}) => {
const { colors } = useThemeColors();
const compactMode = useIsCompactModeEnabled(item);
const colors = useThemeStore((state) => state.colors);
const notebooksListMode = useSettingStore(
(state) => state.settings.notebooksListMode
);
const compactMode = notebooksListMode === "compact";
const topics = item.topics?.slice(0, 3) || [];
return (
@@ -109,6 +112,8 @@ export const NotebookItem = ({
key={topic.id}
height={null}
textStyle={{
fontWeight: "normal",
fontFamily: null,
marginRight: 0
}}
type="grayBg"
@@ -120,7 +125,7 @@ export const NotebookItem = ({
maxWidth: 120,
borderWidth: 0.5,
paddingVertical: 2.5,
borderColor: colors.primary.border,
borderColor: colors.icon,
paddingHorizontal: 6,
marginVertical: 5,
marginRight: 5
@@ -144,7 +149,7 @@ export const NotebookItem = ({
{isTrash ? (
<>
<Paragraph
color={colors.secondary.paragraph}
color={colors.icon}
size={SIZE.xs}
style={{
textAlignVertical: "center",
@@ -155,7 +160,7 @@ export const NotebookItem = ({
new Date(item.dateDeleted).toISOString().slice(0, 10)}
</Paragraph>
<Paragraph
color={colors.primary.accent}
color={colors.accent}
size={SIZE.xs}
style={{
textAlignVertical: "center",
@@ -167,7 +172,7 @@ export const NotebookItem = ({
</>
) : (
<Paragraph
color={colors.secondary.paragraph}
color={colors.icon}
size={SIZE.xs}
style={{
marginRight: 6
@@ -177,7 +182,7 @@ export const NotebookItem = ({
</Paragraph>
)}
<Paragraph
color={colors.secondary.paragraph}
color={colors.icon}
size={SIZE.xs}
style={{
marginRight: 6
@@ -198,7 +203,7 @@ export const NotebookItem = ({
marginRight: 10,
marginTop: 2
}}
color={colors.primary.accent}
color={colors.accent}
/>
) : null}
</View>
@@ -213,7 +218,7 @@ export const NotebookItem = ({
{compactMode ? (
<>
<Paragraph
color={colors.primary.icon}
color={colors.icon}
size={SIZE.xs}
style={{
marginRight: 6
@@ -229,7 +234,7 @@ export const NotebookItem = ({
) : null}
<IconButton
color={colors.primary.heading}
color={colors.heading}
name="dots-horizontal"
testID={notesnook.ids.notebook.menu}
size={SIZE.xl}

View File

@@ -20,7 +20,7 @@ import React from "react";
import { View } from "react-native";
import { notesnook } from "../../../../e2e/test.ids";
import type { Reminder } from "../../../services/notifications";
import { useThemeColors } from "@notesnook/theme";
import { useThemeStore } from "../../../stores/use-theme-store";
import { SIZE } from "../../../utils/size";
import { Properties } from "../../properties";
import { IconButton } from "../../ui/icon-button";
@@ -41,7 +41,7 @@ const ReminderItem = React.memo(
index: number;
isSheet: boolean;
}) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const openReminder = () => {
ReminderSheet.present(item, undefined, isSheet);
};
@@ -90,7 +90,7 @@ const ReminderItem = React.memo(
{item.disabled ? (
<View
style={{
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
flexDirection: "row",
paddingHorizontal: 6,
@@ -105,11 +105,11 @@ const ReminderItem = React.memo(
<Icon
name="bell-off-outline"
size={SIZE.md}
color={colors.error.icon}
color={colors.errorText}
/>
<Paragraph
size={SIZE.xs}
color={colors.secondary.paragraph}
color={colors.icon}
style={{ marginLeft: 5 }}
>
Disabled
@@ -119,7 +119,7 @@ const ReminderItem = React.memo(
{item.mode === "repeat" && item.recurringMode ? (
<View
style={{
backgroundColor: colors.secondary.background,
backgroundColor: colors.nav,
borderRadius: 5,
flexDirection: "row",
paddingHorizontal: 6,
@@ -131,10 +131,10 @@ const ReminderItem = React.memo(
height: 30
}}
>
<Icon name="reload" size={SIZE.md} color={colors.primary.accent} />
<Icon name="reload" size={SIZE.md} color={colors.accent} />
<Paragraph
size={SIZE.xs}
color={colors.secondary.paragraph}
color={colors.icon}
style={{ marginLeft: 5 }}
>
{item.recurringMode.slice(0, 1).toUpperCase() +
@@ -160,7 +160,7 @@ const ReminderItem = React.memo(
</View>
<IconButton
testID={notesnook.listitem.menu}
color={colors.primary.paragraph}
color={colors.pri}
name="dots-horizontal"
size={SIZE.xl}
onPress={() => Properties.present(item, [], isSheet)}

View File

@@ -17,36 +17,37 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React from "react";
import { View } from "react-native";
import useIsSelected from "../../../hooks/use-selected";
import { useEditorStore } from "../../../stores/use-editor-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { hexToRGBA } from "../../../utils/color-scheme/utils";
export const Filler = ({ item }) => {
const { colors } = useThemeColors();
const colors = useThemeStore((state) => state.colors);
const currentEditingNote = useEditorStore(
(state) => state.currentEditingNote
);
const [selected] = useIsSelected(item);
const color = "gray";
return currentEditingNote === item.id || selected ? (
return currentEditingNote === item.id ? (
<View
style={{
position: "absolute",
width: "110%",
height: "150%",
backgroundColor: colors.selected.background,
backgroundColor:
currentEditingNote === item.id
? hexToRGBA(colors[color], 0.12)
: null,
borderLeftWidth: 5,
borderLeftColor:
currentEditingNote === item.id
? item.color
? colors.static[item.color]
: colors.selected.accent
? colors[item.color || "accent"]
: "transparent"
}}
collapsable={false}
/>
></View>
) : null;
};

View File

@@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React, { useRef } from "react";
import { useIsCompactModeEnabled } from "../../../hooks/use-is-compact-mode-enabled";
import { useSelectionStore } from "../../../stores/use-selection-store";
import { useSettingStore } from "../../../stores/use-setting-store";
import { useThemeStore } from "../../../stores/use-theme-store";
import { PressableButton } from "../../ui/pressable";
import { Filler } from "./back-fill";
import { SelectionIcon } from "./selection";
@@ -29,33 +29,51 @@ const SelectionWrapper = ({
children,
item,
background,
onLongPress,
onPress,
testID,
isSheet
}) => {
const itemId = useRef(item.id);
const { colors, isDark } = useThemeColors();
const compactMode = useIsCompactModeEnabled(item);
const colors = useThemeStore((state) => state.colors);
const notebooksListMode = useSettingStore(
(state) => state.settings.notebooksListMode
);
const notesListMode = useSettingStore(
(state) => state.settings.notesListMode
);
const listMode =
item.type === "notebook" || item.itemType === "notebook"
? notebooksListMode
: notesListMode;
const compactMode =
(item.type === "notebook" ||
item.itemType === "notebook" ||
item.itemType === "note" ||
item.type === "note") &&
listMode === "compact";
if (item.id !== itemId.current) {
itemId.current = item.id;
}
const onLongPress = () => {
const _onLongPress = () => {
if (!useSelectionStore.getState().selectionMode) {
useSelectionStore.getState().setSelectionMode(true);
}
useSelectionStore.getState().setSelectedItem(item);
};
const _onPress = async () => {
await onPress();
};
return (
<PressableButton
customColor={isSheet ? colors.primary.hover : "transparent"}
customColor={isSheet ? colors.transGray : "transparent"}
testID={testID}
onLongPress={onLongPress}
onPress={onPress}
customSelectedColor={colors.primary.hover}
customAlpha={!isDark ? -0.02 : 0.02}
onLongPress={_onLongPress}
onPress={_onPress}
customSelectedColor={colors.transGray}
customAlpha={!colors.night ? -0.02 : 0.02}
customOpacity={1}
customStyle={{
flexDirection: "row",

Some files were not shown because too many files have changed in this diff Show More