Files
notesnook/apps/mobile/app/components/sheets/export-notes/index.tsx

419 lines
12 KiB
TypeScript
Raw Normal View History

/*
This file is part of the Notesnook project (https://notesnook.com/)
2023-01-16 13:44:52 +05:00
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/>.
*/
2022-08-30 16:13:11 +05:00
2023-11-24 15:11:38 +05:00
import { useThemeColors } from "@notesnook/theme";
2022-09-16 16:02:40 +05:00
import React, { Fragment, useState } from "react";
import {
ActivityIndicator,
Linking,
Platform,
StyleSheet,
View
} from "react-native";
import FileViewer from "react-native-file-viewer";
import Share from "react-native-share";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { notesnook } from "../../../../e2e/test.ids";
2022-10-14 17:31:36 +05:00
import { db } from "../../../common/database";
2023-11-24 15:11:38 +05:00
import { requestInAppReview } from "../../../services/app-review";
2023-11-16 08:54:37 +05:00
import {
PresentSheetOptions,
2023-11-24 15:11:38 +05:00
ToastManager,
presentSheet
2023-11-16 08:54:37 +05:00
} from "../../../services/event-manager";
import Exporter from "../../../services/exporter";
2022-10-14 17:31:36 +05:00
import PremiumService from "../../../services/premium";
2022-10-18 16:45:03 +05:00
import { useUserStore } from "../../../stores/use-user-store";
2023-06-10 12:17:23 +05:00
import { getElevationStyle } from "../../../utils/elevation";
2023-11-24 15:11:38 +05:00
import { SIZE, ph, pv } from "../../../utils/size";
import { sleep } from "../../../utils/time";
2024-03-29 10:53:10 +05:00
import { Dialog } from "../../dialog";
import DialogHeader from "../../dialog/dialog-header";
2022-10-18 16:45:03 +05:00
import { ProTag } from "../../premium/pro-tag";
2022-08-29 16:19:17 +05:00
import { Button } from "../../ui/button";
2022-10-14 17:31:36 +05:00
import { IconButton } from "../../ui/icon-button";
2024-02-05 12:14:45 +05:00
import { Pressable } from "../../ui/pressable";
import Seperator from "../../ui/seperator";
import Heading from "../../ui/typography/heading";
import Paragraph from "../../ui/typography/paragraph";
2024-07-27 10:19:43 +05:00
import { strings } from "@notesnook/intl";
2021-09-29 13:22:32 +05:00
2023-11-16 08:54:37 +05:00
const ExportNotesSheet = ({
2023-11-24 15:11:38 +05:00
ids,
2023-11-16 08:54:37 +05:00
update
}: {
2023-11-24 15:11:38 +05:00
ids: string[];
2023-11-16 08:54:37 +05:00
update: ((props: PresentSheetOptions) => void) | undefined;
}) => {
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
const { colors } = useThemeColors();
2020-09-07 12:33:35 +05:00
const [exporting, setExporting] = useState(false);
const [complete, setComplete] = useState(false);
2023-11-16 08:54:37 +05:00
const [result, setResult] = useState<
| {
fileName: string;
filePath: string;
name: string;
type: string;
fileDir: string;
2023-11-16 08:54:37 +05:00
}
| undefined
>();
const [status, setStatus] = useState<string>();
2022-10-18 16:45:03 +05:00
const premium = useUserStore((state) => state.premium);
2020-09-20 14:37:46 +05:00
2024-03-29 10:53:10 +05:00
const exportNoteAs = async (
type: "pdf" | "txt" | "md" | "html" | "md-frontmatter"
) => {
2020-11-25 12:54:20 +05:00
if (exporting) return;
2022-10-14 17:31:36 +05:00
if (!PremiumService.get() && type !== "txt") return;
2020-09-20 15:05:16 +05:00
setExporting(true);
2023-11-16 08:54:37 +05:00
update?.({ disableClosing: true } as PresentSheetOptions);
setComplete(false);
2022-10-14 17:31:36 +05:00
let result;
2023-11-24 15:11:38 +05:00
if (ids.length > 1) {
2024-03-29 10:53:10 +05:00
result = await Exporter.bulkExport(
db.notes.all.where((eb) => eb("id", "in", ids)),
type,
setStatus
);
2022-10-14 17:31:36 +05:00
} else {
2024-03-29 10:53:10 +05:00
const note = await db.notes.note(ids[0]);
if (!note) {
setExporting(false);
return;
}
result = await Exporter.exportNote(note, type, setStatus);
2022-10-14 17:31:36 +05:00
await sleep(1000);
2020-09-20 15:05:16 +05:00
}
2022-10-18 16:45:03 +05:00
if (!result) {
2023-11-16 08:54:37 +05:00
update?.({ disableClosing: false } as PresentSheetOptions);
2022-10-18 16:45:03 +05:00
return setExporting(false);
}
2023-11-16 08:54:37 +05:00
setResult(result as any);
update?.({ disableClosing: false } as PresentSheetOptions);
2020-09-20 15:05:16 +05:00
setComplete(true);
2022-09-16 16:02:40 +05:00
setExporting(false);
2023-05-17 11:14:49 +05:00
requestInAppReview();
2020-09-07 12:33:35 +05:00
};
const actions = [
{
title: "PDF",
2020-09-20 14:37:46 +05:00
func: async () => {
2024-03-29 10:53:10 +05:00
await exportNoteAs("pdf");
2020-09-20 14:37:46 +05:00
},
icon: "file-pdf-box",
2022-10-18 16:45:03 +05:00
id: notesnook.ids.dialogs.export.pdf,
pro: premium
2020-09-07 12:33:35 +05:00
},
{
title: "Markdown",
2020-09-20 15:05:16 +05:00
func: async () => {
2024-03-29 10:53:10 +05:00
await exportNoteAs("md");
2020-09-20 15:05:16 +05:00
},
icon: "language-markdown",
2022-10-18 16:45:03 +05:00
id: notesnook.ids.dialogs.export.md,
pro: premium
2020-09-07 12:33:35 +05:00
},
{
title: "Markdown + Frontmatter",
func: async () => {
2024-03-29 10:53:10 +05:00
await exportNoteAs("md-frontmatter");
},
icon: "language-markdown",
id: notesnook.ids.dialogs.export.md,
pro: premium
},
2020-09-07 12:33:35 +05:00
{
title: "Plain Text",
2020-09-20 15:05:16 +05:00
func: async () => {
2024-03-29 10:53:10 +05:00
await exportNoteAs("txt");
2020-09-20 15:05:16 +05:00
},
icon: "card-text",
2022-10-18 16:45:03 +05:00
id: notesnook.ids.dialogs.export.text,
pro: true
2020-09-07 12:33:35 +05:00
},
{
title: "HTML",
2020-09-20 15:05:16 +05:00
func: async () => {
2024-03-29 10:53:10 +05:00
await exportNoteAs("html");
2020-09-20 15:05:16 +05:00
},
icon: "language-html5",
2022-10-18 16:45:03 +05:00
id: notesnook.ids.dialogs.export.html,
pro: premium
2021-09-29 13:22:32 +05:00
}
2020-09-07 12:33:35 +05:00
];
2022-09-16 16:02:40 +05:00
return (
<View>
2022-10-14 17:31:36 +05:00
{!complete && !exporting ? (
<>
<View
style={{
paddingHorizontal: 12
}}
>
<DialogHeader
icon="export"
title={strings.exportNotes(ids.length)}
2022-10-14 17:31:36 +05:00
/>
</View>
<Seperator half />
</>
) : null}
2020-09-20 14:37:46 +05:00
2024-01-29 11:01:49 +05:00
<Dialog context="export-notes" />
2022-09-16 16:02:40 +05:00
<View style={styles.buttonContainer}>
2022-10-14 17:31:36 +05:00
{!exporting && !complete ? (
actions.map((item) => (
<Fragment key={item.title}>
<Seperator half />
2024-02-05 12:14:45 +05:00
<Pressable
2022-10-14 17:31:36 +05:00
onPress={item.func}
2024-02-05 12:14:45 +05:00
style={{
2022-10-14 17:31:36 +05:00
width: "100%",
alignItems: "center",
flexDirection: "row",
paddingRight: 12,
paddingVertical: 10,
justifyContent: "flex-start",
borderRadius: 0,
2022-10-18 16:45:03 +05:00
paddingHorizontal: 12,
opacity: item.pro ? 1 : 0.5
2022-01-22 12:57:05 +05:00
}}
>
2022-10-14 17:31:36 +05:00
<View
style={{
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
backgroundColor: colors.primary.shade,
2022-10-14 17:31:36 +05:00
borderRadius: 5,
height: 60,
width: 60,
justifyContent: "center",
alignItems: "center"
}}
>
<Icon
name={item.icon}
color={
item.pro ? colors.primary.accent : colors.primary.icon
}
2022-10-14 17:31:36 +05:00
size={SIZE.xxxl + 10}
/>
</View>
<View
style={{
flexShrink: 1
}}
>
2022-10-18 16:45:03 +05:00
{!item.pro ? <ProTag size={12} /> : null}
2022-10-14 17:31:36 +05:00
<Heading style={{ marginLeft: 10 }} size={SIZE.md}>
{item.title}
</Heading>
2024-08-06 15:05:38 +05:00
{/* <Paragraph
2022-10-14 17:31:36 +05:00
style={{ marginLeft: 10 }}
size={SIZE.sm}
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
color={colors.secondary.paragraph}
2022-10-14 17:31:36 +05:00
>
{item.desc}
2024-08-06 15:05:38 +05:00
</Paragraph> */}
2022-10-14 17:31:36 +05:00
</View>
2024-02-05 12:14:45 +05:00
</Pressable>
2022-10-14 17:31:36 +05:00
</Fragment>
))
) : (
<View
style={{
minHeight: 150,
justifyContent: "center",
alignItems: "center",
width: "100%",
paddingHorizontal: 12,
paddingVertical: 20
}}
>
{!complete ? (
<>
<ActivityIndicator />
2024-09-09 14:46:29 +05:00
<Paragraph>
{strings.exportingNotes(status) +
"..." +
" " +
strings.pleaseWait()}
</Paragraph>
2022-10-14 17:31:36 +05:00
</>
) : (
<>
<IconButton
name="export"
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
color={colors.primary.icon}
2022-10-14 17:31:36 +05:00
size={50}
2024-02-05 12:14:45 +05:00
style={{
2022-10-14 17:31:36 +05:00
width: 70,
height: 70
}}
2022-09-16 16:02:40 +05:00
/>
2022-10-14 17:31:36 +05:00
<Heading
style={{
textAlign: "center",
marginTop: 10
}}
global: implement the new theme engine (#2196) * mobile: theme * theme: add theme engine * mobile: migrate app colors to new theme engine * mobile: fixed some colors * mobile: fix colors * mobile: store theme info in store * theme: `ColorsType` -> `Variants` * theme: use explicit return type for `useThemeColors` * theme: add `backdrop` color * mobile: `const colors` -> `const {colors} * theme: add default pitch-black theme * mobile: manage theme state via theme-engine * mobile: add theme scopes * mobile: commit * mobile: fix button width on applock screen * mobile: fix typings * mobile: fix theme definition * web: add partial support for custom themes only context menus & popups are left. * theme: add dialog & sheet scopes * global: sync with master branch and make everything work again * mobile: fix theme-engine usage in editor & app * mobile: fix colors * mobile: fix colors * mobile: cleanup * mobile: fix status bar color incorrect on entering foreground * mobile: fix dark color scheme * web: move emotion theme provider to @notesnook/theme * editor: add support for theme enging * web: adjust hover & focus colors on list item * mobile: migrate share ext to theme engine * mobile: fix editor theme provider * clipper: add support for the new theme engine * mobile: fix statusbar color on switch from bg * misc: fix build * mobile: fix build * misc: fix colors * mobile: fix theme colors * mobile: fix bottom padding * server: add theme server * theme: add previewColors * server: support themes query pagination * mobile: add client from theme server * server: reset cache on sync repo * server: fix types * server: show ip & port on start server * server: theme updates * web: finalize new theme engine on web * editor: fix build * global: fix @emotion/react version to 11.11.1 * editor: update katex patch * web: fix imports * global: fix @trpc/* versions * global: a huge set of changes 1. get rid of ThemeVariant. All variants can now be accessed anywhere. 2. remove unnecessary button variants 3. make buttons more responsive 4. implement themes server * web: add support for theme search and theme switching * global: update lockfiles * mobile: fix error * theme: use vite-plugin-react to start theme server * web: add support for auto updating themes * mobile: update theme selector * mobile: update theme if new verison available * theme: add `isomorphic-fetch` package * global: update lockfiles * web: add theme details dialog * setup: add scope for themes server in bootstrap script * web: add production server url * web: update lockfile * web: update lockfile * mobile: remove `react-native-blob-util` * web: add support for endless scrolling in themes * web: bring back dark/light mode option in settings * web: fix colors in places * theme: add selected variant * global: use single typescript version across the projects * web: fix sort & group options not having submenus * web: apply selected variant where appropriate * ui: use unique id for all menu items * config: add ui scope for commits * theme: export button variant creation fn * web: fix only 1 theme showing in theme selector * web: fix navigation item hover & other colors * mobile: update theme * editor: fix toolbar group alignments * editor: set theme provider at app level * theme: use scope name to get current scope * mobile: fix color usage in message card * theme: remove caching * editor: bring back icons in table menus * theme: use zustand to manage theme engine state * web: fix login/signup theming * mobile: fix webpack build * misc: remove ThemeProvider usage * editor: adjust theming and styling of editor toolbar * mobile: refactor * editor: fix toolbar group padding everywhere * web: fix settings sidebar is not scrollable * web: add loading indicator for themes loading * mobile: fix warning * mobile: fix ui issues * web: fix Loader errors on build * theme: add getPreviewColors & validateTheme * theme: fix theme validation * mobile: load theme from file * mobile: fix share extension crash * mobile: rename state * theme: add sourceURL property * theme: refactor theme-engine * web: add support for loading theme from file * web: improve button hover interaction * mobile: fix floating button color * mobile: update theme * mobile: fix border radius of context menu * mobile: set sheet overlay color to theme backdrop * mobile: set sidemenu backdrop to theme backdrop --------- Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
2023-08-01 12:07:21 +05:00
color={colors.secondary.heading}
2022-10-14 17:31:36 +05:00
>
2024-07-27 10:19:43 +05:00
{strings.exportSuccessHeading(ids.length)}
2022-09-16 16:02:40 +05:00
</Heading>
<Paragraph
2022-10-14 17:31:36 +05:00
style={{
textAlign: "center"
}}
2022-01-22 12:57:05 +05:00
>
2024-07-27 10:19:43 +05:00
{strings.exportSuccessDesc(result?.fileName as string)}
2022-09-16 16:02:40 +05:00
</Paragraph>
2022-10-14 17:31:36 +05:00
<Button
title={
2024-07-27 10:19:43 +05:00
Platform.OS === "android"
? strings.openFileLocation()
: strings.open()
}
2022-10-14 17:31:36 +05:00
type="accent"
width={250}
fontSize={SIZE.md}
style={{
marginTop: 10,
borderRadius: 100
}}
onPress={async () => {
2023-11-16 08:54:37 +05:00
if (!result?.filePath) return;
if (Platform.OS === "android") {
Linking.openURL(result.fileDir).catch((e) => {
ToastManager.error(e as Error);
});
} else {
FileViewer.open(result?.filePath, {
showOpenWithDialog: true,
showAppsSuggestions: true
}).catch((e) => {
ToastManager.show({
2024-08-06 15:05:38 +05:00
heading: strings.noApplicationFound(result.name),
type: "success",
context: "local"
});
2022-10-14 17:31:36 +05:00
});
}
2022-10-14 17:31:36 +05:00
}}
/>
<Button
2024-07-27 10:19:43 +05:00
title={strings.share()}
2024-02-05 12:14:45 +05:00
type="secondaryAccented"
2022-10-14 17:31:36 +05:00
width={250}
fontSize={SIZE.md}
style={{
marginTop: 10,
borderRadius: 100
}}
onPress={async () => {
if (!result) return;
2022-10-14 17:31:36 +05:00
if (Platform.OS === "ios") {
Share.open({
url: result?.fileDir + result.fileName
}).catch(() => {
/* empty */
});
2022-10-14 17:31:36 +05:00
} else {
FileViewer.open(result.filePath, {
showOpenWithDialog: true,
showAppsSuggestions: true,
shareFile: true
} as any).catch(() => {
/* empty */
});
2022-10-14 17:31:36 +05:00
}
}}
/>
<Button
2024-07-27 10:19:43 +05:00
title={strings.exportAgain()}
type="inverted"
2022-10-14 17:31:36 +05:00
width={250}
fontSize={SIZE.md}
style={{
marginTop: 10,
borderRadius: 100
}}
onPress={async () => {
setComplete(false);
2023-11-16 08:54:37 +05:00
setResult(undefined);
2022-10-14 17:31:36 +05:00
setExporting(false);
}}
/>
</>
)}
</View>
)}
2020-09-07 12:33:35 +05:00
</View>
2022-09-16 16:02:40 +05:00
</View>
2020-09-07 12:33:35 +05:00
);
};
2023-11-24 15:11:38 +05:00
ExportNotesSheet.present = async (ids?: string[], allNotes?: boolean) => {
const exportNoteIds = allNotes ? await db.notes.all?.ids() : ids || [];
2022-09-16 16:02:40 +05:00
presentSheet({
component: (ref, close, update) => (
2023-11-24 15:11:38 +05:00
<ExportNotesSheet ids={exportNoteIds} update={update} />
2024-01-29 11:01:49 +05:00
),
keyboardHandlerDisabled: true
2022-09-16 16:02:40 +05:00
});
};
2020-09-07 12:33:35 +05:00
const styles = StyleSheet.create({
container: {
2023-06-10 12:17:23 +05:00
...getElevationStyle(5),
2020-09-07 12:33:35 +05:00
borderRadius: 5,
2021-09-29 13:22:32 +05:00
paddingVertical: pv
2020-09-07 12:33:35 +05:00
},
buttonContainer: {
justifyContent: "space-between",
alignItems: "center"
2020-09-07 12:33:35 +05:00
},
button: {
paddingVertical: pv,
paddingHorizontal: ph,
marginTop: 10,
borderRadius: 5,
width: "100%",
justifyContent: "center",
alignItems: "center",
2020-09-07 12:33:35 +05:00
borderWidth: 1,
flexDirection: "row"
2020-09-07 12:33:35 +05:00
},
buttonText: {
2021-01-03 10:38:07 +05:00
//fontFamily: "sans-serif",
color: "white",
2020-09-07 12:33:35 +05:00
fontSize: SIZE.sm,
2021-09-29 13:22:32 +05:00
marginLeft: 5
2020-09-07 12:33:35 +05:00
},
overlay: {
width: "100%",
height: "100%",
position: "absolute"
2021-09-29 13:22:32 +05:00
}
2020-09-07 12:33:35 +05:00
});
2022-02-28 15:32:55 +05:00
export default ExportNotesSheet;