1- import React , { useCallback } from 'react' ;
1+ import React , { useCallback , useMemo } from 'react' ;
22import { FlatList , type FlatListProps , StyleSheet , Text , View } from 'react-native' ;
33
44import { PollOption , PollVote as PollVoteClass } from 'stream-chat' ;
@@ -12,6 +12,7 @@ import {
1212 useTranslationContext ,
1313} from '../../../../contexts' ;
1414
15+ import { primitives } from '../../../../theme' ;
1516import { usePollOptionVotesPagination } from '../../hooks/usePollOptionVotesPagination' ;
1617import { usePollState } from '../../hooks/usePollState' ;
1718
@@ -35,32 +36,40 @@ export const PollOptionFullResultsContent = ({
3536
3637 const {
3738 theme : {
38- colors : { bg_user, black, white } ,
3939 poll : {
40- fullResults : { container, contentContainer, headerContainer, headerText } ,
40+ fullResults : { container, contentContainer, headerContainer, headerText, headerTitle } ,
4141 } ,
4242 } ,
4343 } = useTheme ( ) ;
44+ const styles = useStyles ( ) ;
4445
4546 const PollOptionFullResultsHeader = useCallback (
4647 ( ) => (
4748 < View style = { [ styles . headerContainer , headerContainer ] } >
48- < Text style = { [ styles . headerText , { color : black } , headerText ] } >
49+ < Text style = { [ styles . headerTitle , headerTitle ] } > { option . text } </ Text >
50+ < Text style = { [ styles . headerText , headerText ] } >
4951 { t ( '{{count}} votes' , { count : voteCountsByOption [ option . id ] ?? 0 } ) }
5052 </ Text >
5153 </ View >
5254 ) ,
53- [ black , headerContainer , headerText , option . id , t , voteCountsByOption ] ,
55+ [
56+ headerContainer ,
57+ headerText ,
58+ headerTitle ,
59+ option . id ,
60+ option . text ,
61+ styles . headerContainer ,
62+ styles . headerText ,
63+ styles . headerTitle ,
64+ t ,
65+ voteCountsByOption ,
66+ ] ,
5467 ) ;
5568
5669 return (
57- < View style = { [ styles . container , { backgroundColor : white } , container ] } >
70+ < View style = { [ styles . container , container ] } >
5871 < FlatList
59- contentContainerStyle = { [
60- styles . contentContainer ,
61- { backgroundColor : bg_user } ,
62- contentContainer ,
63- ] }
72+ contentContainerStyle = { [ styles . contentContainer , contentContainer ] }
6473 data = { votes }
6574 keyExtractor = { ( item ) => `option_full_results_${ item . id } ` }
6675 ListHeaderComponent = { PollOptionFullResultsHeader }
@@ -91,16 +100,42 @@ export const PollOptionFullResults = ({
91100 </ PollContextProvider >
92101) ;
93102
94- const styles = StyleSheet . create ( {
95- container : { flex : 1 } ,
96- contentContainer : {
97- borderRadius : 12 ,
98- marginBottom : 8 ,
99- marginHorizontal : 16 ,
100- marginTop : 16 ,
101- paddingHorizontal : 16 ,
102- paddingVertical : 12 ,
103- } ,
104- headerContainer : { flexDirection : 'row' , justifyContent : 'flex-end' , marginBottom : 8 } ,
105- headerText : { fontSize : 16 , marginLeft : 16 } ,
106- } ) ;
103+ const useStyles = ( ) => {
104+ const {
105+ theme : { semantics } ,
106+ } = useTheme ( ) ;
107+ return useMemo (
108+ ( ) =>
109+ StyleSheet . create ( {
110+ container : { flex : 1 , padding : primitives . spacingMd } ,
111+ contentContainer : {
112+ backgroundColor : semantics . backgroundCoreSurfaceCard ,
113+ borderRadius : primitives . radiusLg ,
114+ marginBottom : primitives . spacingMd ,
115+ padding : primitives . spacingMd ,
116+ } ,
117+ headerContainer : {
118+ flexDirection : 'row' ,
119+ justifyContent : 'space-between' ,
120+ alignItems : 'center' ,
121+ paddingBottom : primitives . spacingXs ,
122+ } ,
123+ headerTitle : {
124+ flex : 1 ,
125+ fontSize : primitives . typographyFontSizeLg ,
126+ lineHeight : primitives . typographyLineHeightRelaxed ,
127+ fontWeight : primitives . typographyFontWeightSemiBold ,
128+ color : semantics . textPrimary ,
129+ paddingTop : primitives . spacingXs ,
130+ } ,
131+ headerText : {
132+ fontSize : primitives . typographyFontSizeMd ,
133+ lineHeight : primitives . typographyLineHeightNormal ,
134+ fontWeight : primitives . typographyFontWeightSemiBold ,
135+ color : semantics . textPrimary ,
136+ marginLeft : primitives . spacingMd ,
137+ } ,
138+ } ) ,
139+ [ ] ,
140+ ) ;
141+ } ;
0 commit comments