import { useState } from 'react';
import { Button, Text, View } from 'react-native';
import { pickDirectory } from '@react-native-documents/picker'

export default function SettingsScreen() {
    const [directoryUri, setDirectoryUri] = useState<string | null>(null);
    return (
        <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', gap: 20 }}>
            <Text>{directoryUri ?? "No directory set."}</Text>
            <Button
                title="open directory"
                onPress={async () => {
                    try {
                        const { uri } = await pickDirectory({
                            requestLongTermAccess: false,
                        })
                        console.log(uri)
                        setDirectoryUri(uri)
                    } catch (err) {
                        // see error handling section
                        console.error(err)
                    }
                }}
            />
        </View>
    )

}