1- import React , { useCallback } from 'react' ;
1+ import React from 'react' ;
22import { StyleSheet , View } from 'react-native' ;
33
44import { CommandVariants } from 'stream-chat' ;
55
66import { useTheme } from '../../contexts/themeContext/ThemeContext' ;
77import { Flag , GiphyIcon , Imgur , Lightning , Mute , Sound , UserAdd , UserDelete } from '../../icons' ;
88
9+ export const SuggestionCommandIcon = ( { name } : { name : CommandVariants } ) => {
10+ const {
11+ theme : {
12+ colors : { white } ,
13+ } ,
14+ } = useTheme ( ) ;
15+
16+ if ( name === 'ban' ) {
17+ return < UserDelete height = { 16 } pathFill = { white } width = { 16 } /> ;
18+ } else if ( name === 'flag' ) {
19+ return < Flag pathFill = { white } /> ;
20+ } else if ( name === 'giphy' ) {
21+ return < GiphyIcon /> ;
22+ } else if ( name === 'imgur' ) {
23+ return < Imgur /> ;
24+ } else if ( name === 'mute' ) {
25+ return < Mute height = { 16 } pathFill = { white } width = { 16 } /> ;
26+ } else if ( name === 'unban' ) {
27+ return < UserAdd height = { 16 } pathFill = { white } width = { 16 } /> ;
28+ } else if ( name === 'unmute' ) {
29+ return < Sound pathFill = { white } /> ;
30+ } else {
31+ return < Lightning fill = { white } size = { 16 } /> ;
32+ }
33+ } ;
34+
935export const AutoCompleteSuggestionCommandIcon = ( { name } : { name : CommandVariants } ) => {
1036 const {
1137 theme : {
12- colors : { accent_blue, white } ,
38+ colors : { accent_blue } ,
1339 messageInput : {
1440 suggestions : {
1541 command : { iconContainer } ,
@@ -18,32 +44,6 @@ export const AutoCompleteSuggestionCommandIcon = ({ name }: { name: CommandVaria
1844 } ,
1945 } = useTheme ( ) ;
2046
21- const renderIcon = useCallback (
22- ( name : CommandVariants ) => {
23- switch ( name ) {
24- case 'ban' :
25- return < UserDelete height = { 16 } pathFill = { white } width = { 16 } /> ;
26- case 'flag' :
27- return < Flag pathFill = { white } /> ;
28- case 'giphy' :
29- return < GiphyIcon /> ;
30- case 'imgur' :
31- return < Imgur /> ;
32- case 'mute' :
33- return < Mute height = { 16 } pathFill = { white } width = { 16 } /> ;
34- case 'unban' :
35- return < UserAdd height = { 16 } pathFill = { white } width = { 16 } /> ;
36- case 'unmute' :
37- return < Sound pathFill = { white } /> ;
38- default :
39- return < Lightning fill = { white } size = { 16 } /> ;
40- }
41- } ,
42- [ white ] ,
43- ) ;
44-
45- const icon = renderIcon ( name ) ;
46-
4747 return (
4848 < View
4949 style = { [
@@ -54,7 +54,7 @@ export const AutoCompleteSuggestionCommandIcon = ({ name }: { name: CommandVaria
5454 iconContainer ,
5555 ] }
5656 >
57- { icon }
57+ < SuggestionCommandIcon name = { name } />
5858 </ View >
5959 ) ;
6060} ;
0 commit comments