Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat(mobile): add keep screen on toggle for bookmark viewing (#2691)

Evan Simkowitz64ff1cc65f9f
diff --git a/apps/mobile/app/dashboard/(tabs)/(settings)/index.tsx b/apps/mobile/app/dashboard/(tabs)/(settings)/index.tsx
index 309924e1..a7fc8bb3 100644
--- a/apps/mobile/app/dashboard/(tabs)/(settings)/index.tsx
+++ b/apps/mobile/app/dashboard/(tabs)/(settings)/index.tsx
@@ -202,6 +202,24 @@ export default function Settings() {
}
/>
</View>
+ <Divider orientation="horizontal" className="mx-6 my-1" />
+ <View className="flex flex-row items-center justify-between gap-8 px-4 py-1">
+ <Text className="flex-1" numberOfLines={1}>
+ Keep screen on while reading
+ </Text>
+ <Switch
+ className="shrink-0"
+ disabled={isSettingsLoading}
+ value={settings.keepScreenOnWhileReading}
+ onValueChange={(value) => {
+ if (isSettingsLoading) return;
+ setSettings({
+ ...settings,
+ keepScreenOnWhileReading: value,
+ });
+ }}
+ />
+ </View>
</View>
<SectionHeader title="Media" />
diff --git a/apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx b/apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx
index 524ef9a7..55270b85 100644
--- a/apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx
+++ b/apps/mobile/app/dashboard/bookmarks/[slug]/index.tsx
@@ -1,6 +1,7 @@
import { useState } from "react";
import { KeyboardAvoidingView, Pressable, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useKeepAwake } from "expo-keep-awake";
import { Stack, useLocalSearchParams, useRouter } from "expo-router";
import BookmarkAssetView from "@/components/bookmarks/BookmarkAssetView";
import BookmarkLinkTypeSelector, {
@@ -20,6 +21,11 @@ import { useColorScheme } from "nativewind";
import { useTRPC } from "@karakeep/shared-react/trpc";
import { BookmarkTypes } from "@karakeep/shared/types/bookmarks";
+function KeepScreenOn() {
+ useKeepAwake();
+ return null;
+}
+
export default function BookmarkView() {
const insets = useSafeAreaInsets();
const router = useRouter();
@@ -84,6 +90,7 @@ export default function BookmarkView() {
style={{ flex: 1, paddingBottom: insets.bottom + 8 }}
behavior="height"
>
+ {settings.keepScreenOnWhileReading && <KeepScreenOn />}
<Stack.Screen
options={{
headerTitle: title ?? "",
diff --git a/apps/mobile/lib/settings.ts b/apps/mobile/lib/settings.ts
index 74070bf5..09073eb5 100644
--- a/apps/mobile/lib/settings.ts
+++ b/apps/mobile/lib/settings.ts
@@ -18,6 +18,7 @@ const zSettingsSchema = z.object({
.optional()
.default("reader"),
showNotes: z.boolean().optional().default(false),
+ keepScreenOnWhileReading: z.boolean().optional().default(false),
customHeaders: z.record(z.string(), z.string()).optional().default({}),
// Reader settings (local device overrides)
readerFontSize: z.number().int().min(12).max(24).optional(),
@@ -42,6 +43,7 @@ const useSettings = create<AppSettingsState>((set, get) => ({
theme: "system",
defaultBookmarkView: "reader",
showNotes: false,
+ keepScreenOnWhileReading: false,
customHeaders: {},
},
},
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index fbcc971c..5293f661 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -48,6 +48,7 @@
"expo-haptics": "~15.0.8",
"expo-image": "~3.0.11",
"expo-image-picker": "~17.0.10",
+ "expo-keep-awake": "~15.0.8",
"expo-linking": "~8.0.11",
"expo-navigation-bar": "~5.0.10",
"expo-router": "~6.0.21",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a9235329..6151d17d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -380,6 +380,9 @@ importers:
expo-image-picker:
specifier: ~17.0.10
version: 17.0.10([email protected])
+ expo-keep-awake:
+ specifier: ~15.0.8
expo-linking:
specifier: ~8.0.11