Skip to content

Commit

Permalink
feat: add pinned forms to suggested forms spot
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Apr 23, 2021
1 parent 546d273 commit aa8d720
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 34 deletions.
25 changes: 2 additions & 23 deletions domains/DataCollection/FormGallery/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import {
ScrollView, StyleSheet,
ScrollView,
View
} from 'react-native';
import {
Expand All @@ -13,6 +13,7 @@ import ComingSoonSVG from '../../../assets/graphics/static/Adventurer.svg';
import SmallCardsCarousel from '../../../components/Cards/SmallCardsCarousel';
import I18n from '../../../modules/i18n';
import { layout, theme } from '../../../modules/theme';
import styles from './index.styles';

const FormGallery = (props) => {
const {
Expand Down Expand Up @@ -124,26 +125,4 @@ const FormGallery = (props) => {
</View>
);
};

const styles = StyleSheet.create({
cardContainer: {
alignItems: 'center',
justifyContent: 'center',
margin: 20
},
textContainer: {
flexDirection: 'row',
},
text: {
flexShrink: 1,
textAlign: 'center',
color: theme.colors.primary,
fontWeight: 'bold',
marginVertical: 7,
},
header: {
fontSize: 20,
fontWeight: 'bold'
}
});
export default FormGallery;
29 changes: 29 additions & 0 deletions domains/DataCollection/FormGallery/index.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
StyleSheet
} from 'react-native';

import { theme } from '../../../modules/theme';

const styles = StyleSheet.create({
cardContainer: {
alignItems: 'center',
justifyContent: 'center',
margin: 20
},
textContainer: {
flexDirection: 'row',
},
text: {
flexShrink: 1,
textAlign: 'center',
color: theme.colors.primary,
fontWeight: 'bold',
marginVertical: 7,
},
header: {
fontSize: 20,
fontWeight: 'bold'
}
});

export default styles;
44 changes: 34 additions & 10 deletions domains/DataCollection/Forms/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import React, { useState } from 'react';
import { Keyboard, TouchableWithoutFeedback, View } from 'react-native';
import { Button, Text } from 'react-native-paper';
import {
Keyboard, ScrollView, TouchableWithoutFeedback, View
} from 'react-native';
import { Button, Card, Text } from 'react-native-paper';

import PostSubmissionSVG from '../../../assets/graphics/static/Submission-Page-Icon.svg';
import SmallCardsCarousel from '../../../components/Cards/SmallCardsCarousel';
import ResidentIdSearchbar from '../../../components/ResidentIdSearchbar';
import I18n from '../../../modules/i18n';
import { layout, theme } from '../../../modules/theme';
import GdprCompliance from '../GdprCompliance';
import IdentificationForm from './IdentificationForm';
import styles from './index.styles';
import SupplementaryForm from './SupplementaryForm';

const Forms = (props) => {
const {
navigation, navigateToGallery,
navigation, navigateToGallery, navigateToCustomForm,
selectedForm, setSelectedForm, navigateToNewRecord,
scrollViewScroll, setScrollViewScroll,
puenteForms,
pinnedForms,
surveyingUser, surveyingOrganization,
surveyee, setSurveyee,
customForm, navigateToRoot
Expand Down Expand Up @@ -82,11 +84,33 @@ const Forms = (props) => {
</View>
<View style={layout.container}>
<Text style={{ fontSize: 15, marginBottom: 5 }}>{I18n.t('forms.suggestedForms')}</Text>
<SmallCardsCarousel
puenteForms={puenteForms}
navigateToNewRecord={navigateToNewRecord}
setUser={false}
/>
<ScrollView horizontal>
{pinnedForms && pinnedForms.map((form) => (
<Card
key={form.objectId ?? form.tag}
style={layout.cardSmallStyle}
onPress={() => {
if (!form.tag) return navigateToCustomForm(form);
return navigateToNewRecord(form.tag);
}}
>
<View style={styles.cardContainer}>
<View style={styles.textContainer}>
<Text style={styles.text}>
{form.name}
</Text>
</View>
</View>
</Card>
))}
{pinnedForms.length < 1 && (
<View style={layout.screenRow}>
<Card>
<Card.Title title={I18n.t('formsGallery.noPinnedForms')} />
</Card>
</View>
)}
</ScrollView>
<Button mode="contained" onPress={navigateToGallery}>
<Text style={{ color: 'white' }}>{I18n.t('forms.viewGallery')}</Text>
</Button>
Expand Down
29 changes: 29 additions & 0 deletions domains/DataCollection/Forms/index.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
StyleSheet
} from 'react-native';

import { theme } from '../../../modules/theme';

const styles = StyleSheet.create({
cardContainer: {
alignItems: 'center',
justifyContent: 'center',
margin: 20
},
textContainer: {
flexDirection: 'row',
},
text: {
flexShrink: 1,
textAlign: 'center',
color: theme.colors.primary,
fontWeight: 'bold',
marginVertical: 7,
},
header: {
fontSize: 20,
fontWeight: 'bold'
}
});

export default styles;
3 changes: 2 additions & 1 deletion domains/DataCollection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,16 @@ const DataCollection = ({ navigation }) => {
navigateToGallery={navigateToGallery}
navigateToNewRecord={navigateToNewRecord}
navigateToRoot={navigateToRoot}
navigateToCustomForm={navigateToCustomForm}
selectedForm={selectedForm}
setSelectedForm={setSelectedForm}
puenteForms={puenteForms}
surveyingUser={surveyingUser}
surveyingOrganization={surveyingOrganization}
surveyee={surveyee}
setSurveyee={setSurveyee}
customForm={customForm}
setView={setView}
pinnedForms={pinnedForms}
/>
</View>
)}
Expand Down

0 comments on commit aa8d720

Please sign in to comment.