From 82d220552fc69246ee324e87b2254f8127c3a31d Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Mon, 12 Apr 2021 15:23:16 -0400 Subject: fixed image picker position --- src/App.tsx | 5 +-- src/screens/chat/ChatScreen.tsx | 86 ++++++++--------------------------------- 2 files changed, 18 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/App.tsx b/src/App.tsx index b8d64461..217f0627 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,6 @@ import {NavigationContainer} from '@react-navigation/native'; import React, {useState} from 'react'; import {Provider} from 'react-redux'; import {StreamChat} from 'stream-chat'; -import {OverlayProvider} from 'stream-chat-react-native'; import {STREAM_CHAT_API} from './constants'; import {navigationRef} from './RootNavigation'; import Routes from './routes'; @@ -39,9 +38,7 @@ const App = () => { - - - + diff --git a/src/screens/chat/ChatScreen.tsx b/src/screens/chat/ChatScreen.tsx index 682906ee..957b1189 100644 --- a/src/screens/chat/ChatScreen.tsx +++ b/src/screens/chat/ChatScreen.tsx @@ -1,24 +1,21 @@ import {useBottomTabBarHeight} from '@react-navigation/bottom-tabs'; import {StackNavigationProp} from '@react-navigation/stack'; import React, {useContext} from 'react'; -import {Image, StyleSheet, Text, View} from 'react-native'; -import {SafeAreaView} from 'react-native-safe-area-context'; -import {useStore} from 'react-redux'; +import {StyleSheet} from 'react-native'; +import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'; import { Channel, Chat, MessageInput, MessageList, OverlayProvider, - useMessageContext, } from 'stream-chat-react-native'; import {ChatContext} from '../../App'; import ChatHeader from '../../components/messages/ChatHeader'; import {TAGG_LIGHT_BLUE} from '../../constants'; import {MainStackParams} from '../../routes'; -import {RootState} from '../../store/rootReducer'; import {ScreenType} from '../../types'; -import {isIPhoneX, SCREEN_WIDTH} from '../../utils'; +import {HeaderHeight, isIPhoneX, SCREEN_WIDTH} from '../../utils'; type ChatScreenNavigationProp = StackNavigationProp; interface ChatScreenProps { @@ -29,9 +26,8 @@ interface ChatScreenProps { */ const ChatScreen: React.FC = () => { const {channel, chatClient} = useContext(ChatContext); - const state: RootState = useStore().getState(); - const loggedInUserId = state.user.user.userId; const tabbarHeight = useBottomTabBarHeight(); + const insets = useSafeAreaInsets(); const chatTheme = { messageList: { @@ -41,78 +37,30 @@ const ChatScreen: React.FC = () => { }, }; - const isOwnMessage = (message) => { - if (message.user.id === loggedInUserId) { - return true; - } else { - return false; - } - }; - - const OwnMessageBubble = ({message}) => ( - - - - {message.text} - - - {/* TODO: Timestamp */} - - ); - - const UserXMessageBubble = ({message}) => ( - - - - {message.text} - - {/* TODO: Timestamp */} - - ); - - const CustomMessageUIComponent = () => { - const {message} = useMessageContext(); - if (isOwnMessage(message)) { - return ; - } else { - return ; - } - }; - return ( - - - - + + + + null} - // MessageSimple={CustomMessageUIComponent} messageActions={({copyMessage, deleteMessage}) => [ copyMessage, deleteMessage, - ]} - // AttachButton={() => null} - > + ]}> {}} /> - - - + + + ); }; -- cgit v1.2.3-70-g09d2