diff --git a/components/Posts/PollWithVotes.js b/components/Posts/PollWithVotes.js index 06749c6..003932c 100644 --- a/components/Posts/PollWithVotes.js +++ b/components/Posts/PollWithVotes.js @@ -165,6 +165,10 @@ class PollWithVotes extends PollClass { this.props.navigation.navigate('VotesViewPage', {postId: this.props.post._id, postFormat: 'Poll'}) } + navigateToPollVotesViewPage = (pollOption) => { + this.props.navigation.navigate('PollVoteViewPage', {pollId: this.props.post._id, pollOption}) + } + render() { this.votes = this.props.post.optionOnesVotes + this.props.post.optionTwosVotes + this.props.post.optionThreesVotes + this.props.post.optionFoursVotes + this.props.post.optionFivesVotes + this.props.post.optionSixesVotes; this.optionOnesBarLength = this.votes === 0 ? this.calculateZeroVoteLength(1) : this.props.post.optionOnesVotes / this.votes * 100 @@ -246,9 +250,11 @@ class PollWithVotes extends PollClass { - Votes - - {this.props.post.optionOnesVotes} + this.navigateToPollVotesViewPage("One")} style={{width: '100%', alignItems: 'center'}}> + Votes + + {this.props.post.optionOnesVotes} + {this.props.post.votedFor === "One" ? this.handleRemoveVoteOnPoll() : this.handleVoteOnPoll("One")}} disabled={this.props.post.pollVoteChanging}> @@ -284,9 +290,11 @@ class PollWithVotes extends PollClass { - Votes - - {this.props.post.optionTwosVotes} + this.navigateToPollVotesViewPage("Two")} style={{width: '100%', alignItems: 'center'}}> + Votes + + {this.props.post.optionTwosVotes} + {this.props.post.votedFor === "Two" ? this.handleRemoveVoteOnPoll() : this.handleVoteOnPoll("Two")}}> @@ -320,9 +328,11 @@ class PollWithVotes extends PollClass { - Votes - - {this.props.post.optionThreesVotes} + this.navigateToPollVotesViewPage("Three")} style={{width: '100%', alignItems: 'center'}}> + Votes + + {this.props.post.optionThreesVotes} + {this.props.post.votedFor === "Three" ? this.handleRemoveVoteOnPoll() : this.handleVoteOnPoll("Three")}}> @@ -356,9 +366,11 @@ class PollWithVotes extends PollClass { - Votes - - {this.props.post.optionFoursVotes} + this.navigateToPollVotesViewPage("Four")} style={{width: '100%', alignItems: 'center'}}> + Votes + + {this.props.post.optionFoursVotes} + {this.props.post.votedFor === "Four" ? this.handleRemoveVoteOnPoll() : this.handleVoteOnPoll("Four")}}> @@ -392,9 +404,11 @@ class PollWithVotes extends PollClass { - Votes - - {this.props.post.optionFivesVotes} + this.navigateToPollVotesViewPage("Five")} style={{width: '100%', alignItems: 'center'}}> + Votes + + {this.props.post.optionFivesVotes} + {this.props.post.votedFor === "Five" ? this.handleRemoveVoteOnPoll() : this.handleVoteOnPoll("Five")}}> @@ -428,9 +442,11 @@ class PollWithVotes extends PollClass { - Votes - - {this.props.post.optionSixesVotes} + this.navigateToPollVotesViewPage("Six")} style={{width: '100%', alignItems: 'center'}}> + Votes + + {this.props.post.optionSixesVotes} + {this.props.post.votedFor === "Six" ? this.handleRemoveVoteOnPoll() : this.handleVoteOnPoll("Six")}}> diff --git a/navigation/StackNavigator.js b/navigation/StackNavigator.js index 46e411a..d35e481 100644 --- a/navigation/StackNavigator.js +++ b/navigation/StackNavigator.js @@ -83,6 +83,7 @@ import LoginActivitySettings from "../screens/SecuritySettingsScreens/LoginActiv import PostUpvoteDownvoteActivity from "../screens/ActivityScreens/PostUpvoteDownvoteActivity.js"; import VotesViewPage from "../screens/VotesViewPage.js"; import CategoryMemberViewPage from "../screens/CategoryMemberViewPage.js"; +import PollVoteViewPage from "../screens/PollVoteViewPage.js"; const Stack = createStackNavigator(); @@ -136,6 +137,7 @@ const RootStack = () => { + @@ -172,6 +174,7 @@ const FindScreen_Stack = () => { + @@ -204,6 +207,7 @@ const HomeScreenStack = () => { + diff --git a/screens/PollVoteViewPage.js b/screens/PollVoteViewPage.js new file mode 100644 index 0000000..63dd76b --- /dev/null +++ b/screens/PollVoteViewPage.js @@ -0,0 +1,37 @@ +import ItemAutoList from '../components/ItemAutoList'; +import TopNavBar from '../components/TopNavBar'; +import useItemReducer from '../hooks/useItemReducer'; +import UserItem from "../components/Users/UserItem"; + +export default function PollVoteViewPage({route}) { + const {pollId, pollOption} = route.params; + const [state, dispatch] = useItemReducer(); + + return ( + <> + + { + return { + length: 70, + offset: 70 * index, + index + } + } + }} + state={state} + dispatch={dispatch} + noMoreItemsText="No more votes left." + /> + + ) +} \ No newline at end of file