Clean up welcome screen logic
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -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>
|
||||
|
Reference in New Issue
Block a user