Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayush Srivastava committed Jun 16, 2022
1 parent 5efb1a3 commit 6c939b1
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 574 deletions.
2 changes: 1 addition & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import FlashMessage from "react-native-flash-message";

export default function App() {

global.baseURL = 'localhost:8081/'

return (
<View style={styles.container}>
<AppNavigation />
Expand Down
242 changes: 24 additions & 218 deletions Components/AboutInfo.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,30 @@
import React, { useState } from "react";
import React, { useState, useEffect, useCallback } from "react";
import {
View,
StyleSheet,
Text,
Touchable,
TouchableOpacity,
FlatList,
} from "react-native";
import { Divider } from "react-native-elements";
import { useNavigation } from "@react-navigation/native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { FontAwesome } from "@expo/vector-icons";

import { Entypo, FontAwesome } from "@expo/vector-icons";

import { LinearGradient } from "expo-linear-gradient";
const AboutInfo = (props) => {
const navigation = useNavigation();
const AboutInfo = () => {
const [status, setStatus] = useState(true);
const [displayItems, setDisplayItems] = useState([]);
// console.log(displayItems);

const randomData = [
{
id: "1",
employer: "Crop: Maize",
position: "Farm 1",
from: "08/14/2020",
to: "09/14/2021",
},
{
id: "2",
employer: "Crop: Wheat",
position: "Farm 2",
from: "08/14/2020",
to: "09/14/2021",
},
{
id: "3",
employer: "Crop: Paddy",
position: "Farm 3",
from: "08/14/2020",
to: "09/14/2021",
},
{
id: "4",
employer: "Crop: Banana",
position: "Farm 4",
from: "08/14/2020",
to: "09/14/2021",
},
];
const DropDownOptions = [
{
keyIndex: "1",
option: "Farm 1",
},
{
keyIndex: "2",
option: "Farm 2",
},
{
keyIndex: "3",
option: "Farm 3",
},
{
keyIndex: "4",
option: "Farm 4",
},
];
let name = "Srividya";
let category = "Vijaywada, A.P";
const [userData, setUserData] = useState({});

useEffect(() => {
getUserData();
}, [])


const getUserData = useCallback(() => {

AsyncStorage.getItem("userData").then((value) => {
let parseData = JSON.parse(value);
setUserData(parseData);
});

}, [])

const username = (name) => {
var str = name;
Expand All @@ -81,55 +37,21 @@ const AboutInfo = (props) => {
return res;
};

const handleDisplayList = (index, operation) => {
// console.log(index);
let temp = [...displayItems];
switch (operation) {
case "add":
temp.push(index);
setDisplayItems(temp);
break;
case "delete":
const removeIndex = displayItems.findIndex(
(item) => item.keyIndex == index
);
temp.splice(removeIndex, 1);
setDisplayItems([...temp]);
break;
default:
break;
}
};

const DifferenceBetweenDates = (from, to) => {
let date1 = new Date(from);
let date2 = new Date(to);
let numberOfMonths = (date2.getFullYear() - date1.getFullYear()) * 12 + (date2.getMonth() - date1.getMonth()) + 1;
let numberOfYears = (numberOfMonths/12).toFixed(0);
let display = numberOfYears + (numberOfYears == '1'? ' year ':' years ') + numberOfMonths + (numberOfMonths == '1'? ' month':' months')
return(display);
}

return (
<View style={styles.cardView}>
<View style={styles.mainContainer}>
<View style={styles.headingIcon}>
<FontAwesome name="user-o" size={24} color="#707070" />
<Text style={styles.cvHeading}>About You</Text>
</View>
<TouchableOpacity
onPress={() => navigation.navigate("DashboardEditProfile")}
>
<Text style={styles.editButton}>Edit</Text>
</TouchableOpacity>
</View>

<Divider />
<View style={{ flexDirection: "row" }}>
<View style={styles.imageView}>
{status ? (
<View style={styles.ProfilePicBorder}>
<Text style={styles.ProfilePicText}>{username(name)}</Text>
<Text style={styles.ProfilePicText}>{username(userData.name)}</Text>
</View>
) : (
<View>
Expand All @@ -139,104 +61,11 @@ const AboutInfo = (props) => {
</View>

<View style={styles.nameAndCat}>
<Text style={styles.name}>{name}</Text>
<Text style={styles.category}>{category.toUpperCase()}</Text>
<Text style={styles.name}>{userData.name}</Text>
<Text style={styles.category}>{userData.email}</Text>
</View>
</View>
<Divider style={{ padding: 10, margin: 10 }} />
<View style={{ padding: 10 }}>
<Text style={styles.cvHeading}>About</Text>
<Text style={styles.content}>
Repaired and maintained fences, farm machineries, and farm buildings.
Executed and performed feeding and caring for farm animals like horses and cattle.
Drove and operated farm tractors to bush hog and make hay.
Harvested and reaped vegetables, fruits and crops using farm equipment or hand.
Repaired and replaced defective farm equipment.
</Text>
<Divider />
{/* <FlatList
data={DropDownOptions}
keyExtractor={(item) => item.keyIndex}
renderItem={({ item }) => (
<View>
<View
style={{
padding: 10,
flexDirection: "row",
justifyContent: "space-between",
}}
>
<Text style={styles.cvHeading}>{item.option}</Text>
{displayItems.indexOf(item.keyIndex) == -1 ? (
<TouchableOpacity
activeOpacity={1}
onPress={() => handleDisplayList(item.keyIndex, "add")}
>
<Entypo name="chevron-down" size={24} color="#777777" />
</TouchableOpacity>
) : (
<TouchableOpacity
activeOpacity={1}
onPress={() => handleDisplayList(item.keyIndex, "delete")}
>
<Entypo name="chevron-up" size={24} color="#777777" />
</TouchableOpacity>
)}
</View>
{displayItems.indexOf(item.keyIndex) != -1 ? (
<FlatList
data={randomData}
style={{
paddingHorizontal: 10,
}}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View
style={{
flexDirection: "row",
justifyContent: 'space-between',
width: '100%',
alignSelf: "center",
padding: 8,
backgroundColor: "#fff",
borderRadius: 12,
marginHorizontal: 4,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 10,
margin: 14,
elevation: 5,
}}
>
<View>
<Text style={{ color: "#F02F39", fontWeight: 'bold' }}>{item.position}</Text>
<Text style={{ color: "#707070", fontWeight: 'bold' }}>{item.employer}</Text>
<Text style={{color: "#707070"}}>{DifferenceBetweenDates(item.from, item.to)}</Text>
</View>
<TouchableOpacity
style={{ paddingLeft: 5 }}
>
<Entypo name="cross" size={20} color="#F02F39" />
</TouchableOpacity>
</View>
)}
/>
) : null}
</View>
)}
/> */}

<Divider />
<Text style={styles.showMore}>Show More </Text>
</View>

</View>
);
};
Expand Down Expand Up @@ -271,28 +100,9 @@ const styles = StyleSheet.create({
fontSize: 18,
},

mainContainer: {
flexDirection: "row",
justifyContent: "space-between",
},

subHeading: {
padding: 10,
color: "grey",
},
buttonCV: {
width: "50%",
alignSelf: "center",
},
editButton: {
padding: 10,
color: "#FF0000",
},

nameAndCat: {
alignSelf: "center",
justifyContent: "center",
// alignItems: 'center'
},
name: {
fontSize: 18,
Expand All @@ -309,11 +119,7 @@ const styles = StyleSheet.create({
content: {
padding: 10,
},
showMore: {
alignSelf: "center",
color: "#F02F39",
paddingVertical: 10,
},

ProfilePicText: {
fontSize: 40,
color: "#DA9917",
Expand Down
6 changes: 3 additions & 3 deletions Components/LogoutButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const LogoutButton = () => {
const clearData = await AsyncStorage.clear();

AsyncStorage.getItem("userData").then((value) => {
let parseData = JSON.parse(value);
let parseData = JSON.parse(value);
console.log(parseData);
})

Expand All @@ -31,8 +31,8 @@ export const LogoutButton = () => {
);
};
return (
<TouchableOpacity style={{ padding: 8, backgroundColor: 'red', borderRadius: 10 }} onPress={() => LogOutPressed()}>
<Text style={{ fontSize: 16, color: '#fff' }}>Logout</Text>
<TouchableOpacity style={{ padding: 6, backgroundColor: 'red', borderRadius: 5, marginRight:10 }} onPress={() => LogOutPressed()}>
<Text style={{ fontSize: 15, color: '#fff' }}>Logout</Text>
</TouchableOpacity>
)
}
25 changes: 13 additions & 12 deletions Navigation/AppNavigation.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import React, { useState, useEffect, useMemo } from "react";
import { SideDrawer, Auth, StackNav } from "./GrowMoreNavigation";
import React, { useState, useCallback, useMemo, useEffect } from "react";
import { Auth, StackNav } from "./GrowMoreNavigation";
import { NavigationContainer } from "@react-navigation/native";
import StartingScreen from "../Screens/StartingScreen";
import { AuthContext } from "../Context";
import AsyncStorage from "@react-native-async-storage/async-storage";

export const AppNavigation = () => {
const [storage, setStorage] = useState();
const [isLoading, setIsloading] = useState(true);
console.log(storage)

useEffect(() => {

getUserData();
}, [])


const getUserData = useCallback(() => {

AsyncStorage.getItem("userData").then((value) => {
let parseData = JSON.parse(value);
setStorage(parseData);


});
}, []);

}, [])

const authContext = useMemo(() => {
return {
Expand All @@ -27,9 +31,6 @@ export const AppNavigation = () => {
signUp: () => {
setStorage("userSignup");
},
skip: () => {
setStorage("skip");
},
logOut: () => {
setStorage(null);
console.log('Logout')
Expand All @@ -39,7 +40,7 @@ export const AppNavigation = () => {
return (
<AuthContext.Provider value={authContext}>
<NavigationContainer>
{ storage ? <StackNav /> : <Auth />}
{storage ? <StackNav /> : <Auth />}
</NavigationContainer>
</AuthContext.Provider>
);
Expand Down

0 comments on commit 6c939b1

Please sign in to comment.