diff --git a/.env.example b/.env.example index 25e5069..dc18694 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,10 @@ -#DO NOT COMMIT THIS +# Copy to .env and fill in. Never commit .env. + +# Read by the app at runtime (inlined at build time); see src/utils/env.ts. EXPO_PUBLIC_REVENUECAT_IOS_API_KEY= EXPO_PUBLIC_REVENUECAT_ANDROID_API_KEY= EXPO_PUBLIC_SENTRY_DSN= + +# Build-time only: lets the Sentry Expo plugin upload source maps during +# EAS / release builds. Store it as an EAS secret for cloud builds. +SENTRY_AUTH_TOKEN= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..db48b2b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + pull_request: + push: + branches: [master] + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + name: Lint, typecheck and locales + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v5 + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.4.4 + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Verify locales + run: bun run verify:locales + + - name: Lint + run: bun run lint + + # Generates Expo Router's typed routes first, so hrefs are checked too. + - name: Typecheck + run: bun run typecheck diff --git a/.oxlintrc.json b/.oxlintrc.json index 69b90b8..19e1634 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -1,13 +1,33 @@ { "$schema": "./node_modules/oxlint/configuration_schema.json", - "plugins": ["typescript", "unicorn", "oxc", "react", "react-hooks"], + "plugins": [ + "typescript", + "unicorn", + "oxc", + "react", + "react-hooks" + ], "categories": { - "correctness": "error" + "correctness": "error", + "suspicious": "error", + "perf": "error" }, "rules": { - "no-explicit-any": "off" + "typescript/no-explicit-any": "error", + "react/react-in-jsx-scope": "off", + "react/style-prop-object": "off", + "react/no-unstable-nested-components": [ + "error", + { + "allowAsProps": true + } + ], + "no-underscore-dangle": "off" }, - "ignorePatterns": [".agents/**"], + "ignorePatterns": [ + ".agents/**", + ".expo/**" + ], "env": { "builtin": true } diff --git a/AGENTS.md b/AGENTS.md index 75ddf4a..3cfc67b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,7 +44,8 @@ app/ ├── (tabs)/ │ ├── _layout.tsx # bottom tabs layout │ ├── index.tsx # route wrapper -> @/screens/tab-one -│ └── tab-two.tsx # route wrapper -> @/screens/tab-two +│ ├── tab-two.tsx # route wrapper -> @/screens/tab-two +│ └── settings.tsx # route wrapper -> @/screens/settings ├── stack-one.tsx # route wrapper -> @/screens/stack-one ├── modal-one.tsx # route wrapper -> @/screens/modal-one └── +not-found.tsx # route wrapper -> @/screens/not-found @@ -52,6 +53,7 @@ src/ ├── screens/ # screen UI rendered by routes │ ├── tab-one/ │ ├── tab-two/ +│ ├── settings/ │ ├── stack-one/ │ ├── modal-one/ │ └── not-found/ @@ -59,7 +61,7 @@ src/ │ ├── common/ # shared primitives (pressable, error-boundary, legend-list) │ └── layouts/ # Layout.Base / Bare / Modal ├── data/ # WatermelonDB schema, migrations, models/, database instance -├── hooks/ # app-wide hooks (refresh control) +├── hooks/ # app-wide hooks (refresh control, WatermelonDB useQuery) ├── i18n/ # initializeI18n + locales//.json ├── providers/ # MainProvider (TamaguiProvider + ErrorBoundary + DatabaseProvider + theme tracking) ├── stores/ # app observables (settings$) @@ -235,7 +237,7 @@ Do not persist derived data, functions, or React nodes. Do not create a new MMKV - Everything lives in `src/data/`: `schema.ts`, `migrations.ts`, `models/.ts`, `database.ts` (Nitro SQLite adapter, plus `define-columns.ts`). Export from `src/data/index.ts`; `DatabaseProvider` is composed into `MainProvider`. - Changing a table: bump `version` in `schema.ts` **and** add a step in `migrations.ts`. Register new models in `modelClasses`. - Models do not use decorators (`experimentalDecorators` is off). Declare typed fields on the class and bind them with `Object.defineProperties(Model.prototype, defineColumns({...}))` from `src/data/define-columns.ts` (see `models/note.ts`). -- Read via `useDatabase()` + `collection.query(...).observe()` (see `src/screens/tab-two/useNotes.ts`); write inside `database.write(...)`. +- Read with `useQuery("table", [Q...])` from `@/hooks/useQuery` (waits for `databaseReady`, subscribes, cleans up; see `src/screens/tab-two/useNotes.ts`); write inside `database.write(...)`. - Needs a development build (not Expo Go); the native engine is a Nitro module (`react-native-nitro-modules`, `rxjs` peer). Await `databaseReady` from `@/data` before the first query or write. - Do not put queryable/relational data in `settings$` or MMKV. diff --git a/app.json b/app.json index 3491950..764a694 100644 --- a/app.json +++ b/app.json @@ -7,7 +7,8 @@ "scheme": "mytemplateproject", "userInterfaceStyle": "automatic", "experiments": { - "reactCompiler": true + "reactCompiler": true, + "typedRoutes": true }, "assetBundlePatterns": ["**/*"], "ios": { diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx index ed2f092..614057b 100644 --- a/app/(tabs)/_layout.tsx +++ b/app/(tabs)/_layout.tsx @@ -35,6 +35,13 @@ export default function TabLayout() { tabBarIcon: ({ color, size }) => , }} /> + , + }} + /> ); } diff --git a/app/(tabs)/settings.tsx b/app/(tabs)/settings.tsx new file mode 100644 index 0000000..b6dac30 --- /dev/null +++ b/app/(tabs)/settings.tsx @@ -0,0 +1 @@ +export { SettingsScreen as default } from "@/screens/settings"; diff --git a/app/_layout.tsx b/app/_layout.tsx index f1e168d..2076a95 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -77,9 +77,16 @@ function RootLayout() { } didInitRef.current = true; + // RevenueCat fetches customer info over the network, so it runs in the + // background; its listener updates `premium` when the answer arrives. + initializeRevenueCat().catch((error: unknown) => { + logger.error("RevenueCat initialization failed:", error); + captureException(error); + }); + (async () => { try { - const [language] = await Promise.all([initializeI18n(), initializeRevenueCat()]); + const language = await initializeI18n(); settings$.language.set(language); } catch (error) { logger.error("Root initialization failed:", error); diff --git a/assets/icons/nanoicons/ui.glyphmap.json b/assets/icons/nanoicons/ui.glyphmap.json index 63a578e..414b04c 100644 --- a/assets/icons/nanoicons/ui.glyphmap.json +++ b/assets/icons/nanoicons/ui.glyphmap.json @@ -1 +1 @@ -{"m":{"f":"ui-c5f20b27","u":1024,"z":1024,"s":59648,"h":"c5f20b27fe9971b2354e13971b9366bdfe82d51919eecb9a473e237bef63337b"},"i":{"chevron-left":[1024,[[59648,"currentColor"]]],"clock":[1024,[[59649,"currentColor"]]],"house":[1024,[[59650,"currentColor"]]],"x":[1024,[[59651,"currentColor"]]]}} \ No newline at end of file +{"m":{"f":"ui-071fbd38","u":1024,"z":1024,"s":59648,"h":"071fbd38d91bcd3158a95c56361ea6dfe16aa0c435cd8ad2d40724aefd4e2fae"},"i":{"chevron-left":[1024,[[59648,"currentColor"]]],"clock":[1024,[[59649,"currentColor"]]],"house":[1024,[[59650,"currentColor"]]],"settings":[1024,[[59651,"currentColor"]]],"x":[1024,[[59652,"currentColor"]]]}} \ No newline at end of file diff --git a/assets/icons/nanoicons/ui.ttf b/assets/icons/nanoicons/ui.ttf index bfe9f08..407c6b3 100644 Binary files a/assets/icons/nanoicons/ui.ttf and b/assets/icons/nanoicons/ui.ttf differ diff --git a/assets/icons/ui/settings.svg b/assets/icons/ui/settings.svg new file mode 100644 index 0000000..f4fc792 --- /dev/null +++ b/assets/icons/ui/settings.svg @@ -0,0 +1,4 @@ + + + + diff --git a/package.json b/package.json index 6b35426..71f981c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "codegen": "bun ./scripts/codegen.mjs", "lint": "oxlint .", "format": "bun fmt", - "typecheck": "bun check", + "typegen": "expo customize tsconfig.json", + "typecheck": "bun run typegen && bun check", "verify:locales": "bun ./scripts/verify-locales.mjs", "prebuild": "bunx expo prebuild --clean", "prebuild:dev": "APP_VARIANT=development bunx expo prebuild --clean", diff --git a/scripts/verify-locales.mjs b/scripts/verify-locales.mjs index 6103cfb..32b879f 100644 --- a/scripts/verify-locales.mjs +++ b/scripts/verify-locales.mjs @@ -44,7 +44,7 @@ const namespacesDir = path.join(import.meta.dirname, "../src/i18n/locales"); const languages = fs .readdirSync(namespacesDir) .filter((f) => fs.statSync(path.join(namespacesDir, f)).isDirectory()) - .sort(); + .toSorted(); if (languages.length === 0) { process.stderr.write("❌ No language directories found\n"); @@ -62,7 +62,7 @@ const namespaces = fs .readdirSync(referenceLangDir) .filter((f) => f.endsWith(".json")) .map((f) => path.basename(f, ".json")) - .sort(); + .toSorted(); if (namespaces.length === 0) { process.stderr.write(`❌ No namespace files found in ${referenceLanguage}\n`); @@ -78,7 +78,7 @@ for (const lang of languages) { .readdirSync(langDir) .filter((f) => f.endsWith(".json")) .map((f) => path.basename(f, ".json")) - .sort(); + .toSorted(); const missingNamespaces = namespaces.filter((ns) => !langNamespaces.includes(ns)); const extraNamespaces = langNamespaces.filter((ns) => !namespaces.includes(ns)); @@ -139,7 +139,7 @@ for (const namespace of namespaces) { hasErrors = true; const noun = missingKeys.length === 1 ? "key" : "keys"; process.stderr.write(`❌ ${namespace}.json (${lang}): Missing ${missingKeys.length} ${noun}\n`); - missingKeys.sort(); + missingKeys.toSorted(); const displayCount = isVerbose ? missingKeys.length : 5; for (const key of missingKeys.slice(0, displayCount)) { process.stderr.write(` ${key}\n`); @@ -159,7 +159,7 @@ for (const namespace of namespaces) { hasErrors = true; const noun = extraKeys.length === 1 ? "key" : "keys"; process.stderr.write(`❌ ${namespace}.json (${lang}): Extra ${extraKeys.length} ${noun}\n`); - extraKeys.sort(); + extraKeys.toSorted(); const displayCount = isVerbose ? extraKeys.length : 5; for (const key of extraKeys.slice(0, displayCount)) { process.stderr.write(` ${key}\n`); diff --git a/src/components/common/error-boundary.tsx b/src/components/common/error-boundary.tsx index 82e4c36..5576230 100644 --- a/src/components/common/error-boundary.tsx +++ b/src/components/common/error-boundary.tsx @@ -1,10 +1,11 @@ import { router } from "expo-router"; import { Component, type ErrorInfo, type FC, type ReactNode } from "react"; import { useTranslation } from "react-i18next"; -import { Pressable, ScrollView } from "react-native"; +import { ScrollView } from "react-native"; import { Text, View } from "@tamagui/tailwind"; import { getTokenValue } from "tamagui"; +import { Pressable } from "@/components/common/pressable"; import { logger } from "@/utils/logger"; import { captureException } from "@/utils/sentry"; @@ -77,7 +78,7 @@ export class ErrorBoundary extends Component>(component: Component, className: string) { - return styled(component as unknown as TailwindComponent>, className); +export function styledNative(component: ComponentType, className: string) { + return styled(component as unknown as TailwindComponent, className); } diff --git a/src/components/layouts/Bare.tsx b/src/components/layouts/Bare.tsx index b316dad..4e188b7 100644 --- a/src/components/layouts/Bare.tsx +++ b/src/components/layouts/Bare.tsx @@ -1,10 +1,10 @@ import { View } from "@tamagui/tailwind"; import type { FC } from "react"; -import { SafeScreen } from "./safe-screen"; +import { DEFAULT_SAFE_AREA_EDGES, SafeScreen } from "./safe-screen"; import type { BareLayoutProps } from "./types"; -export const BareLayout: FC = ({ children, contentContainerStyle, safeAreaEdges = ["top"] }) => { +export const BareLayout: FC = ({ children, contentContainerStyle, safeAreaEdges = DEFAULT_SAFE_AREA_EDGES }) => { return ( diff --git a/src/components/layouts/Base.tsx b/src/components/layouts/Base.tsx index b20b0d7..dc0a68c 100644 --- a/src/components/layouts/Base.tsx +++ b/src/components/layouts/Base.tsx @@ -7,7 +7,7 @@ import { useTranslation } from "react-i18next"; import { Icon } from "@/components/common/icon"; import { IconButton } from "@/components/common/icon-button"; import { useTheme } from "@/theme/hooks/useTheme"; -import { SafeScreen } from "./safe-screen"; +import { DEFAULT_SAFE_AREA_EDGES, SafeScreen } from "./safe-screen"; import type { BaseLayoutProps } from "./types"; export const BaseLayout: FC = ({ @@ -16,7 +16,7 @@ export const BaseLayout: FC = ({ onBack, children, contentContainerStyle, - safeAreaEdges = ["top"], + safeAreaEdges = DEFAULT_SAFE_AREA_EDGES, callToAction, }) => { const router = useRouter(); diff --git a/src/components/layouts/safe-screen.tsx b/src/components/layouts/safe-screen.tsx index 2c7d51c..0bfc860 100644 --- a/src/components/layouts/safe-screen.tsx +++ b/src/components/layouts/safe-screen.tsx @@ -3,3 +3,8 @@ import { SafeAreaView } from "react-native-safe-area-context"; import { styledNative } from "@/components/common/styled-native"; export const SafeScreen = styledNative(SafeAreaView, "flex-1 bg-background-primary"); + +export type SafeAreaEdge = "top" | "bottom" | "left" | "right"; + +/** Stable default so layouts don't pass a new array to SafeAreaView each render. */ +export const DEFAULT_SAFE_AREA_EDGES: readonly SafeAreaEdge[] = ["top"]; diff --git a/src/components/layouts/types.ts b/src/components/layouts/types.ts index 68b4e5b..82567ab 100644 --- a/src/components/layouts/types.ts +++ b/src/components/layouts/types.ts @@ -1,20 +1,25 @@ -import type { ReactNode } from "react"; -import type { ViewProps } from "react-native"; +import type { View } from "@tamagui/tailwind"; +import type { ComponentProps, ReactNode } from "react"; + +import type { SafeAreaEdge } from "./safe-screen"; + +/** Style accepted by the `@tamagui/tailwind` `View` that hosts layout content. */ +type ContentStyle = ComponentProps["style"]; export interface BareLayoutProps { children?: ReactNode; - contentContainerStyle?: ViewProps["style"]; - safeAreaEdges?: ("top" | "bottom" | "left" | "right")[]; + contentContainerStyle?: ContentStyle; + safeAreaEdges?: readonly SafeAreaEdge[]; } export interface BaseLayoutProps { children: ReactNode; title?: string; showBack?: boolean; - safeAreaEdges?: ("top" | "bottom" | "left" | "right")[]; + safeAreaEdges?: readonly SafeAreaEdge[]; onBack?: () => void; callToAction?: ReactNode; - contentContainerStyle?: ViewProps["style"]; + contentContainerStyle?: ContentStyle; } export interface ModalLayoutProps { diff --git a/src/data/define-columns.ts b/src/data/define-columns.ts index f13c41c..5f646d2 100644 --- a/src/data/define-columns.ts +++ b/src/data/define-columns.ts @@ -10,8 +10,7 @@ type RawValue = Parameters[1]; */ export function defineColumns(spec: Record): PropertyDescriptorMap { const descriptors: PropertyDescriptorMap = {}; - for (const property of Object.keys(spec)) { - const column = spec[property]; + for (const [property, column] of Object.entries(spec)) { descriptors[property] = { configurable: true, enumerable: true, diff --git a/src/data/models/note.ts b/src/data/models/note.ts index 19aaa72..bc4c430 100644 --- a/src/data/models/note.ts +++ b/src/data/models/note.ts @@ -3,7 +3,7 @@ import { Model } from "react-native-watermelondb"; import { defineColumns } from "../define-columns"; export class Note extends Model { - static table = "notes"; + static override table = "notes"; title!: string; /** Epoch ms; WatermelonDB fills `created_at` / `updated_at` automatically. */ diff --git a/src/hooks/useQuery.ts b/src/hooks/useQuery.ts new file mode 100644 index 0000000..fb6a10a --- /dev/null +++ b/src/hooks/useQuery.ts @@ -0,0 +1,57 @@ +import { useEffect, useState } from "react"; +import type { Model } from "react-native-watermelondb"; +import type { Clause } from "react-native-watermelondb/QueryDescription"; +import { useDatabase } from "react-native-watermelondb/react"; + +import { databaseReady } from "@/data"; +import { logger } from "@/utils/logger"; +import { captureException } from "@/utils/sentry"; + +/** + * Live WatermelonDB query: waits for `databaseReady`, subscribes to the + * results and unsubscribes on unmount or when the query changes. + * + * Clauses are compared by value, so inline `Q.where(...)` calls are fine. + * + * ```ts + * const notes = useQuery("notes", [Q.sortBy("created_at", Q.desc)]); + * ``` + */ +export function useQuery(table: string, clauses: readonly Clause[] = []): T[] { + const database = useDatabase(); + const [records, setRecords] = useState([]); + + // Q clauses are plain data, so their JSON is a stable identity for the query + // and round-trips back to the same clauses inside the effect. + const queryKey = JSON.stringify(clauses); + + useEffect(() => { + let cancelled = false; + let unsubscribe: (() => void) | undefined; + + databaseReady + .then(() => { + if (cancelled) { + return; + } + const queryClauses = JSON.parse(queryKey) as Clause[]; + const subscription = database + .get(table) + .query(...queryClauses) + .observe() + .subscribe(setRecords); + unsubscribe = () => subscription.unsubscribe(); + }) + .catch((error: unknown) => { + logger.error(`Query on "${table}" failed:`, error); + captureException(error); + }); + + return () => { + cancelled = true; + unsubscribe?.(); + }; + }, [database, table, queryKey]); + + return records; +} diff --git a/src/i18n/i18next.d.ts b/src/i18n/i18next.d.ts new file mode 100644 index 0000000..f6dc59f --- /dev/null +++ b/src/i18n/i18next.d.ts @@ -0,0 +1,10 @@ +import type { resources } from "./index"; + +// Types `t()` keys and namespaces from the English JSON, so a typo or a key +// missing from `locales/en` is a compile error. +declare module "i18next" { + interface CustomTypeOptions { + defaultNS: "common"; + resources: (typeof resources)["en"]; + } +} diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 4238b32..67a903d 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -17,7 +17,7 @@ const extractLanguageCode = (locale: string | undefined): string => { if (!locale || typeof locale !== "string") { return FALLBACK_LANGUAGE; } - const languageCode = locale.split("_")[0].split("-")[0].toLowerCase(); + const languageCode = locale.split(/[-_]/)[0]?.toLowerCase() ?? FALLBACK_LANGUAGE; return SUPPORTED_LANGUAGES.includes(languageCode as Languages) ? languageCode : FALLBACK_LANGUAGE; }; @@ -82,7 +82,7 @@ export const setAppLanguage = async (language: string): Promise => { logger.warn("Unsupported language:", language); return; } - storage.setString(StorageKeys.LANGUAGE, language); + storage.set(StorageKeys.LANGUAGE, language); await i18n.changeLanguage(language); }; diff --git a/src/i18n/locales/en/screens.json b/src/i18n/locales/en/screens.json index 2b14734..478e125 100644 --- a/src/i18n/locales/en/screens.json +++ b/src/i18n/locales/en/screens.json @@ -35,5 +35,44 @@ "title": "Bottom sheet", "body": "The universal BottomSheet is a sibling of Host, not nested in it." } + }, + "settings": { + "title": "Settings", + "appearance": { + "title": "Appearance", + "followSystem": "Match system", + "darkMode": "Dark mode" + }, + "display": { + "title": "Display", + "language": "Language", + "textSize": "Text size", + "dateFormat": "Date format" + }, + "languages": { + "en": "English" + }, + "textSizes": { + "smaller": "Smaller", + "default": "Default", + "bigger": "Bigger" + }, + "subscription": { + "title": "Subscription", + "status": "Status", + "premium": "Premium", + "free": "Free", + "upgrade": "Upgrade to Premium", + "restore": "Restore purchases", + "purchased": "Welcome to Premium", + "restored": "Purchases restored", + "nothingToRestore": "No purchases to restore", + "paywallFailed": "Couldn't open the paywall. Try again.", + "restoreFailed": "Couldn't restore purchases. Try again." + }, + "about": { + "title": "About", + "version": "Version" + } } } diff --git a/src/screens/settings/index.tsx b/src/screens/settings/index.tsx new file mode 100644 index 0000000..255a076 --- /dev/null +++ b/src/screens/settings/index.tsx @@ -0,0 +1,145 @@ +import { Button, FieldGroup, Host, Picker, Row, Spacer, Switch, Text } from "@expo/ui"; +import { useBottomTabBarHeight } from "expo-router/tabs"; +import { useCallback, useState } from "react"; +import { useTranslation } from "react-i18next"; + +import { Toast } from "@/components/common/toast"; +import { SafeScreen } from "@/components/layouts/safe-screen"; +import { SUPPORTED_LANGUAGES } from "@/i18n"; +import { useSettingsStore } from "@/stores/settings"; +import { useThemeStore } from "@/theme/stores/useThemeStore"; +import type { TextSizePreference } from "@/theme/types"; +import type { ValidDateFormat } from "@/types/date"; +import { formatDate } from "@/utils/date"; +import { env } from "@/utils/env"; +import { hasPremiumEntitlement, PAYWALL_PLACEMENTS, presentPaywall, restorePurchases } from "@/utils/revenuecat"; + +const TEXT_SIZES: readonly TextSizePreference[] = ["smaller", "default", "bigger"]; +const DATE_FORMATS: readonly ValidDateFormat[] = ["DD/MM/YYYY", "MM/DD/YYYY", "YYYY/MM/DD"]; +const FILL = { flex: 1 } as const; +// Day 31 makes the day/month order of each format obvious in the picker. +const SAMPLE_DATE = new Date(2026, 11, 31); + +export function SettingsScreen() { + const { t } = useTranslation("screens"); + const tabBarHeight = useBottomTabBarHeight(); + const [toastMessage, setToastMessage] = useState(null); + const hideToast = useCallback(() => setToastMessage(null), []); + + const mode = useThemeStore((s) => s.mode); + const followSystemTheme = useThemeStore((s) => s.followSystemTheme); + const language = useSettingsStore((s) => s.language); + const textSizePreference = useSettingsStore((s) => s.textSizePreference); + const dateFormat = useSettingsStore((s) => s.dateFormat); + const premium = useSettingsStore((s) => s.premium); + const isDark = mode === "dark"; + + const handleFollowSystem = (value: boolean) => { + useThemeStore.getState().setConfig({ followSystemTheme: value, defaultMode: mode }); + }; + + const handleUpgrade = async () => { + const result = await presentPaywall(PAYWALL_PLACEMENTS.subscription); + if (result.success) { + setToastMessage(t("settings.subscription.purchased")); + } else if (!result.cancelled) { + setToastMessage(t("settings.subscription.paywallFailed")); + } + }; + + const handleRestore = async () => { + const result = await restorePurchases(); + if (!result.success) { + setToastMessage(t("settings.subscription.restoreFailed")); + } else if (hasPremiumEntitlement(result.customerInfo)) { + setToastMessage(t("settings.subscription.restored")); + } else { + setToastMessage(t("settings.subscription.nothingToRestore")); + } + }; + + return ( + + + + + + useThemeStore.getState().setMode(value ? "dark" : "light")} + /> + + + + + {t("settings.display.language")} + + useSettingsStore.getState().setLanguage(code)} + > + {SUPPORTED_LANGUAGES.map((code) => ( + + ))} + + + + {t("settings.display.textSize")} + + useSettingsStore.getState().setTextSizePreference(size)} + > + {TEXT_SIZES.map((size) => ( + + ))} + + + + {t("settings.display.dateFormat")} + + useSettingsStore.getState().setDateFormat(format)} + > + {DATE_FORMATS.map((format) => ( + + ))} + + + + + + + {t("settings.subscription.status")} + + {premium ? t("settings.subscription.premium") : t("settings.subscription.free")} + + {premium ? null : ( +