Changeset View
Changeset View
Standalone View
Standalone View
native/chat/chat.react.js
Show All 15 Lines | |||||
} from '@react-navigation/native'; | } from '@react-navigation/native'; | ||||
import { StackView, type StackHeaderProps } from '@react-navigation/stack'; | import { StackView, type StackHeaderProps } from '@react-navigation/stack'; | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { Platform, View } from 'react-native'; | import { Platform, View } from 'react-native'; | ||||
import { useSelector } from 'react-redux'; | import { useSelector } from 'react-redux'; | ||||
import { isLoggedIn } from 'lib/selectors/user-selectors'; | import { isLoggedIn } from 'lib/selectors/user-selectors'; | ||||
import { threadIsPending } from 'lib/shared/thread-utils'; | import { | ||||
threadIsPending, | |||||
threadMembersWithoutAddedAshoat, | |||||
} from 'lib/shared/thread-utils'; | |||||
import { firstLine } from 'lib/utils/string-utils'; | import { firstLine } from 'lib/utils/string-utils'; | ||||
import KeyboardAvoidingView from '../components/keyboard-avoiding-view.react'; | import KeyboardAvoidingView from '../components/keyboard-avoiding-view.react'; | ||||
import SWMansionIcon from '../components/swmansion-icon.react'; | import SWMansionIcon from '../components/swmansion-icon.react'; | ||||
import { InputStateContext } from '../input/input-state'; | import { InputStateContext } from '../input/input-state'; | ||||
import HeaderBackButton from '../navigation/header-back-button.react'; | import HeaderBackButton from '../navigation/header-back-button.react'; | ||||
import { defaultStackScreenOptions } from '../navigation/options'; | import { defaultStackScreenOptions } from '../navigation/options'; | ||||
import { | import { | ||||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | const chatThreadListOptions = ({ navigation }) => ({ | ||||
headerTitle: 'Inbox', | headerTitle: 'Inbox', | ||||
headerRight: | headerRight: | ||||
Platform.OS === 'ios' | Platform.OS === 'ios' | ||||
? () => <ComposeThreadButton navigate={navigation.navigate} /> | ? () => <ComposeThreadButton navigate={navigation.navigate} /> | ||||
: undefined, | : undefined, | ||||
headerBackTitleVisible: false, | headerBackTitleVisible: false, | ||||
headerStyle: unboundStyles.threadListHeaderStyle, | headerStyle: unboundStyles.threadListHeaderStyle, | ||||
}); | }); | ||||
const messageListOptions = ({ navigation, route }) => ({ | |||||
const messageListOptions = ({ navigation, route }) => { | |||||
const isSearchEmpty = | |||||
!!route.params.searching && | |||||
threadMembersWithoutAddedAshoat(route.params.threadInfo).length === 1; | |||||
const areSettingsEnabled = | |||||
!threadIsPending(route.params.threadInfo.id) && !isSearchEmpty; | |||||
return { | |||||
// This is a render prop, not a component | // This is a render prop, not a component | ||||
// eslint-disable-next-line react/display-name | // eslint-disable-next-line react/display-name | ||||
headerTitle: () => ( | headerTitle: () => ( | ||||
<MessageListHeaderTitle | <MessageListHeaderTitle | ||||
threadInfo={route.params.threadInfo} | threadInfo={route.params.threadInfo} | ||||
searching={route.params.searching} | |||||
navigate={navigation.navigate} | navigate={navigation.navigate} | ||||
areSettingsEnabled={areSettingsEnabled} | |||||
isSearchEmpty={isSearchEmpty} | |||||
/> | /> | ||||
), | ), | ||||
headerTitleContainerStyle: { | headerTitleContainerStyle: { | ||||
marginHorizontal: Platform.select({ ios: 80, default: 0 }), | marginHorizontal: Platform.select({ ios: 80, default: 0 }), | ||||
flex: 1, | flex: 1, | ||||
}, | }, | ||||
headerRight: | headerRight: | ||||
Platform.OS === 'android' && !threadIsPending(route.params.threadInfo.id) | Platform.OS === 'android' && areSettingsEnabled | ||||
? // This is a render prop, not a component | ? // This is a render prop, not a component | ||||
// eslint-disable-next-line react/display-name | // eslint-disable-next-line react/display-name | ||||
() => ( | () => ( | ||||
<ThreadSettingsButton | <ThreadSettingsButton | ||||
threadInfo={route.params.threadInfo} | threadInfo={route.params.threadInfo} | ||||
navigate={navigation.navigate} | navigate={navigation.navigate} | ||||
/> | /> | ||||
) | ) | ||||
: undefined, | : undefined, | ||||
headerBackTitleVisible: false, | headerBackTitleVisible: false, | ||||
}); | }; | ||||
}; | |||||
const composeThreadOptions = { | const composeThreadOptions = { | ||||
headerTitle: 'Compose chat', | headerTitle: 'Compose chat', | ||||
headerBackTitleVisible: false, | headerBackTitleVisible: false, | ||||
}; | }; | ||||
const threadSettingsOptions = ({ route }) => ({ | const threadSettingsOptions = ({ route }) => ({ | ||||
headerTitle: firstLine(route.params.threadInfo.uiName), | headerTitle: firstLine(route.params.threadInfo.uiName), | ||||
headerBackTitleVisible: false, | headerBackTitleVisible: false, | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |