generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from Real-Dev-Squad/DisplayContributions
added display active task + refactor PR
- Loading branch information
Showing
5 changed files
with
221 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { | ||
View, | ||
StyleSheet, | ||
Text, | ||
TouchableOpacity, | ||
Linking, | ||
Image, | ||
} from 'react-native'; | ||
import React, { useState } from 'react'; | ||
import { | ||
calculateTimeDifference, | ||
convertTimestampToReadableDate, | ||
} from '../../screens/AuthScreen/Util'; | ||
|
||
const DisplayContribution = ({ tasks }) => { | ||
const [clicked, setClicked] = useState(false); | ||
|
||
return ( | ||
<View style={{ padding: 5 }}> | ||
<TouchableOpacity | ||
onPress={() => setClicked(!clicked)} | ||
style={styles.DropDownButton} | ||
> | ||
<Text style={styles.DropDownTitle}>Active Tasks</Text> | ||
{clicked ? ( | ||
<Image | ||
style={styles.ImageDimensions} | ||
source={require('../../../assets/down.png')} | ||
/> | ||
) : ( | ||
<Image | ||
style={styles.ImageDimensions} | ||
source={require('../../../assets/right.png')} | ||
/> | ||
)} | ||
</TouchableOpacity> | ||
{clicked | ||
? tasks.map((item, index) => ( | ||
<View style={styles.DropDownElement} key={index}> | ||
<TouchableOpacity | ||
style={styles.DropDownbackground} | ||
onPress={ | ||
item.github.issue.html_url | ||
? () => Linking.openURL(item.github.issue.html_url) | ||
: null | ||
} | ||
> | ||
<Text style={styles.ItemTaskTitle}>{item.title}</Text> | ||
<> | ||
{item.purpose ? ( | ||
<Text style={styles.ItemTaskPurpose}>{item?.purpose}</Text> | ||
) : null} | ||
</> | ||
<> | ||
{item.github ? ( | ||
<Text style={styles.EstimatedTimeChoice1}> | ||
Estimated completion:{' '} | ||
{calculateTimeDifference( | ||
convertTimestampToReadableDate(item.startedOn), | ||
convertTimestampToReadableDate(item.endsOn), | ||
)} | ||
</Text> | ||
) : ( | ||
<Text style={styles.EstimatedTimeChoice2}> | ||
Estimated completion:{' '} | ||
{calculateTimeDifference( | ||
convertTimestampToReadableDate(item.startedOn), | ||
convertTimestampToReadableDate(item.endsOn), | ||
)} | ||
</Text> | ||
)} | ||
</> | ||
<> | ||
{item.github ? ( | ||
<Text style={styles.CheckoutLive}> | ||
Checkout this feature in action | ||
</Text> | ||
) : null} | ||
</> | ||
</TouchableOpacity> | ||
</View> | ||
)) | ||
: null} | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
DropDownButton: { | ||
width: '100%', | ||
height: 80, | ||
elevation: 5, | ||
borderRadius: 10, | ||
backgroundColor: 'white', | ||
alignSelf: 'center', | ||
flexDirection: 'row', | ||
justifyContent: 'space-evenly', | ||
alignItems: 'center', | ||
paddingLeft: 35, | ||
}, | ||
DropDownTitle: { | ||
fontWeight: '600', | ||
fontSize: 20, | ||
flex: 1, | ||
color: 'black', | ||
}, | ||
DropDownElement: { | ||
color: 'black', | ||
width: '100%', | ||
alignSelf: 'center', | ||
height: 'auto', | ||
}, | ||
DropDownbackground: { | ||
padding: 10, | ||
marginTop: 5, | ||
alignSelf: 'center', | ||
width: '90%', | ||
backgroundColor: '#fff', | ||
borderRadius: 5, | ||
}, | ||
ImageDimensions: { | ||
height: 100, | ||
width: 100, | ||
}, | ||
EstimatedTimeChoice1: { | ||
color: 'black', | ||
fontSize: 15, | ||
fontWeight: 'bold', | ||
borderBottomColor: 'grey', | ||
borderBottomWidth: 1, | ||
marginTop: 5, | ||
}, | ||
EstimatedTimeChoice2: { | ||
color: 'black', | ||
fontWeight: 'bold', | ||
fontSize: 13, | ||
marginTop: 5, | ||
}, | ||
CheckoutLive: { | ||
color: 'grey', | ||
textAlign: 'center', | ||
}, | ||
ItemTaskTitle: { | ||
color: 'blue', | ||
fontSize: 18, | ||
}, | ||
ItemTaskPurpose: { | ||
color: 'black', | ||
marginTop: 5, | ||
}, | ||
}); | ||
|
||
export default DisplayContribution; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 19 additions & 55 deletions
74
src/screens/ProfileScreen/User Data/UserContributions/ActiveTask.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,25 @@ | ||
import React, { useState } from 'react'; | ||
import { View, StyleSheet, Text, TouchableOpacity, Image } from 'react-native'; | ||
import React, { useCallback, useContext, useState } from 'react'; | ||
import { AuthContext } from '../../../../context/AuthContext'; | ||
import { useFocusEffect } from '@react-navigation/native'; | ||
import { fetchActiveTasks } from '../../../AuthScreen/Util'; | ||
import DisplayContribution from '../../../../components/UserContibution/DisplayContribution'; | ||
|
||
const ActiveTaskDropDown = () => { | ||
const [clicked, setClicked] = useState(false); | ||
return ( | ||
<View style={{ padding: 5 }}> | ||
<TouchableOpacity | ||
onPress={() => setClicked(!clicked)} | ||
style={styles.DropDownButton} | ||
> | ||
<Text style={styles.DropDownTitle}>Active tasks</Text> | ||
{clicked ? ( | ||
<Image | ||
style={styles.ImageDimensions} | ||
source={require('../../../../../assets/down.png')} | ||
/> | ||
) : ( | ||
<Image | ||
style={styles.ImageDimensions} | ||
source={require('../../../../../assets/right.png')} | ||
/> | ||
)} | ||
</TouchableOpacity> | ||
</View> | ||
const [activeTasks, setActiveTasks] = useState([]); | ||
const { loggedInUserData } = useContext(AuthContext); | ||
|
||
useFocusEffect( | ||
useCallback(() => { | ||
(async () => { | ||
const userName = loggedInUserData?.username; | ||
const contributionResponse = await fetchActiveTasks(userName); | ||
setActiveTasks(contributionResponse.tasks); | ||
})(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []), | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
DropDownButton: { | ||
width: '100%', | ||
height: 80, | ||
elevation: 5, | ||
borderRadius: 10, | ||
backgroundColor: 'white', | ||
alignSelf: 'center', | ||
flexDirection: 'row', | ||
justifyContent: 'space-evenly', | ||
alignItems: 'center', | ||
paddingLeft: 35, | ||
}, | ||
DropDownTitle: { | ||
fontWeight: '600', | ||
fontSize: 20, | ||
flex: 1, | ||
color: 'black', | ||
}, | ||
DropDownElement: { | ||
color: 'black', | ||
width: '100%', | ||
alignSelf: 'center', | ||
height: 50, | ||
borderBottomWidth: 0.5, | ||
}, | ||
ImageDimensions: { | ||
height: 100, | ||
width: 100, | ||
}, | ||
}); | ||
return <DisplayContribution tasks={activeTasks} />; | ||
}; | ||
|
||
export default ActiveTaskDropDown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters