diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index 84bc650..2aa7141 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -5,6 +5,7 @@ import { HelloWave } from '@/components/HelloWave'; import ParallaxScrollView from '@/components/ParallaxScrollView'; import { ThemedText } from '@/components/ThemedText'; import { ThemedView } from '@/components/ThemedView'; +import { Text } from 'react-native-paper'; export default function HomeScreen() { return ( @@ -16,41 +17,9 @@ export default function HomeScreen() { style={styles.headerImage} /> }> - - Welcome bruh. - - - - Step 1: Try it - - Edit app/(tabs)/index.tsx to see changes. - Press{' '} - - {Platform.select({ - ios: 'cmd + d', - android: 'cmd + m', - web: 'F12', - })} - {' '} - to open developer tools. - - - - Step 2: Explore - - {`Tap the Explore tab to learn more about what's included in this starter app.`} - - - - Step 3: Get a fresh start - - {`When you're ready, run `} - npm run reset-project to get a fresh{' '} - app directory. This will move the current{' '} - app to{' '} - app-example. - - + + My Journey + ); } diff --git a/app/SettingsScreen.tsx b/app/SettingsScreen.tsx index 6c069b2..d824e20 100644 --- a/app/SettingsScreen.tsx +++ b/app/SettingsScreen.tsx @@ -1,27 +1,92 @@ -import { useState } from 'react'; -import { Button, Text, View } from 'react-native'; +import { useEffect, useState } from 'react'; +import { Button, View } from 'react-native'; import { pickDirectory } from '@react-native-documents/picker' +import { List, Text } from 'react-native-paper'; +import { Directory, Paths } from 'expo-file-system/next'; +import { StorageAccessFramework } from 'expo-file-system'; +import AsyncStorage from '@react-native-async-storage/async-storage'; + +const DATA_DIRECTORY_URI_KEY = 'dataDirectoryUri'; + +const prettyName = (uri: string | null) => { + if (!uri) return null; + const decodedUri = decodeURIComponent(uri); + const match = decodedUri.match(/.*\/primary:(.+)/); + + if (match) { + return match[1]; + } + + // Fallback to your original logic + return uri.split('%3A').pop() || "Unknown"; + +} export default function SettingsScreen() { const [directoryUri, setDirectoryUri] = useState(null); + // Load saved directory URI on component mount + useEffect(() => { + const loadDirectoryUri = async () => { + try { + const savedUri = await AsyncStorage.getItem(DATA_DIRECTORY_URI_KEY); + if (savedUri) { + setDirectoryUri(savedUri); + } + } catch (error) { + console.error('Error loading directory URI:', error); + } + }; + + loadDirectoryUri(); + }, []); + + // Save directory URI whenever it changes + const saveDirectoryUri = async (uri: string | null) => { + try { + if (uri) { + await AsyncStorage.setItem(DATA_DIRECTORY_URI_KEY, uri); + } else { + await AsyncStorage.removeItem(DATA_DIRECTORY_URI_KEY); + } + setDirectoryUri(uri); + } catch (error) { + console.error('Error saving directory URI:', error); + } + }; + return ( - - {directoryUri ?? "No directory set."} -