diff --git a/front/app/+html.tsx b/front/app/+html.tsx new file mode 100644 index 00000000..d9b6ddde --- /dev/null +++ b/front/app/+html.tsx @@ -0,0 +1,26 @@ +import { ScrollViewStyleReset } from "expo-router/html"; +import type { PropsWithChildren } from "react"; + +export default function Root({ children }: PropsWithChildren) { + // TODO: change this lang attr + return ( + + + Kyoo + + + + + + + + + + + + + + {children} + + ); +} diff --git a/front/app/_layout.tsx b/front/app/_layout.tsx index 2b5f34f9..1e75bab4 100644 --- a/front/app/_layout.tsx +++ b/front/app/_layout.tsx @@ -61,35 +61,11 @@ export default function Layout() { // const registry = createStyleRegistry(); // useServerHeadInsertion(() => registry.flushToComponent()); - // TODO: change this lang attr + // return ( {Platform.OS === "web" && } ); - // return ( - // - // - // Kyoo - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // {Platform.OS === "web" && } - // - // - // - // - // ); } diff --git a/front/src/primitives/links.tsx b/front/src/primitives/links.tsx index 09d90374..2536834a 100644 --- a/front/src/primitives/links.tsx +++ b/front/src/primitives/links.tsx @@ -1,6 +1,7 @@ -import { useLinkTo } from "one"; +import { useRouter } from "expo-router"; import { type ReactNode, forwardRef } from "react"; import { + Linking, Platform, Pressable, type PressableProps, @@ -11,6 +12,28 @@ import { import { useTheme, useYoshiki } from "yoshiki/native"; import { alpha } from "./theme"; +function useLinkTo({ + href, + replace = false, +}: { + href: string; + replace?: boolean; +}) { + const router = useRouter(); + + // TODO: add href attr for web + return { + onPress: (e) => { + if (e?.defaultPrevented) return; + if (href.startsWith("http")) { + Platform.OS === "web" ? window.open(href, "_blank") : Linking.openURL(href); + } else { + replace ? router.replace(href) : router.push(href); + } + }, + } satisfies PressableProps; +} + export const A = ({ href, replace, diff --git a/front/src/providers/settings.ts b/front/src/providers/settings.ts index 102dc83b..3b0e5210 100644 --- a/front/src/providers/settings.ts +++ b/front/src/providers/settings.ts @@ -1,7 +1,7 @@ -import { getServerData } from "one"; import { Platform } from "react-native"; import { MMKV, useMMKVString } from "react-native-mmkv"; import type { ZodTypeAny, z } from "zod"; +import { getServerData } from "~/utils"; export const storage = new MMKV(); diff --git a/front/src/providers/translations.compile.ts b/front/src/providers/translations.compile.ts index 38ea0866..55b100f6 100644 --- a/front/src/providers/translations.compile.ts +++ b/front/src/providers/translations.compile.ts @@ -1,18 +1,22 @@ // this file is run at compile time thanks to a vite plugin -import { readFile, readdir } from "node:fs/promises"; -import type { Resource } from "i18next"; +// import { readFile, readdir } from "node:fs/promises"; +// import type { Resource } from "i18next"; -const translationDir = new URL("../../public/translations/", import.meta.url); -const langs = await readdir(translationDir); +// const translationDir = new URL("../../public/translations/", import.meta.url); +// const langs = await readdir(translationDir); -export const resources: Resource = Object.fromEntries( - await Promise.all( - langs.map(async (x) => [ - x.replace(".json", ""), - { translation: JSON.parse(await readFile(new URL(x, translationDir), "utf8")) }, - ]), - ), -); +// export const resources: Resource = Object.fromEntries( +// await Promise.all( +// langs.map(async (x) => [ +// x.replace(".json", ""), +// { translation: JSON.parse(await readFile(new URL(x, translationDir), "utf8")) }, +// ]), +// ), +// ); + +import en from "../../public/translations/en.json"; + +export const resources = { en }; export const supportedLanguages = Object.keys(resources); diff --git a/front/src/providers/translations.native.tsx b/front/src/providers/translations.native.tsx index bc3e56c1..b8a79953 100644 --- a/front/src/providers/translations.native.tsx +++ b/front/src/providers/translations.native.tsx @@ -2,7 +2,7 @@ import i18next from "i18next"; import { type ReactNode, useMemo } from "react"; import { I18nextProvider } from "react-i18next"; import { resources, supportedLanguages } from "./translations.compile"; -import { setServerData } from "one"; +import { setServerData } from "~/utils"; export const TranslationsProvider = ({ children }: { children: ReactNode }) => { const val = useMemo(() => { diff --git a/front/src/providers/translations.web.client.tsx b/front/src/providers/translations.web.client.tsx index 97c27774..3b447de3 100644 --- a/front/src/providers/translations.web.client.tsx +++ b/front/src/providers/translations.web.client.tsx @@ -1,9 +1,9 @@ import i18next from "i18next"; import HttpApi, { type HttpBackendOptions } from "i18next-http-backend"; -import { getServerData } from "one"; import { type ReactNode, useMemo } from "react"; import { I18nextProvider } from "react-i18next"; import { supportedLanguages } from "./translations.compile"; +import { getServerData } from "~/utils"; export const TranslationsProvider = ({ children }: { children: ReactNode }) => { const val = useMemo(() => { diff --git a/front/src/query/query.tsx b/front/src/query/query.tsx index 438e11c7..be18cc7e 100644 --- a/front/src/query/query.tsx +++ b/front/src/query/query.tsx @@ -1,10 +1,10 @@ import { QueryClient, dehydrate, useInfiniteQuery, useQuery } from "@tanstack/react-query"; -import { setServerData } from "one"; import { useContext } from "react"; import { Platform } from "react-native"; import type { z } from "zod"; import { type KyooError, type Page, Paged } from "~/models"; import { AccountContext } from "~/providers/account-context"; +import { setServerData } from "~/utils"; const ssrApiUrl = process.env.KYOO_URL ?? "http://back/api"; diff --git a/front/src/utils.ts b/front/src/utils.ts new file mode 100644 index 00000000..91587588 --- /dev/null +++ b/front/src/utils.ts @@ -0,0 +1,4 @@ +export function setServerData(key: string, val: any) {} +export function getServerData(key: string) { + return key; +}