Clean up welcome screen logic

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-11 21:43:30 +03:00
parent 5518fba787
commit 1c78a7e4ce
2 changed files with 16 additions and 20 deletions

View File

@@ -1,11 +1,21 @@
import React from 'react';
import { Button, Text } from 'react-native-paper';
import { useDispatch } from 'react-redux';
import { openDocumentTree } from 'react-native-scoped-storage';
import { PaddedView } from '../components';
import styles from '../styles';
import { noOp } from '../utilities';
import { updateStorageUri } from '../state';
const Welcome = () => {
const dispatch = useDispatch();
const selectStorageLocation = async () => {
const uri = await openDocumentTree(true).catch(noOp);
if (!uri) return;
await dispatch(updateStorageUri(uri.uri));
};
const Welcome = (properties: {
selectStorageLocation: () => Promise<void>;
}) => {
return (
<PaddedView centered>
<Text
@@ -15,7 +25,7 @@ const Welcome = (properties: {
</Text>
<Button
mode="contained"
onPress={properties.selectStorageLocation}
onPress={selectStorageLocation}
style={styles.extremeMarginBottom}>
Select Storage Location
</Button>