From 3375439e3530edfc9da0da48767252edb4c7e240 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Wed, 26 Feb 2025 10:18:41 +0500 Subject: [PATCH] mobile: refactor and fix bugs --- apps/mobile/app/app.tsx | 6 +- .../components/announcements/announcement.js | 8 +- .../app/components/announcements/body.js | 3 +- .../app/components/announcements/cta.js | 7 +- .../app/components/announcements/functions.js | 3 +- .../app/components/announcements/list.js | 5 +- .../components/announcements/subheading.js | 5 +- .../app/components/announcements/title.js | 11 +- .../app/components/attachments/actions.tsx | 24 ++- .../attachments/attachment-item.tsx | 5 +- .../app/components/attachments/index.tsx | 17 +- apps/mobile/app/components/auth/auth-modal.js | 5 +- .../app/components/auth/change-password.js | 5 +- .../app/components/auth/forgot-password.js | 7 +- apps/mobile/app/components/auth/index.js | 5 +- apps/mobile/app/components/auth/login.js | 20 +- .../app/components/auth/session-expired.js | 7 +- apps/mobile/app/components/auth/signup.js | 25 +-- apps/mobile/app/components/auth/two-factor.js | 29 ++- .../delay-layout/default-placeholder.tsx | 15 +- .../app/components/delay-layout/index.tsx | 8 +- .../delay-layout/settings-placeholder.tsx | 5 +- .../app/components/dialog/dialog-buttons.js | 17 +- .../app/components/dialog/dialog-header.tsx | 3 +- apps/mobile/app/components/dialog/index.js | 20 +- .../dialogs/applock-password/index.tsx | 3 +- .../dialogs/attach-image-dialog/index.tsx | 22 +- .../components/dialogs/color-picker/index.tsx | 11 +- .../dialogs/jump-to-section/index.tsx | 5 +- .../app/components/dialogs/loading/index.tsx | 3 +- .../components/dialogs/pdf-preview/index.js | 5 +- .../app/components/dialogs/progress/index.tsx | 7 +- .../app/components/dialogs/result/index.js | 13 +- .../components/dialogs/result/pro-features.js | 3 +- .../app/components/dialogs/vault/index.js | 7 +- apps/mobile/app/components/header/index.tsx | 2 +- .../app/components/image-preview/index.tsx | 3 +- apps/mobile/app/components/intro/index.tsx | 3 +- .../app/components/list-items/note/index.tsx | 4 +- .../components/list-items/notebook/index.tsx | 3 +- .../components/list-items/reminder/index.tsx | 17 +- .../list-items/selection-wrapper/index.tsx | 2 +- .../app/components/list-items/tag/index.tsx | 3 +- apps/mobile/app/components/list/empty.tsx | 6 +- apps/mobile/app/components/list/index.tsx | 9 +- .../app/components/merge-conflicts/index.js | 9 +- .../app/components/note-history/index.tsx | 7 +- .../app/components/note-history/preview.js | 5 +- .../components/premium/compact-features.js | 3 +- .../app/components/premium/component.js | 13 +- .../mobile/app/components/premium/expiring.js | 11 +- apps/mobile/app/components/premium/feature.js | 11 +- apps/mobile/app/components/premium/group.js | 7 +- .../app/components/premium/premium-toast.js | 3 +- .../app/components/premium/pricing-item.tsx | 3 +- .../app/components/premium/pricing-plans.tsx | 27 +-- apps/mobile/app/components/premium/pro-tag.js | 3 +- .../app/components/properties/color-tags.tsx | 69 +++---- .../app/components/properties/date-meta.js | 8 +- .../mobile/app/components/properties/index.js | 8 +- .../app/components/properties/notebooks.js | 9 +- apps/mobile/app/components/properties/tags.js | 13 +- .../app/components/sheet-provider/index.js | 13 +- .../components/sheets/add-notebook/index.tsx | 5 +- .../components/sheets/change-email/index.tsx | 5 +- .../components/sheets/editor-tabs/index.tsx | 3 +- .../components/sheets/export-notes/index.tsx | 27 +-- .../components/sheets/export-notes/share.jsx | 3 +- .../app/components/sheets/github/issue.js | 11 +- .../app/components/sheets/link-note/index.tsx | 17 +- .../components/sheets/manage-tags/index.tsx | 5 +- .../app/components/sheets/migrate/index.tsx | 15 +- .../components/sheets/new-feature/index.tsx | 7 +- .../components/sheets/publish-note/index.tsx | 21 +- .../app/components/sheets/rate-app/index.js | 3 +- .../components/sheets/recovery-key/index.jsx | 7 +- .../components/sheets/references/index.tsx | 7 +- .../sheets/relations-list/index.tsx | 3 +- .../sheets/reminder-notify/index.tsx | 15 +- .../app/components/sheets/reminder/index.tsx | 29 +-- .../app/components/sheets/toc/index.tsx | 5 +- .../app/components/sheets/update/index.js | 15 +- .../app/components/sheets/user/index.tsx | 3 +- .../mobile/app/components/side-menu/index.tsx | 3 + .../app/components/side-menu/menu-item.tsx | 2 +- .../components/side-menu/side-menu-home.tsx | 2 +- .../side-menu/side-menu-list-empty.tsx | 37 +++- .../side-menu/side-menu-notebooks.tsx | 9 +- .../components/side-menu/side-menu-tags.tsx | 28 ++- .../app/components/side-menu/user-status.js | 3 +- apps/mobile/app/components/tip/index.tsx | 18 +- apps/mobile/app/components/toast/index.tsx | 4 +- .../mobile/app/components/ui/button/index.tsx | 6 +- .../app/components/ui/icon-button/index.tsx | 13 +- apps/mobile/app/components/ui/input/index.tsx | 22 +- .../app/components/ui/reminder-time/index.tsx | 3 +- apps/mobile/app/components/ui/tag/index.tsx | 5 +- .../app/components/walkthroughs/index.tsx | 9 +- .../components/walkthroughs/walkthroughs.tsx | 45 +++-- apps/mobile/app/hooks/use-app-events.tsx | 7 +- apps/mobile/app/hooks/use-delay-layout.ts | 8 +- .../app/navigation/fluid-panels-view.tsx | 26 ++- .../app/navigation/navigation-stack.tsx | 191 ++++++++++++++---- .../app-lock}/index.tsx | 34 +++- apps/mobile/app/screens/editor/index.tsx | 5 +- apps/mobile/app/screens/editor/loading.tsx | 21 +- .../app/screens/editor/readonly-editor.tsx | 11 +- .../app/screens/editor/tiptap/use-editor.ts | 2 +- apps/mobile/app/screens/editor/wrapper.tsx | 2 + .../app/screens/link-notebooks/index.tsx | 2 +- .../app/screens/move-notebook/index.tsx | 4 +- apps/mobile/app/screens/move-notes/index.tsx | 2 + .../screens/note-preview-configure/index.tsx | 7 +- apps/mobile/app/screens/notebook/index.tsx | 10 +- apps/mobile/app/screens/notes/colored.tsx | 2 + apps/mobile/app/screens/notes/index.tsx | 2 +- apps/mobile/app/screens/notes/monographs.tsx | 1 + apps/mobile/app/screens/notes/tagged.tsx | 2 + apps/mobile/app/screens/search/index.tsx | 2 + apps/mobile/app/screens/search/search-bar.tsx | 6 +- apps/mobile/app/screens/settings/2fa.tsx | 17 +- apps/mobile/app/screens/settings/app-lock.js | 11 +- .../settings/attachment-group-progress.tsx | 7 +- .../app/screens/settings/components.tsx | 3 +- apps/mobile/app/screens/settings/debug.tsx | 12 +- .../settings/editor/configure-toolbar.tsx | 13 +- .../app/screens/settings/editor/group.tsx | 9 +- .../screens/settings/editor/tool-sheet.tsx | 7 +- .../app/screens/settings/editor/tool.tsx | 11 +- apps/mobile/app/screens/settings/group.tsx | 3 +- apps/mobile/app/screens/settings/home.tsx | 11 +- apps/mobile/app/screens/settings/licenses.tsx | 3 +- .../app/screens/settings/picker/index.tsx | 8 +- .../app/screens/settings/picker/pickers.jsx | 10 +- .../screens/settings/restore-backup/index.tsx | 9 +- .../app/screens/settings/section-group.tsx | 3 +- .../app/screens/settings/section-item.tsx | 16 +- .../app/screens/settings/server-config.tsx | 17 +- .../app/screens/settings/settings-data.tsx | 1 + .../app/screens/settings/sound-picker.tsx | 3 +- .../app/screens/settings/subscription.js | 3 +- .../app/screens/settings/theme-selector.tsx | 68 ++++--- .../app/screens/settings/title-format.tsx | 3 +- .../app/screens/settings/user-section.js | 7 +- apps/mobile/app/services/background-sync.ts | 1 + apps/mobile/app/services/exporter.ts | 1 + apps/mobile/app/services/settings.ts | 1 + .../app/stores/create-db-collection-store.ts | 6 +- apps/mobile/app/utils/global-refs.ts | 4 +- apps/mobile/app/utils/styles.ts | 4 +- apps/mobile/native/globals.js | 7 +- 151 files changed, 989 insertions(+), 670 deletions(-) rename apps/mobile/app/{components/app-lock-overlay => screens/app-lock}/index.tsx (92%) diff --git a/apps/mobile/app/app.tsx b/apps/mobile/app/app.tsx index 4fa4e2d71..fd31dabf6 100644 --- a/apps/mobile/app/app.tsx +++ b/apps/mobile/app/app.tsx @@ -39,8 +39,9 @@ import { themeTrpcClient } from "./screens/settings/theme-selector"; import Notifications from "./services/notifications"; import SettingsService from "./services/settings"; import { TipManager } from "./services/tip-manager"; -import { useThemeStore } from "./stores/use-theme-store"; +import { changeSystemBarColors, useThemeStore } from "./stores/use-theme-store"; import { useUserStore } from "./stores/use-user-store"; +import RNBootSplash from "react-native-bootsplash"; I18nManager.allowRTL(false); I18nManager.forceRTL(false); @@ -50,6 +51,9 @@ if (appLockEnabled || appLockMode !== "none") { useUserStore.getState().lockApp(true); } +RNBootSplash.hide({ fade: true }); +changeSystemBarColors(); + const App = (props: { configureMode: "note-preview" }) => { useAppEvents(); //@ts-ignore diff --git a/apps/mobile/app/components/announcements/announcement.js b/apps/mobile/app/components/announcements/announcement.js index 2512ed45f..d498eedbf 100644 --- a/apps/mobile/app/components/announcements/announcement.js +++ b/apps/mobile/app/components/announcements/announcement.js @@ -24,6 +24,7 @@ import { useMessageStore } from "../../stores/use-message-store"; import { useSelectionStore } from "../../stores/use-selection-store"; import { allowedOnPlatform, renderItem } from "./functions"; import { getContainerBorder } from "../../utils/colors"; +import { DefaultAppStyles } from "../../utils/styles"; export const Announcement = ({ color }) => { const { colors } = useThemeColors(); @@ -36,9 +37,8 @@ export const Announcement = ({ color }) => { style={{ backgroundColor: colors.primary.background, width: "100%", - paddingHorizontal: 12, - paddingTop: 12, - paddingBottom: 12 + paddingHorizontal: DefaultAppStyles.GAP, + paddingVertical: DefaultAppStyles.GAP_VERTICAL }} > { {announcement?.body diff --git a/apps/mobile/app/components/announcements/body.js b/apps/mobile/app/components/announcements/body.js index b45eee919..4367baa36 100644 --- a/apps/mobile/app/components/announcements/body.js +++ b/apps/mobile/app/components/announcements/body.js @@ -20,12 +20,13 @@ along with this program. If not, see . import React from "react"; import Paragraph from "../ui/typography/paragraph"; import { getStyle } from "./functions"; +import { DefaultAppStyles } from "../../utils/styles"; export const Body = ({ text, style = {} }) => { return ( diff --git a/apps/mobile/app/components/announcements/cta.js b/apps/mobile/app/components/announcements/cta.js index 6c53315a4..ae7038091 100644 --- a/apps/mobile/app/components/announcements/cta.js +++ b/apps/mobile/app/components/announcements/cta.js @@ -29,6 +29,7 @@ import { PricingPlans } from "../premium/pricing-plans"; import SheetProvider from "../sheet-provider"; import { Button } from "../ui/button"; import { allowedOnPlatform, getStyle } from "./functions"; +import { DefaultAppStyles } from "../../utils/styles"; export const Cta = ({ actions, style = {}, color, inline }) => { const { colors } = useThemeColors(); @@ -61,7 +62,7 @@ export const Cta = ({ actions, style = {}, color, inline }) => { return ( { onPress={() => onPress(item)} width={250} style={{ - marginBottom: 5, + marginBottom: DefaultAppStyles.GAP_VERTICAL, borderRadius: 100 }} /> @@ -148,7 +149,7 @@ export const Cta = ({ actions, style = {}, color, inline }) => { height={30} style={{ minWidth: "50%", - marginTop: 5 + marginTop: DefaultAppStyles.GAP_VERTICAL_SMALL }} textStyle={{ textDecorationLine: "underline" diff --git a/apps/mobile/app/components/announcements/functions.js b/apps/mobile/app/components/announcements/functions.js index 16dbd86d9..e5c61d7d3 100644 --- a/apps/mobile/app/components/announcements/functions.js +++ b/apps/mobile/app/components/announcements/functions.js @@ -28,6 +28,7 @@ import { List } from "./list"; import { Photo } from "./photo"; import { SubHeading } from "./subheading"; import { Title } from "./title"; +import { DefaultAppStyles } from "../../utils/styles"; export function allowedOnPlatform(platforms) { if (!platforms) return true; @@ -53,7 +54,7 @@ const Features = () => { return ( { return ( { diff --git a/apps/mobile/app/components/announcements/subheading.js b/apps/mobile/app/components/announcements/subheading.js index 87c7ee635..7c05efb1a 100644 --- a/apps/mobile/app/components/announcements/subheading.js +++ b/apps/mobile/app/components/announcements/subheading.js @@ -21,14 +21,15 @@ import React from "react"; import { AppFontSize } from "../../utils/size"; import Heading from "../ui/typography/heading"; import { getStyle } from "./functions"; +import { DefaultAppStyles } from "../../utils/styles"; export const SubHeading = ({ text, style = {} }) => { return ( diff --git a/apps/mobile/app/components/announcements/title.js b/apps/mobile/app/components/announcements/title.js index 5b019ba13..e40b7c15b 100644 --- a/apps/mobile/app/components/announcements/title.js +++ b/apps/mobile/app/components/announcements/title.js @@ -24,6 +24,7 @@ import { AppFontSize } from "../../utils/size"; import { Button } from "../ui/button"; import Heading from "../ui/typography/heading"; import { getStyle } from "./functions"; +import { DefaultAppStyles } from "../../utils/styles"; export const Title = ({ text, style = {}, inline }) => { const announcements = useMessageStore((state) => state.announcements); @@ -36,13 +37,13 @@ export const Title = ({ text, style = {}, inline }) => { flexDirection: "row", justifyContent: "space-between", alignItems: "center", - marginBottom: inline ? 5 : 0 + marginBottom: inline ? DefaultAppStyles.GAP_VERTICAL_SMALL : 0 }} > { ) : ( {text} diff --git a/apps/mobile/app/components/attachments/actions.tsx b/apps/mobile/app/components/attachments/actions.tsx index 594599c5e..39f6bb26a 100644 --- a/apps/mobile/app/components/attachments/actions.tsx +++ b/apps/mobile/app/components/attachments/actions.tsx @@ -58,6 +58,7 @@ import { Pressable } from "../ui/pressable"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { strings } from "@notesnook/intl"; +import { DefaultAppStyles } from "../../utils/styles"; const Actions = ({ attachment, @@ -226,12 +227,13 @@ const Actions = ({ style={{ borderBottomWidth: 1, borderBottomColor: colors.primary.border, - marginBottom: notes && notes.length > 0 ? 0 : 12 + marginBottom: + notes && notes.length > 0 ? 0 : DefaultAppStyles.GAP_VERTICAL }} > @@ -241,9 +243,9 @@ const Actions = ({ @@ -283,14 +285,14 @@ const Actions = ({ style={{ borderBottomWidth: 1, borderBottomColor: colors.primary.border, - marginBottom: 12, - paddingVertical: 12 + marginBottom: DefaultAppStyles.GAP_VERTICAL, + paddingVertical: DefaultAppStyles.GAP_VERTICAL }} > <> @@ -307,10 +309,10 @@ const Actions = ({ openNote(item, (item as any).type === "trash"); }} style={{ - paddingVertical: 12, + paddingVertical: DefaultAppStyles.GAP_VERTICAL, alignItems: "flex-start", - paddingHorizontal: 12 + paddingHorizontal: DefaultAppStyles.GAP }} key={item.id} > @@ -347,7 +349,7 @@ const Actions = ({ {failed ? ( diff --git a/apps/mobile/app/components/attachments/attachment-item.tsx b/apps/mobile/app/components/attachments/attachment-item.tsx index 6ba399b88..c70d44cc9 100644 --- a/apps/mobile/app/components/attachments/attachment-item.tsx +++ b/apps/mobile/app/components/attachments/attachment-item.tsx @@ -32,6 +32,7 @@ import Paragraph from "../ui/typography/paragraph"; import Actions from "./actions"; import { strings } from "@notesnook/intl"; import { Pressable } from "../ui/pressable"; +import { DefaultAppStyles } from "../../utils/styles"; function getFileExtension(filename: string) { const ext = /^.+\.([^.]+)$/.exec(filename); @@ -76,8 +77,8 @@ export const AttachmentItem = ({ flexDirection: "row", marginVertical: 5, justifyContent: "space-between", - padding: 12, - paddingVertical: 6, + padding: DefaultAppStyles.GAP, + paddingVertical: DefaultAppStyles.GAP_VERTICAL, minHeight: 45 }} > diff --git a/apps/mobile/app/components/attachments/index.tsx b/apps/mobile/app/components/attachments/index.tsx index f20b2fc3a..b50a795c4 100644 --- a/apps/mobile/app/components/attachments/index.tsx +++ b/apps/mobile/app/components/attachments/index.tsx @@ -50,6 +50,7 @@ import Seperator from "../ui/seperator"; import Heading from "../ui/typography/heading"; import Paragraph from "../ui/typography/paragraph"; import { AttachmentItem } from "./attachment-item"; +import { DefaultAppStyles } from "../../utils/styles"; const DEFAULT_SORTING: SortOptions = { sortBy: "dateEdited", @@ -357,7 +358,7 @@ export const AttachmentDialog = ({ flexDirection: "row", justifyContent: "space-between", alignItems: "center", - paddingHorizontal: 12 + paddingHorizontal: DefaultAppStyles.GAP }} > {strings.dataTypesPluralCamelCase.attachment()} @@ -370,8 +371,6 @@ export const AttachmentDialog = ({ { if (!attachments) return; @@ -409,7 +404,7 @@ export const AttachmentDialog = ({ style={{ width: "100%", alignSelf: "center", - paddingHorizontal: 12, + paddingHorizontal: DefaultAppStyles.GAP, height: "100%" }} > @@ -429,7 +424,7 @@ export const AttachmentDialog = ({ alignItems: "center", width: "100%", borderRadius: 10, - padding: 10, + padding: DefaultAppStyles.GAP_SMALL, borderWidth: 1, borderColor: colors.primary.border, gap: 12, @@ -495,7 +490,7 @@ export const AttachmentDialog = ({ backgroundColor: colors.primary.background, flexWrap: "wrap", flexDirection: "row", - paddingVertical: 12 + paddingVertical: DefaultAppStyles.GAP_VERTICAL }} contentContainerStyle={{ alignItems: "center" @@ -515,7 +510,7 @@ export const AttachmentDialog = ({ fontSize={AppFontSize.sm} style={{ borderRadius: 100, - paddingHorizontal: 12, + paddingHorizontal: DefaultAppStyles.GAP, height: 40, minWidth: 80 }} diff --git a/apps/mobile/app/components/auth/auth-modal.js b/apps/mobile/app/components/auth/auth-modal.js index 72edd3a07..3f81926aa 100644 --- a/apps/mobile/app/components/auth/auth-modal.js +++ b/apps/mobile/app/components/auth/auth-modal.js @@ -37,6 +37,7 @@ import { hideAuth, initialAuthMode } from "./common"; import { Login } from "./login"; import { Signup } from "./signup"; import { strings } from "@notesnook/intl"; +import { DefaultAppStyles } from "../../utils/styles"; export const AuthMode = { login: 0, @@ -133,7 +134,7 @@ const AuthModal = () => { style={{ flexDirection: "row", alignItems: "center", - paddingHorizontal: 12, + paddingHorizontal: DefaultAppStyles.GAP, width: "100%", height: 50, justifyContent: @@ -167,7 +168,7 @@ const AuthModal = () => { marginTop: 2 }} style={{ - paddingHorizontal: 6 + paddingHorizontal: DefaultAppStyles.GAP_SMALL }} /> )} diff --git a/apps/mobile/app/components/auth/change-password.js b/apps/mobile/app/components/auth/change-password.js index 9ed6857f1..321f22746 100644 --- a/apps/mobile/app/components/auth/change-password.js +++ b/apps/mobile/app/components/auth/change-password.js @@ -36,6 +36,7 @@ import { Dialog } from "../dialog"; import BackupService from "../../services/backup"; import { sleep } from "../../utils/time"; import { strings } from "@notesnook/intl"; +import { DefaultAppStyles } from "../../utils/styles"; export const ChangePassword = () => { const passwordInputRef = useRef(); @@ -103,7 +104,7 @@ export const ChangePassword = () => { @@ -148,7 +149,7 @@ export const ChangePassword = () => {