Changeset View
Changeset View
Standalone View
Standalone View
native/chat/message-result.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { Text, View } from 'react-native'; | import { Text, View } from 'react-native'; | ||||
import { ScrollView } from 'react-native-gesture-handler'; | import { ScrollView } from 'react-native-gesture-handler'; | ||||
import { type ThreadInfo } from 'lib/types/thread-types.js'; | import { type ThreadInfo } from 'lib/types/thread-types.js'; | ||||
import { longAbsoluteDate } from 'lib/utils/date-utils.js'; | import { longAbsoluteDate } from 'lib/utils/date-utils.js'; | ||||
import type { ChatNavigationProp } from './chat.react'; | import type { ChatNavigationProp } from './chat.react'; | ||||
import { MessageListContextProvider } from './message-list-types.js'; | import { MessageListContextProvider } from './message-list-types.js'; | ||||
import { Message } from './message.react.js'; | import { Message } from './message.react.js'; | ||||
import { modifyItemForResultScreen } from './utils.js'; | |||||
import type { AppNavigationProp } from '../navigation/app-navigator.react'; | import type { AppNavigationProp } from '../navigation/app-navigator.react'; | ||||
import type { NavigationRoute } from '../navigation/route-names'; | import type { NavigationRoute } from '../navigation/route-names'; | ||||
import { useStyles } from '../themes/colors.js'; | import { useStyles } from '../themes/colors.js'; | ||||
import type { ChatMessageInfoItemWithHeight } from '../types/chat-types.js'; | import type { ChatMessageInfoItemWithHeight } from '../types/chat-types.js'; | ||||
import type { VerticalBounds } from '../types/layout-types.js'; | import type { VerticalBounds } from '../types/layout-types.js'; | ||||
type MessageResultProps = { | type MessageResultProps = { | ||||
+item: ChatMessageInfoItemWithHeight, | +item: ChatMessageInfoItemWithHeight, | ||||
+threadInfo: ThreadInfo, | +threadInfo: ThreadInfo, | ||||
+navigation: | +navigation: | ||||
| AppNavigationProp<'TogglePinModal'> | | AppNavigationProp<'TogglePinModal'> | ||||
| ChatNavigationProp<'MessageResultsScreen'>, | | ChatNavigationProp<'MessageResultsScreen'>, | ||||
+route: | +route: | ||||
| NavigationRoute<'TogglePinModal'> | | NavigationRoute<'TogglePinModal'> | ||||
| NavigationRoute<'MessageResultsScreen'>, | | NavigationRoute<'MessageResultsScreen'>, | ||||
+messageVerticalBounds: ?VerticalBounds, | +messageVerticalBounds: ?VerticalBounds, | ||||
}; | }; | ||||
function MessageResult(props: MessageResultProps): React.Node { | function MessageResult(props: MessageResultProps): React.Node { | ||||
const styles = useStyles(unboundStyles); | const styles = useStyles(unboundStyles); | ||||
const onToggleFocus = React.useCallback(() => {}, []); | const onToggleFocus = React.useCallback(() => {}, []); | ||||
const item = React.useMemo( | |||||
() => modifyItemForResultScreen(props.item), | |||||
[props.item], | |||||
); | |||||
return ( | return ( | ||||
<ScrollView style={styles.container}> | <ScrollView style={styles.container}> | ||||
<MessageListContextProvider threadInfo={props.threadInfo}> | <MessageListContextProvider threadInfo={props.threadInfo}> | ||||
<View style={styles.viewContainer}> | <View style={styles.viewContainer}> | ||||
<Message | <Message | ||||
item={props.item} | item={item} | ||||
focused={false} | focused={false} | ||||
navigation={props.navigation} | navigation={props.navigation} | ||||
route={props.route} | route={props.route} | ||||
toggleFocus={onToggleFocus} | toggleFocus={onToggleFocus} | ||||
verticalBounds={props.messageVerticalBounds} | verticalBounds={props.messageVerticalBounds} | ||||
shouldDisplayPinIndicator={false} | shouldDisplayPinIndicator={false} | ||||
/> | /> | ||||
<Text style={styles.messageDate}> | <Text style={styles.messageDate}> | ||||
Show All 27 Lines |