aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/app/dashboard/(tabs)
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-08-26 21:33:01 +0300
committerMohamedBassem <me@mbassem.com>2024-08-26 21:33:01 +0300
commitfdf055ae222ac2063fa87759479018248657fd63 (patch)
tree686d5d921ae42f9108dbfa9faf00a9d10006f94f /apps/mobile/app/dashboard/(tabs)
parent140554021e83ca375845584f8d7e5e476434f1c0 (diff)
downloadkarakeep-fdf055ae222ac2063fa87759479018248657fd63.tar.zst
feature(mobile): Allow configuring uploaded image quality in the mobile app
Diffstat (limited to 'apps/mobile/app/dashboard/(tabs)')
-rw-r--r--apps/mobile/app/dashboard/(tabs)/index.tsx2
-rw-r--r--apps/mobile/app/dashboard/(tabs)/settings.tsx42
2 files changed, 41 insertions, 3 deletions
diff --git a/apps/mobile/app/dashboard/(tabs)/index.tsx b/apps/mobile/app/dashboard/(tabs)/index.tsx
index dc9871e7..bd7ce3ea 100644
--- a/apps/mobile/app/dashboard/(tabs)/index.tsx
+++ b/apps/mobile/app/dashboard/(tabs)/index.tsx
@@ -34,7 +34,7 @@ function HeaderRight({
} else if (nativeEvent.event === "library") {
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
- quality: 0,
+ quality: settings.imageQuality,
allowsMultipleSelection: false,
});
if (!result.canceled) {
diff --git a/apps/mobile/app/dashboard/(tabs)/settings.tsx b/apps/mobile/app/dashboard/(tabs)/settings.tsx
index 73d1b42d..18d3d243 100644
--- a/apps/mobile/app/dashboard/(tabs)/settings.tsx
+++ b/apps/mobile/app/dashboard/(tabs)/settings.tsx
@@ -1,6 +1,10 @@
+import { useEffect } from "react";
import { Text, View } from "react-native";
+import { Slider } from "react-native-awesome-slider";
+import { useSharedValue } from "react-native-reanimated";
import { Button } from "@/components/ui/Button";
import CustomSafeAreaView from "@/components/ui/CustomSafeAreaView";
+import { Divider } from "@/components/ui/Divider";
import PageTitle from "@/components/ui/PageTitle";
import { useSession } from "@/lib/session";
import useAppSettings from "@/lib/settings";
@@ -8,7 +12,19 @@ import { api } from "@/lib/trpc";
export default function Dashboard() {
const { logout } = useSession();
- const { settings, isLoading: isSettingsLoading } = useAppSettings();
+ const {
+ settings,
+ setSettings,
+ isLoading: isSettingsLoading,
+ } = useAppSettings();
+
+ const imageQuality = useSharedValue(0);
+ const imageQualityMin = useSharedValue(0);
+ const imageQualityMax = useSharedValue(100);
+
+ useEffect(() => {
+ imageQuality.value = settings.imageQuality * 100;
+ }, [settings]);
const { data, error, isLoading } = api.users.whoami.useQuery();
@@ -30,8 +46,30 @@ export default function Dashboard() {
{isLoading ? "Loading ..." : data?.email}
</Text>
</View>
-
<Button className="w-full" label="Log Out" onPress={logout} />
+ <Divider orientation="horizontal" />
+ <Text className="w-full p-1 text-2xl font-bold text-foreground">
+ Upload Settings
+ </Text>
+ <View className="flex w-full flex-row items-center justify-between gap-8 rounded-lg bg-white px-4 py-2 dark:bg-accent">
+ <Text className="text-lg text-accent-foreground">Image Quality</Text>
+ <View className="flex flex-1 flex-row items-center justify-center gap-2">
+ <Text className="text-foreground">
+ {settings.imageQuality * 100}%
+ </Text>
+ <Slider
+ onSlidingComplete={(value) =>
+ setSettings({
+ ...settings,
+ imageQuality: Math.round(value) / 100,
+ })
+ }
+ progress={imageQuality}
+ minimumValue={imageQualityMin}
+ maximumValue={imageQualityMax}
+ />
+ </View>
+ </View>
</View>
</CustomSafeAreaView>
);