⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
feat(mobile): option to choose links default behavior
daniel31x13e30bcaefe37e
diff --git a/apps/mobile/app/(tabs)/settings/index.tsx b/apps/mobile/app/(tabs)/settings/index.tsxindex bc4a757b..d5582e6c 100644--- a/apps/mobile/app/(tabs)/settings/index.tsx+++ b/apps/mobile/app/(tabs)/settings/index.tsx@@ -13,8 +13,17 @@ import { nativeApplicationVersion } from "expo-application";import { useColorScheme } from "nativewind";import { rawTheme, ThemeName } from "@/lib/colors";import { useEffect, useState } from "react";-import { Check, LogOut, Moon, Smartphone, Sun } from "lucide-react-native";+import {+ Check,+ FileText,+ Globe,+ LogOut,+ Moon,+ Smartphone,+ Sun,+} from "lucide-react-native";import useDataStore from "@/store/data";+import { ArchivedFormat } from "@/types/global";export default function SettingsScreen() {const { signOut, auth } = useAuthStore();@@ -41,6 +50,7 @@ export default function SettingsScreen() {contentContainerStyle={{padding: 20,}}+ contentContainerClassName="flex-col gap-6"contentInsetAdjustmentBehavior="automatic"><View className="bg-base-200 rounded-xl px-4 py-3">@@ -75,14 +85,17 @@ export default function SettingsScreen() {</View><View>- <Text className="mb-4 mx-4 mt-6 text-neutral">Theme</Text>+ <Text className="mb-4 mx-4 text-neutral">Theme</Text><View className="bg-base-200 rounded-xl flex-col"><TouchableOpacityclassName="flex-row gap-2 items-center justify-between py-3 px-4"onPress={() => setOverride("system")}><View className="flex-row items-center gap-2">- <Smartphone size={20} color="gray" />+ <Smartphone+ size={20}+ color={rawTheme[colorScheme as ThemeName].neutral}+ /><Text className="text-neutral">System Defaults</Text></View>{override === "system" ? (@@ -128,7 +141,61 @@ export default function SettingsScreen() {</TouchableOpacity></View></View>- <Text className="mt-4 mx-auto text-sm text-neutral">++ <View>+ <Text className="mb-4 mx-4 text-neutral">+ Default Behavior for Opening Links+ </Text>+ <View className="bg-base-200 rounded-xl flex-col">+ <TouchableOpacity+ className="flex-row gap-2 items-center justify-between py-3 px-4"+ onPress={() =>+ updateData({+ preferredFormat: null,+ })+ }+ >+ <View className="flex-row items-center gap-2">+ <Globe+ size={20}+ color={rawTheme[colorScheme as ThemeName].neutral}+ />+ <Text className="text-base-content">Open original content</Text>+ </View>+ {data.preferredFormat === null ? (+ <Check+ size={20}+ color={rawTheme[colorScheme as ThemeName].primary}+ />+ ) : null}+ </TouchableOpacity>+ <View className="h-px bg-neutral-content ml-12" />+ <TouchableOpacity+ className="flex-row gap-2 items-center justify-between py-3 px-4"+ onPress={() =>+ updateData({+ preferredFormat: ArchivedFormat.readability,+ })+ }+ >+ <View className="flex-row items-center gap-2">+ <FileText+ size={20}+ color={rawTheme[colorScheme as ThemeName].neutral}+ />+ <Text className="text-base-content">Open reader view</Text>+ </View>+ {data.preferredFormat === ArchivedFormat.readability ? (+ <Check+ size={20}+ color={rawTheme[colorScheme as ThemeName].primary}+ />+ ) : null}+ </TouchableOpacity>+ </View>+ </View>++ <Text className="mx-auto text-sm text-neutral">Linkwarden for {Platform.OS === "ios" ? "iOS" : "Android"}{" "}{nativeApplicationVersion}</Text>diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsxindex de2267a6..ee5869b7 100644--- a/apps/mobile/app/_layout.tsx+++ b/apps/mobile/app/_layout.tsx@@ -111,11 +111,9 @@ export default function RootLayout() {rawTheme[colorScheme as ThemeName]["base-100"],headerStyle: {backgroundColor:- Platform.OS === "ios"- ? "transparent"- : colorScheme === "dark"- ? rawTheme["dark"]["base-100"]- : "white",+ colorScheme === "dark"+ ? rawTheme["dark"]["base-100"]+ : "white",},}}/>diff --git a/apps/mobile/app/links/[id].tsx b/apps/mobile/app/links/[id].tsxindex ca685213..f6584e19 100644--- a/apps/mobile/app/links/[id].tsx+++ b/apps/mobile/app/links/[id].tsx@@ -150,7 +150,7 @@ export default function LinkScreen() {),}}tagsStyles={{- p: { fontSize: 16, lineHeight: 24, marginVertical: 10 },+ p: { fontSize: 18, lineHeight: 28, marginVertical: 10 },}}baseStyle={{color: rawTheme[colorScheme as ThemeName]["base-content"],diff --git a/apps/mobile/components/LinkListing.tsx b/apps/mobile/components/LinkListing.tsxindex 839158c1..a073dd6e 100644--- a/apps/mobile/components/LinkListing.tsx+++ b/apps/mobile/components/LinkListing.tsx@@ -17,6 +17,7 @@ import { useUser } from "@linkwarden/router/user";import { rawTheme, ThemeName } from "@/lib/colors";import { useColorScheme } from "nativewind";import { CalendarDays, Folder } from "lucide-react-native";+import useDataStore from "@/store/data";type Props = {link: LinkIncludingShortenedCollectionAndTags;@@ -29,6 +30,7 @@ const LinkListing = ({ link, dashboard }: Props) => {const updateLink = useUpdateLink(auth);const { data: user } = useUser(auth);const { colorScheme } = useColorScheme();+ const { data } = useDataStore();const deleteLink = useDeleteLink(auth);@@ -53,7 +55,13 @@ const LinkListing = ({ link, dashboard }: Props) => {dashboard && "rounded-xl")}onLongPress={() => {}}- onPress={() => router.push(`/links/${link.id}`)}+ onPress={() =>+ router.push(+ data.preferredFormat+ ? `/links/${link.id}?format=${data.preferredFormat}`+ : `/links/${link.id}`+ )+ }android_ripple={{color: colorScheme === "dark" ? "rgba(255,255,255,0.2)" : "#ddd",borderless: false,diff --git a/apps/mobile/store/data.ts b/apps/mobile/store/data.tsindex 1e874fd4..31606dc8 100644--- a/apps/mobile/store/data.ts+++ b/apps/mobile/store/data.ts@@ -16,6 +16,7 @@ const useDataStore = create<DataStore>((set, get) => ({url: "",},theme: "light",+ preferredFormat: null,},setData: async () => {const dataString = JSON.parse((await AsyncStorage.getItem("data")) || "{}");diff --git a/packages/types/global.ts b/packages/types/global.tsindex 6902c796..29d8f540 100644--- a/packages/types/global.ts+++ b/packages/types/global.ts@@ -186,4 +186,5 @@ export interface MobileData {url: string;};theme: "light" | "dark" | "system";+ preferredFormat: ArchivedFormat | null;}