2023-01-20 14:06:26 +00:00
|
|
|
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
|
|
|
/* eslint-disable import/namespace */
|
2023-01-24 13:41:25 +00:00
|
|
|
|
|
|
|
import { useRef } from 'react'
|
|
|
|
|
2023-01-20 14:06:26 +00:00
|
|
|
import { Composer, Messages } from '@status-im/components'
|
|
|
|
import { Stack, useTheme } from '@tamagui/core'
|
2023-01-24 13:41:25 +00:00
|
|
|
import { StatusBar } from 'expo-status-bar'
|
2023-01-20 14:06:26 +00:00
|
|
|
import {
|
|
|
|
Keyboard,
|
|
|
|
KeyboardAvoidingView,
|
|
|
|
Platform,
|
|
|
|
TouchableWithoutFeedback,
|
|
|
|
} from 'react-native'
|
|
|
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
|
|
import { ScrollView } from 'tamagui'
|
|
|
|
|
2023-01-24 13:41:25 +00:00
|
|
|
import type { RootStackParamList } from '../App'
|
|
|
|
import type { NativeStackScreenProps } from '@react-navigation/native-stack'
|
|
|
|
|
|
|
|
type ChannelScreenProps = NativeStackScreenProps<RootStackParamList, 'Channel'>
|
|
|
|
|
|
|
|
export const ChannelScreen = ({ route }: ChannelScreenProps) => {
|
2023-01-20 14:06:26 +00:00
|
|
|
const insets = useSafeAreaInsets()
|
|
|
|
const theme = useTheme()
|
|
|
|
|
2023-01-24 13:41:25 +00:00
|
|
|
// We need to get the channel name from the route params
|
|
|
|
const channelName = route.params.channelId
|
|
|
|
const scrollRef = useRef(null)
|
|
|
|
|
2023-01-20 14:06:26 +00:00
|
|
|
return (
|
|
|
|
<KeyboardAvoidingView
|
|
|
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
|
|
style={{ height: '100%', flex: 1, backgroundColor: theme.background.val }}
|
|
|
|
>
|
2023-01-24 13:41:25 +00:00
|
|
|
<StatusBar style={'dark'} animated />
|
|
|
|
<ScrollView
|
|
|
|
ref={scrollRef}
|
|
|
|
paddingHorizontal={12}
|
|
|
|
width="100%"
|
|
|
|
onContentSizeChange={() => scrollRef.current?.scrollToEnd()}
|
|
|
|
>
|
|
|
|
<Stack pt={insets.top + 60} pb={insets.bottom}>
|
|
|
|
<Messages />
|
|
|
|
</Stack>
|
2023-01-20 14:06:26 +00:00
|
|
|
</ScrollView>
|
2023-01-24 13:41:25 +00:00
|
|
|
|
2023-01-20 14:06:26 +00:00
|
|
|
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
|
2023-01-24 13:41:25 +00:00
|
|
|
<Stack>
|
|
|
|
<Composer
|
|
|
|
pb={insets.bottom + Platform.select({ android: 12, ios: 0 })}
|
|
|
|
/>
|
2023-01-20 14:06:26 +00:00
|
|
|
</Stack>
|
|
|
|
</TouchableWithoutFeedback>
|
|
|
|
</KeyboardAvoidingView>
|
|
|
|
)
|
|
|
|
}
|