@@ -3,6 +3,7 @@ import { Text } from 'react-native';
33import styled from '@stream-io/styled-components' ;
44import { emojiData } from '../utils' ;
55import PropTypes from 'prop-types' ;
6+ import { themed } from '../styles/theme' ;
67
78import leftTail from '../images/reactionlist/left-tail.png' ;
89import leftCenter from '../images/reactionlist/left-center.png' ;
@@ -81,79 +82,88 @@ const Reactions = styled.View`
8182 flex-direction: row;
8283` ;
8384
84- export class ReactionList extends React . PureComponent {
85- constructor ( props ) {
86- super ( props ) ;
87- }
88-
89- static propTypes = {
90- latestReactions : PropTypes . array ,
91- openReactionSelector : PropTypes . func ,
92- getTotalReactionCount : PropTypes . func ,
93- visible : PropTypes . bool ,
94- position : PropTypes . string ,
95- } ;
96-
97- _renderReactions = ( reactions ) => {
98- const reactionsByType = { } ;
99- reactions . map ( ( item ) => {
100- if ( reactions [ item . type ] === undefined ) {
101- return ( reactionsByType [ item . type ] = [ item ] ) ;
102- } else {
103- return ( reactionsByType [ item . type ] = [
104- ...reactionsByType [ item . type ] ,
105- item ,
106- ] ) ;
107- }
108- } ) ;
109-
110- const emojiDataByType = { } ;
111- emojiData . forEach ( ( e ) => ( emojiDataByType [ e . id ] = e ) ) ;
112-
113- const reactionTypes = emojiData . map ( ( e ) => e . id ) ;
114- return Object . keys ( reactionsByType ) . map ( ( type ) =>
115- reactionTypes . indexOf ( type ) > - 1 ? (
116- < Text key = { type } > { emojiDataByType [ type ] . icon } </ Text >
117- ) : null ,
118- ) ;
119- } ;
120-
121- render ( ) {
122- const {
123- latestReactions,
124- openReactionSelector,
125- getTotalReactionCount,
126- visible,
127- position,
128- } = this . props ;
129- return (
130- < TouchableWrapper
131- position = { position }
132- onPress = { openReactionSelector }
133- activeOpacity = { 1 }
134- >
135- < Container visible = { visible } >
136- < Reactions > { this . _renderReactions ( latestReactions ) } </ Reactions >
137- < ReactionCount reactionCounts = { getTotalReactionCount ( ) } >
138- { getTotalReactionCount ( ) }
139- </ ReactionCount >
140- </ Container >
141- < ImageWrapper visible = { visible } >
142- { position === 'left' ? (
143- < React . Fragment >
144- < LeftTail source = { leftTail } />
145- < LeftCenter source = { leftCenter } resizeMode = "stretch" />
146- < LeftEnd source = { leftEnd } />
147- </ React . Fragment >
148- ) : (
149- < React . Fragment >
150- < RightEnd source = { rightEnd } />
151- < RightCenter source = { rightCenter } resizeMode = "stretch" />
152- < RightTail source = { rightTail } />
153- </ React . Fragment >
154- ) }
155- </ ImageWrapper >
156- </ TouchableWrapper >
157- ) ;
158- }
159- }
85+ /**
86+ * @example ./docs/ReactionList.md
87+ * @extends PureComponent
88+ */
89+
90+ export const ReactionList = themed (
91+ class ReactionList extends React . PureComponent {
92+ static themePath = 'message.reactionList' ;
93+
94+ constructor ( props ) {
95+ super ( props ) ;
96+ }
97+
98+ static propTypes = {
99+ latestReactions : PropTypes . array ,
100+ openReactionSelector : PropTypes . func ,
101+ getTotalReactionCount : PropTypes . func ,
102+ visible : PropTypes . bool ,
103+ position : PropTypes . string ,
104+ } ;
105+
106+ _renderReactions = ( reactions ) => {
107+ const reactionsByType = { } ;
108+ reactions . map ( ( item ) => {
109+ if ( reactions [ item . type ] === undefined ) {
110+ return ( reactionsByType [ item . type ] = [ item ] ) ;
111+ } else {
112+ return ( reactionsByType [ item . type ] = [
113+ ...reactionsByType [ item . type ] ,
114+ item ,
115+ ] ) ;
116+ }
117+ } ) ;
118+
119+ const emojiDataByType = { } ;
120+ emojiData . forEach ( ( e ) => ( emojiDataByType [ e . id ] = e ) ) ;
121+
122+ const reactionTypes = emojiData . map ( ( e ) => e . id ) ;
123+ return Object . keys ( reactionsByType ) . map ( ( type ) =>
124+ reactionTypes . indexOf ( type ) > - 1 ? (
125+ < Text key = { type } > { emojiDataByType [ type ] . icon } </ Text >
126+ ) : null ,
127+ ) ;
128+ } ;
129+
130+ render ( ) {
131+ const {
132+ latestReactions,
133+ openReactionSelector,
134+ getTotalReactionCount,
135+ visible,
136+ position,
137+ } = this . props ;
138+ return (
139+ < TouchableWrapper
140+ position = { position }
141+ onPress = { openReactionSelector }
142+ activeOpacity = { 1 }
143+ >
144+ < Container visible = { visible } >
145+ < Reactions > { this . _renderReactions ( latestReactions ) } </ Reactions >
146+ < ReactionCount reactionCounts = { getTotalReactionCount ( ) } >
147+ { getTotalReactionCount ( ) }
148+ </ ReactionCount >
149+ </ Container >
150+ < ImageWrapper visible = { visible } >
151+ { position === 'left' ? (
152+ < React . Fragment >
153+ < LeftTail source = { leftTail } />
154+ < LeftCenter source = { leftCenter } resizeMode = "stretch" />
155+ < LeftEnd source = { leftEnd } />
156+ </ React . Fragment >
157+ ) : (
158+ < React . Fragment >
159+ < RightEnd source = { rightEnd } />
160+ < RightCenter source = { rightCenter } resizeMode = "stretch" />
161+ < RightTail source = { rightTail } />
162+ </ React . Fragment >
163+ ) }
164+ </ ImageWrapper >
165+ </ TouchableWrapper >
166+ ) ;
167+ }
168+ } ,
169+ ) ;
0 commit comments