@@ -14,6 +14,7 @@ import {
1414 useOwnCapabilitiesContext ,
1515 usePollContext ,
1616 useTheme ,
17+ useTranslationContext ,
1718} from '../../../contexts' ;
1819
1920import { Check } from '../../../icons' ;
@@ -26,6 +27,7 @@ import { usePollState } from '../hooks/usePollState';
2627export type PollOptionProps = {
2728 option : PollOptionClass ;
2829 showProgressBar ?: boolean ;
30+ forceIncoming ?: boolean ;
2931} ;
3032
3133export type PollAllOptionsContentProps = PollContextValue & {
@@ -36,6 +38,7 @@ export type PollAllOptionsContentProps = PollContextValue & {
3638export const PollAllOptionsContent = ( {
3739 additionalScrollViewProps,
3840} : Pick < PollAllOptionsContentProps , 'additionalScrollViewProps' > ) => {
41+ const { t } = useTranslationContext ( ) ;
3942 const { name, options } = usePollState ( ) ;
4043
4144 const {
@@ -50,12 +53,13 @@ export const PollAllOptionsContent = ({
5053 return (
5154 < ScrollView style = { [ styles . allOptionsWrapper , wrapper ] } { ...additionalScrollViewProps } >
5255 < View style = { [ styles . allOptionsTitleContainer , titleContainer ] } >
56+ < Text style = { styles . allOptionsTitleMeta } > { t ( 'Question' ) } </ Text >
5357 < Text style = { [ styles . allOptionsTitleText , titleText ] } > { name } </ Text >
5458 </ View >
5559 < View style = { [ styles . allOptionsListContainer , listContainer ] } >
5660 { options ?. map ( ( option : PollOptionClass ) => (
5761 < View key = { `full_poll_options_${ option . id } ` } style = { styles . optionWrapper } >
58- < PollOption key = { option . id } option = { option } showProgressBar = { false } />
62+ < PollOption key = { option . id } option = { option } forceIncoming />
5963 </ View >
6064 ) ) }
6165 </ View >
@@ -78,19 +82,15 @@ export const PollAllOptions = ({
7882 </ PollContextProvider >
7983) ;
8084
81- export const PollOption = ( { option, showProgressBar = true } : PollOptionProps ) => {
82- const { latestVotesByOption, maxVotedOptionIds , voteCountsByOption } = usePollState ( ) ;
85+ export const PollOption = ( { option, showProgressBar = true , forceIncoming } : PollOptionProps ) => {
86+ const { latestVotesByOption, voteCountsByOption , voteCount } = usePollState ( ) ;
8387 const styles = useStyles ( ) ;
8488
8589 const relevantVotes = useMemo (
8690 ( ) => latestVotesByOption ?. [ option . id ] || [ ] ,
8791 [ latestVotesByOption , option . id ] ,
8892 ) ;
89- const maxVotes = useMemo (
90- ( ) =>
91- maxVotedOptionIds ?. [ 0 ] && voteCountsByOption ? voteCountsByOption [ maxVotedOptionIds [ 0 ] ] : 0 ,
92- [ maxVotedOptionIds , voteCountsByOption ] ,
93- ) ;
93+
9494 const votes = voteCountsByOption [ option . id ] || 0 ;
9595
9696 const {
@@ -105,13 +105,15 @@ export const PollOption = ({ option, showProgressBar = true }: PollOptionProps)
105105 } = useTheme ( ) ;
106106 const isPollCreatedByClient = useIsPollCreatedByCurrentUser ( ) ;
107107
108- const unFilledColor = isPollCreatedByClient
109- ? semantics . chatPollProgressTrackOutgoing
110- : semantics . chatPollProgressTrackIncoming ;
108+ const unFilledColor =
109+ isPollCreatedByClient && ! forceIncoming
110+ ? semantics . chatPollProgressTrackOutgoing
111+ : semantics . chatPollProgressTrackIncoming ;
111112
112- const filledColor = isPollCreatedByClient
113- ? semantics . chatPollProgressFillOutgoing
114- : semantics . chatPollProgressFillIncoming ;
113+ const filledColor =
114+ isPollCreatedByClient && ! forceIncoming
115+ ? semantics . chatPollProgressFillOutgoing
116+ : semantics . chatPollProgressFillIncoming ;
115117
116118 return (
117119 < View style = { [ styles . container , container ] } >
@@ -133,7 +135,7 @@ export const PollOption = ({ option, showProgressBar = true }: PollOptionProps)
133135 { showProgressBar ? (
134136 < View style = { styles . progressBarContainer } >
135137 < ProgressBar
136- progress = { votes / maxVotes }
138+ progress = { votes / voteCount }
137139 filledColor = { filledColor }
138140 emptyColor = { unFilledColor }
139141 />
@@ -273,6 +275,13 @@ const useAllOptionStyles = () => {
273275 lineHeight : primitives . typographyLineHeightRelaxed ,
274276 fontWeight : primitives . typographyFontWeightSemiBold ,
275277 color : semantics . textPrimary ,
278+ paddingTop : primitives . spacingXs ,
279+ } ,
280+ allOptionsTitleMeta : {
281+ fontSize : primitives . typographyFontSizeSm ,
282+ color : semantics . textTertiary ,
283+ lineHeight : primitives . typographyLineHeightNormal ,
284+ fontWeight : primitives . typographyFontWeightMedium ,
276285 } ,
277286 allOptionsWrapper : {
278287 flex : 1 ,
0 commit comments