@@ -6,8 +6,12 @@ import Swipeable from 'react-native-gesture-handler/Swipeable';
66import {
77 ChannelPreviewMessenger ,
88 ChannelPreviewMessengerProps ,
9+ ChannelPreviewStatus ,
10+ ChannelPreviewStatusProps ,
911 Delete ,
1012 MenuPointHorizontal ,
13+ Pin ,
14+ useChannelMembershipState ,
1115 useChatContext ,
1216 useTheme ,
1317} from 'stream-chat-react-native' ;
@@ -19,6 +23,7 @@ import { useChannelInfoOverlayContext } from '../context/ChannelInfoOverlayConte
1923import type { StackNavigationProp } from '@react-navigation/stack' ;
2024
2125import type { StackNavigatorParamList , StreamChatGenerics } from '../types' ;
26+ import { ChannelState } from 'stream-chat' ;
2227
2328const styles = StyleSheet . create ( {
2429 leftSwipeableButton : {
@@ -35,13 +40,37 @@ const styles = StyleSheet.create({
3540 alignItems : 'center' ,
3641 flexDirection : 'row' ,
3742 } ,
43+ statusContainer : {
44+ display : 'flex' ,
45+ flexDirection : 'row' ,
46+ } ,
47+ pinIconContainer : {
48+ marginLeft : 8 ,
49+ } ,
3850} ) ;
3951
4052type ChannelListScreenNavigationProp = StackNavigationProp <
4153 StackNavigatorParamList ,
4254 'ChannelListScreen'
4355> ;
4456
57+ const CustomChannelPreviewStatus = (
58+ props : ChannelPreviewStatusProps & { membership : ChannelState [ 'membership' ] } ,
59+ ) => {
60+ const { membership } = props ;
61+
62+ return (
63+ < View style = { styles . statusContainer } >
64+ < ChannelPreviewStatus { ...props } />
65+ { membership . pinned_at && (
66+ < View style = { styles . pinIconContainer } >
67+ < Pin size = { 24 } />
68+ </ View >
69+ ) }
70+ </ View >
71+ ) ;
72+ } ;
73+
4574export const ChannelPreview : React . FC < ChannelPreviewMessengerProps < StreamChatGenerics > > = (
4675 props ,
4776) => {
@@ -57,6 +86,8 @@ export const ChannelPreview: React.FC<ChannelPreviewMessengerProps<StreamChatGen
5786
5887 const navigation = useNavigation < ChannelListScreenNavigationProp > ( ) ;
5988
89+ const membership = useChannelMembershipState ( channel ) ;
90+
6091 const {
6192 theme : {
6293 colors : { accent_red, white_smoke } ,
@@ -75,7 +106,7 @@ export const ChannelPreview: React.FC<ChannelPreviewMessengerProps<StreamChatGen
75106 < View style = { [ styles . swipeableContainer , { backgroundColor : white_smoke } ] } >
76107 < RectButton
77108 onPress = { ( ) => {
78- setData ( { channel, clientId : client . userID , navigation } ) ;
109+ setData ( { channel, clientId : client . userID , membership , navigation } ) ;
79110 setOverlay ( 'channelInfo' ) ;
80111 } }
81112 style = { [ styles . leftSwipeableButton ] }
@@ -104,7 +135,13 @@ export const ChannelPreview: React.FC<ChannelPreviewMessengerProps<StreamChatGen
104135 </ View >
105136 ) }
106137 >
107- < ChannelPreviewMessenger { ...props } />
138+ < ChannelPreviewMessenger
139+ { ...props }
140+ // eslint-disable-next-line react/no-unstable-nested-components
141+ PreviewStatus = { ( statusProps ) => (
142+ < CustomChannelPreviewStatus { ...statusProps } membership = { membership } />
143+ ) }
144+ />
108145 </ Swipeable >
109146 ) ;
110147} ;
0 commit comments