Skip to content

Commit

Permalink
fix: remove UI problem with asset supplementary form
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed May 27, 2021
1 parent df5dc74 commit e52e1b1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
import React, { useEffect, useState } from 'react';
import { ScrollView, View } from 'react-native';
import { Card, Text } from 'react-native-paper';
import { Card, IconButton, Text } from 'react-native-paper';

import { assetFormsQuery } from '../../../../../../modules/cached-resources';
import { layout } from '../../../../../../modules/theme';
import { layout, theme } from '../../../../../../modules/theme';
import styles from './index.style';

const AssetFormSelect = ({ setViewSupplementaryForms, setSelectedForm }) => {
const AssetFormSelect = ({ setSelectedForm }) => {
const [assetForms, setAssetForms] = useState([]);
useEffect(() => {
assetFormsQuery().then((forms) => {
setAssetForms(forms);
});
}, []);
});

const refreshAssetForms = () => {
assetFormsQuery().then((forms) => {
setAssetForms(forms);
});
};

const selectForm = (form) => {
setViewSupplementaryForms(false);
setSelectedForm(form);
};

return (
<View>
<ScrollView horizontal>
<View style={{ flexDirection: 'row' }}>
<Text style={styles.header}>Supplementary Asset Forms</Text>
<IconButton
style={{ bottom: 7 }}
color={theme.colors.primary}
size={20}
icon="refresh"
onPress={refreshAssetForms}
/>
</View>
<ScrollView horizontal style={styles.componentContainer}>
{assetForms && assetForms.map((form) => (
<Card
key={form.objectId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ const styles = StyleSheet.create({
header: {
fontSize: 20,
fontWeight: 'bold'
},
componentContainer: {
borderRadius: 10,
backgroundColor: '#ccc',
shadowColor: '#000',
// shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.8,
shadowRadius: 2,
elevation: 5
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Formik } from 'formik';
import React, { useState } from 'react';
import { ActivityIndicator, TouchableWithoutFeedback, View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
import { Button } from 'react-native-paper';

import PaperButton from '../../../../../components/Button';
import PaperInputPicker from '../../../../../components/FormikFields/PaperInputPicker';
Expand All @@ -15,7 +14,6 @@ import AssetFormSelect from './AssetFormSelect';
import styles from './index.styles';

const AssetSupplementary = ({ selectedAsset, surveyingOrganization }) => {
const [viewSupplementaryForms, setViewSupplementaryForms] = useState(false);
const [selectedForm, setSelectedForm] = useState();
const [photoFile, setPhotoFile] = useState('State Photo String');
return (
Expand Down Expand Up @@ -70,14 +68,9 @@ const AssetSupplementary = ({ selectedAsset, surveyingOrganization }) => {
<TouchableWithoutFeedback>
<View style={styles.assetContainer}>
<View>
<Button compact mode="contained" onPress={() => setViewSupplementaryForms(!viewSupplementaryForms)}>Show Available Asset Forms</Button>
{viewSupplementaryForms === true
&& (
<AssetFormSelect
setViewSupplementaryForms={setViewSupplementaryForms}
setSelectedForm={setSelectedForm}
/>
)}
<AssetFormSelect
setSelectedForm={setSelectedForm}
/>
</View>
{selectedAsset
&& (
Expand Down

0 comments on commit e52e1b1

Please sign in to comment.