Skip to content

Commit

Permalink
Merge pull request #71 from hopetambala/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
joseph-mccombs authored Feb 26, 2021
2 parents 69f8b55 + 1857aaa commit 54d1d7b
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 60 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [10.6.3](https://github.com/hopetambala/puente-reactnative-collect/compare/v10.6.2...v10.6.3) (2021-02-25)


### New Features

* autofill for organization ([3a8d7ee](https://github.com/hopetambala/puente-reactnative-collect/commit/3a8d7ee5af4147cb9d824134b7a99841987bd725))
* ui update for autofill ([46e37fc](https://github.com/hopetambala/puente-reactnative-collect/commit/46e37fcd0212784c6609212e33ffa342d03740cc))


### Bug fixes

* adding assets back to cachedResourcecs ([eb25c1d](https://github.com/hopetambala/puente-reactnative-collect/commit/eb25c1dc04426a307452b299370bf7f4db573efd))
* android autofill respond to user ([f96c306](https://github.com/hopetambala/puente-reactnative-collect/commit/f96c3061a3c5594b4e0e4a33ff40f7daf47b0147))

### [10.6.1](https://github.com/hopetambala/puente-reactnative-collect/compare/v10.6.0...v10.6.1) (2021-02-19)


Expand Down
6 changes: 3 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"android",
"web"
],
"version": "10.6.1",
"version": "10.6.3",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "myapp",
Expand All @@ -23,7 +23,7 @@
],
"ios": {
"supportsTablet": true,
"buildNumber": "10.6.1",
"buildNumber": "10.6.3",
"infoPlist": {
"NSLocationWhenInUseUsageDescription": "This app uses your location to geo-tag surveys accurately."
}
Expand All @@ -32,7 +32,7 @@
"favicon": "./assets/images/favicon.png"
},
"android": {
"versionCode": 380100601,
"versionCode": 380100603,
"permissions": [
"ACCESS_COARSE_LOCATION",
"ACCESS_FINE_LOCATION",
Expand Down
87 changes: 57 additions & 30 deletions components/FormikFields/PaperInputPicker/AutoFill/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react';
import {
Platform,
StyleSheet, Text, TouchableOpacity, View,
YellowBox
} from 'react-native';
Expand All @@ -9,6 +10,7 @@ import { TextInput } from 'react-native-paper';
import { getData } from '../../../../modules/async-storage';
import { cacheAutofillData } from '../../../../modules/cached-resources';
import I18n from '../../../../modules/i18n';
import { theme } from '../../../../modules/theme';
import { stylesDefault, stylesPaper } from '../index.style';

YellowBox.ignoreWarnings(['VirtualizedLists should never be nested']);
Expand Down Expand Up @@ -56,12 +58,12 @@ export default class AutoFill extends Component {
label, translatedLabel, formikProps, formikKey, scrollViewScroll, setScrollViewScroll
} = this.props;

const placeholder = `${I18n.t('components.autofill.placeholder')} ${I18n.t(label)} ${I18n.t('components.autofill.placeholder_end')}`;
const placeholder = I18n.t(label);

return (
<View style={styles.container}>
{/* handle issues where autofil does not populate any data */}
{!values ? (
{!values && (
<TextInput
label={translatedLabel.length > 40 ? '' : translatedLabel}
onChangeText={formikProps.handleChange(formikKey)}
Expand All @@ -70,18 +72,20 @@ export default class AutoFill extends Component {
theme={stylesPaper}
style={stylesDefault.label}
/>
) : (
)}
{values && Platform.OS === 'ios' && (
<View>
<Autocomplete
autoCapitalize="none"
autoCorrect={false}
containerStyle={styles.autocompleteContainer}
// data to show in suggestion
inputContainerStyle={styles.textInputContainer}
// data to show in suggestion
data={fields.length === 1 && comp(query, fields[0]) ? [] : fields}
// default value if you want to set something in input
// default value if you want to set something in input
defaultValue={query}
/* onchange of the text changing the state of the query which will trigger
the findFilm method to show the suggestions */
/* onchange of the text changing the state of the query which will trigger
the findFilm method to show the suggestions */
onChangeText={(text) => {
this.setState({ query: text });
formikProps.setFieldValue(formikKey, text);
Expand All @@ -94,7 +98,7 @@ export default class AutoFill extends Component {
// and on the screen when they are not
setScrollViewScroll(false);
if (fields.length === 0
&& scrollViewScroll === false) {
&& scrollViewScroll === false) {
setScrollViewScroll(true);
}
}}
Expand All @@ -113,13 +117,43 @@ export default class AutoFill extends Component {
</TouchableOpacity>
)}
/>
<View style={styles.descriptionContainer}>
{fields.length > 0 ? (
<Text style={styles.infoText}>{query}</Text>
) : (
<Text style={styles.infoText}>{placeholder}</Text>
</View>
)}
{values && Platform.OS === 'android' && (
<View>
<Autocomplete
autoCapitalize="none"
autoCorrect={false}
containerStyle={styles.autocompleteContainer}
inputContainerStyle={styles.textInputContainer}
// data to show in suggestion
data={fields.length === 1 && comp(query, fields[0]) ? [] : fields}
// default value if you want to set something in input
defaultValue={query}
/* onchange of the text changing the state of the query which will trigger
the findFilm method to show the suggestions */
onChangeText={(text) => {
this.setState({ query: text });
formikProps.setFieldValue(formikKey, text);
}}
placeholder={placeholder}
listStyle={styles.listContainer}
keyExtractor={(item,) => item.key}
renderItem={({ item }) => (
// you can change the view you want to show in suggestion from here
<TouchableOpacity
key={`${item}`}
onPress={() => {
this.setState({ query: item });
formikProps.setFieldValue(formikKey, item);
}}
>
<Text style={styles.itemText} key={item}>
{item}
</Text>
</TouchableOpacity>
)}
</View>
/>
</View>
)}
</View>
Expand All @@ -129,30 +163,23 @@ export default class AutoFill extends Component {

const styles = StyleSheet.create({
container: {
// backgroundColor: '#F5FCFF',
flex: 1,
padding: 16,
// marginTop: 40,
marginBottom: 40,
},
autocompleteContainer: {
backgroundColor: '#ffffff',
borderWidth: 0
paddingLeft: 15,
paddingRight: 15,
paddingTop: 10,
marginBottom: 75,
},
descriptionContainer: {
flex: 1,
justifyContent: 'center',
borderRadius: 20
textInputContainer: {
borderColor: theme.colors.primary,
borderWidth: 1,
color: 'red'
},
itemText: {
fontSize: 15,
paddingTop: 5,
paddingBottom: 5,
margin: 2,
},
infoText: {
textAlign: 'center',
fontSize: 16,
flex: 1
},
listContainer: {
height: 80,
Expand Down
22 changes: 16 additions & 6 deletions domains/Auth/SignUp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import * as yup from 'yup';

import FormInput from '../../../components/FormikFields/FormInput';
import Autofill from '../../../components/FormikFields/PaperInputPicker/AutoFill';
import TermsModal from '../../../components/TermsModal';
import { populateCache } from '../../../modules/cached-resources';
import I18n from '../../../modules/i18n';
Expand Down Expand Up @@ -59,9 +60,11 @@ const validationSchema = yup.object().shape({
export default function SignUp({ navigation }) {
const [checked, setChecked] = React.useState(false);
const [visible, setVisible] = React.useState(false);
const [scrollViewScroll, setScrollViewScroll] = React.useState();
const handleLogIn = () => {
navigation.navigate('Sign In');
};

return (
<KeyboardAvoidingView
enabled
Expand All @@ -72,7 +75,11 @@ export default function SignUp({ navigation }) {
<Button icon="arrow-left" width={100} style={{ paddingTop: 40 }} onPress={handleLogIn}>
Back
</Button>
<ScrollView style={{ backgroundColor: theme.colors.accent }}>
<ScrollView
style={{ backgroundColor: theme.colors.accent }}
keyboardShouldPersistTaps="never"
scrollEnabled={scrollViewScroll}
>
<SafeAreaView style={{ marginTop: 10 }}>
<Formik
initialValues={{
Expand Down Expand Up @@ -142,11 +149,14 @@ export default function SignUp({ navigation }) {
placeholder="Password Here"
secureTextEntry
/>
<FormInput
label={I18n.t('signUp.organization')}
<Autofill
parameter="organization"
formikProps={formikProps}
formikKey="organization"
placeholder="Puente"
label="signUp.organization"
translatedLabel="Organization"
scrollViewScroll={scrollViewScroll}
setScrollViewScroll={setScrollViewScroll}
/>
<Button mode="text" theme={theme} color="#3E81FD" style={styles.serviceButton} onPress={() => setVisible(true)}>{I18n.t('signUp.termsOfService.view')}</Button>
<View style={styles.container}>
Expand All @@ -167,8 +177,8 @@ export default function SignUp({ navigation }) {
{formikProps.isSubmitting ? (
<ActivityIndicator />
) : (
<Button mode="contained" theme={theme} style={styles.submitButton} onPress={formikProps.handleSubmit}>{I18n.t('signUp.submit')}</Button>
)}
<Button mode="contained" theme={theme} style={styles.submitButton} onPress={formikProps.handleSubmit}>{I18n.t('signUp.submit')}</Button>
)}

<TermsModal visible={visible} setVisible={setVisible} />
</>
Expand Down
52 changes: 36 additions & 16 deletions modules/cached-resources/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,28 @@ async function cacheAutofillData(parameter) {
checkOnlineStatus().then((connected) => {
if (connected) {
retrievePuenteAutofillData('all').then((result) => {
storeData(result, 'autofill_information');
resolve(result[parameter]);
// cache organizations tied to all users
customQueryService(0, 500, 'User', 'adminVerified', true).then((users) => {
const orgsCapitalized = [];
const orgResults = [];
users.forEach((user) => {
const org = user.get('organization');
if (org !== null && org !== undefined && org !== '') {
const orgCapitalized = org.toUpperCase().trim() || '';
if (!orgsCapitalized.includes(orgCapitalized) && org !== '') {
orgsCapitalized.push(orgCapitalized);
orgResults.push(org);
}
}
});
const autofillData = result;
autofillData.organization = orgResults;
storeData(autofillData, 'autofill_information');
resolve(autofillData[parameter]);
}, () => {
storeData(result, 'autofill_information');
resolve(result[parameter]);
});
}, (error) => {
reject(error);
});
Expand Down Expand Up @@ -67,19 +87,19 @@ function customFormsQuery(surveyingOrganization) {
});
}

function assetFormsQuery() {
function getTasksAsync() {
return new Promise((resolve, reject) => {
checkOnlineStatus().then((online) => {
checkOnlineStatus().then(async (online) => {
if (online) {
customQueryService(0, 5000, 'FormSpecificationsV2', 'typeOfForm', 'Assets').then(async (forms) => {
await storeData(forms, 'assetForms');
resolve(JSON.parse(JSON.stringify(forms)));
await getTasks().then(async (result) => {
await storeData(result, 'tasks');
resolve(result);
}, (error) => {
reject(error);
});
} else {
getData('assetForms').then((forms) => {
resolve(forms);
getData('tasks').then((tasks) => {
resolve(tasks);
}, (error) => {
reject(error);
});
Expand All @@ -90,19 +110,19 @@ function assetFormsQuery() {
});
}

function getTasksAsync() {
function assetFormsQuery() {
return new Promise((resolve, reject) => {
checkOnlineStatus().then(async (online) => {
checkOnlineStatus().then((online) => {
if (online) {
await getTasks().then(async (result) => {
await storeData(result, 'tasks');
resolve(result);
customQueryService(0, 5000, 'FormSpecificationsV2', 'typeOfForm', 'Assets').then(async (forms) => {
await storeData(forms, 'assetForms');
resolve(JSON.parse(JSON.stringify(forms)));
}, (error) => {
reject(error);
});
} else {
getData('tasks').then((tasks) => {
resolve(tasks);
getData('assetForms').then((forms) => {
resolve(forms);
}, (error) => {
reject(error);
});
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puente-reactnative",
"version": "10.6.1",
"version": "10.6.3",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
Expand Down Expand Up @@ -47,10 +47,10 @@
"axios": "0.19.2",
"expo": "38.0.8",
"expo-asset": "8.1.7",
"expo-camera": "^10.0.0",
"expo-camera": "10.0.0",
"expo-constants": "9.1.1",
"expo-font": "8.2.1",
"expo-image-picker": "^10.0.0",
"expo-image-picker": "10.0.0",
"expo-linking": "1.0.1",
"expo-localization": "8.2.1",
"expo-location": "8.2.1",
Expand All @@ -59,7 +59,7 @@
"expo-web-browser": "8.3.1",
"formik": "2.1.5",
"i18n-js": "3.7.1",
"lodash": "^4.17.20",
"lodash": "4.17.20",
"metro-config": "0.63.0",
"native-base": "2.13.8",
"parse": "2.14.0",
Expand Down

0 comments on commit 54d1d7b

Please sign in to comment.