11import React , { useContext , useEffect , useMemo , useState } from 'react' ;
2- import {
3- I18nManager ,
4- LogBox ,
5- Platform ,
6- Pressable ,
7- SafeAreaView ,
8- StyleSheet ,
9- useColorScheme ,
10- View ,
11- } from 'react-native' ;
2+ import { I18nManager , LogBox , Platform , SafeAreaView , useColorScheme , View } from 'react-native' ;
123import { DarkTheme , DefaultTheme , NavigationContainer , RouteProp } from '@react-navigation/native' ;
134import { createStackNavigator , StackNavigationProp } from '@react-navigation/stack' ;
145import { useHeaderHeight } from '@react-navigation/elements' ;
156import { SafeAreaProvider , useSafeAreaInsets } from 'react-native-safe-area-context' ;
167import { Channel as ChannelType , ChannelSort } from 'stream-chat' ;
178import {
18- Archieve ,
199 Channel ,
2010 ChannelList ,
21- ChannelPreviewStatus ,
22- ChannelPreviewStatusProps ,
2311 Chat ,
2412 MessageInput ,
2513 MessageList ,
2614 OverlayProvider ,
27- Pin ,
2815 Streami18n ,
2916 Thread ,
3017 ThreadContextValue ,
31- Unpin ,
3218 useAttachmentPickerContext ,
33- useChannelMembershipState ,
3419 useCreateChatClient ,
3520 useOverlayContext ,
3621} from 'stream-chat-react-native' ;
@@ -105,51 +90,6 @@ type ChannelListScreenProps = {
10590 navigation : StackNavigationProp < NavigationParamsList , 'ChannelList' > ;
10691} ;
10792
108- const CustomChannelPreviewStatus = ( props : ChannelPreviewStatusProps ) => {
109- const { channel } = props ;
110- const membership = useChannelMembershipState ( channel ) ;
111-
112- return (
113- < View style = { styles . statusContainer } >
114- < ChannelPreviewStatus { ...props } />
115- < Pressable
116- style = { styles . iconContainer }
117- onPress = { async ( ) => {
118- if ( membership . pinned_at ) {
119- await channel . unpin ( ) ;
120- } else {
121- await channel . pin ( ) ;
122- }
123- } }
124- >
125- { membership . pinned_at ? < Unpin height = { 24 } width = { 24 } pathFill = 'red' /> : < Pin size = { 24 } /> }
126- </ Pressable >
127- < Pressable
128- style = { styles . iconContainer }
129- onPress = { async ( ) => {
130- if ( membership . archived_at ) {
131- await channel . unarchive ( ) ;
132- } else {
133- await channel . archive ( ) ;
134- }
135- } }
136- >
137- < Archieve height = { 24 } width = { 24 } fill = { membership . archived_at ? 'red' : 'grey' } />
138- </ Pressable >
139- </ View >
140- ) ;
141- } ;
142-
143- const styles = StyleSheet . create ( {
144- statusContainer : {
145- flexDirection : 'row' ,
146- alignItems : 'center' ,
147- } ,
148- iconContainer : {
149- marginLeft : 8 ,
150- } ,
151- } ) ;
152-
15393const ChannelListScreen : React . FC < ChannelListScreenProps > = ( { navigation } ) => {
15494 const { setChannel } = useContext ( AppContext ) ;
15595
@@ -158,7 +98,6 @@ const ChannelListScreen: React.FC<ChannelListScreenProps> = ({ navigation }) =>
15898 return (
15999 < View style = { { height : '100%' } } >
160100 < ChannelList < StreamChatGenerics >
161- PreviewStatus = { CustomChannelPreviewStatus }
162101 filters = { memoizedFilters }
163102 onSelect = { ( channel ) => {
164103 setChannel ( channel ) ;
0 commit comments