Changeset View
Changeset View
Standalone View
Standalone View
native/chat/chat.react.js
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | import { | ||||
BackgroundChatThreadListRouteName, | BackgroundChatThreadListRouteName, | ||||
type ScreenParamList, | type ScreenParamList, | ||||
type ChatParamList, | type ChatParamList, | ||||
type ChatTopTabsParamList, | type ChatTopTabsParamList, | ||||
MessageSearchRouteName, | MessageSearchRouteName, | ||||
} from '../navigation/route-names.js'; | } from '../navigation/route-names.js'; | ||||
import MessageSearch from '../search/message-search.react.js'; | import MessageSearch from '../search/message-search.react.js'; | ||||
import SearchHeader from '../search/search-header.react.js'; | import SearchHeader from '../search/search-header.react.js'; | ||||
import SearchMessagesButton from '../search/search-messages-button.react.js'; | |||||
import { useColors, useStyles } from '../themes/colors.js'; | import { useColors, useStyles } from '../themes/colors.js'; | ||||
const unboundStyles = { | const unboundStyles = { | ||||
keyboardAvoidingView: { | keyboardAvoidingView: { | ||||
flex: 1, | flex: 1, | ||||
}, | }, | ||||
view: { | view: { | ||||
flex: 1, | flex: 1, | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | |||||
const header = (props: CoreStackHeaderProps) => { | const header = (props: CoreStackHeaderProps) => { | ||||
// Flow has trouble reconciling identical types between different libdefs, | // Flow has trouble reconciling identical types between different libdefs, | ||||
// and flow-typed has no way for one libdef to depend on another | // and flow-typed has no way for one libdef to depend on another | ||||
const castProps: StackHeaderProps = (props: any); | const castProps: StackHeaderProps = (props: any); | ||||
return <ChatHeader {...castProps} />; | return <ChatHeader {...castProps} />; | ||||
}; | }; | ||||
const headerRightStyle = { flexDirection: 'row' }; | |||||
const messageListOptions = ({ navigation, route }) => { | const messageListOptions = ({ navigation, route }) => { | ||||
const isSearchEmpty = | const isSearchEmpty = | ||||
!!route.params.searching && | !!route.params.searching && | ||||
threadMembersWithoutAddedAshoat(route.params.threadInfo).length === 1; | threadMembersWithoutAddedAshoat(route.params.threadInfo).length === 1; | ||||
const areSettingsEnabled = | const areSettingsEnabled = | ||||
!threadIsPending(route.params.threadInfo.id) && !isSearchEmpty; | !threadIsPending(route.params.threadInfo.id) && !isSearchEmpty; | ||||
return { | 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: props => ( | headerTitle: props => ( | ||||
<MessageListHeaderTitle | <MessageListHeaderTitle | ||||
threadInfo={route.params.threadInfo} | threadInfo={route.params.threadInfo} | ||||
navigate={navigation.navigate} | navigate={navigation.navigate} | ||||
areSettingsEnabled={areSettingsEnabled} | areSettingsEnabled={areSettingsEnabled} | ||||
isSearchEmpty={isSearchEmpty} | isSearchEmpty={isSearchEmpty} | ||||
{...props} | {...props} | ||||
/> | /> | ||||
), | ), | ||||
headerRight: areSettingsEnabled | headerRight: 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 | ||||
() => ( | () => ( | ||||
<View style={headerRightStyle}> | |||||
<SearchMessagesButton | |||||
threadInfo={route.params.threadInfo} | |||||
navigate={navigation.navigate} | |||||
/> | |||||
<ThreadSettingsButton | <ThreadSettingsButton | ||||
threadInfo={route.params.threadInfo} | threadInfo={route.params.threadInfo} | ||||
navigate={navigation.navigate} | navigate={navigation.navigate} | ||||
/> | /> | ||||
</View> | |||||
) | ) | ||||
: undefined, | : undefined, | ||||
headerBackTitleVisible: false, | headerBackTitleVisible: false, | ||||
headerTitleAlign: isSearchEmpty ? 'center' : 'left', | headerTitleAlign: isSearchEmpty ? 'center' : 'left', | ||||
headerLeftContainerStyle: { width: Platform.OS === 'ios' ? 32 : 40 }, | headerLeftContainerStyle: { width: Platform.OS === 'ios' ? 32 : 40 }, | ||||
}; | }; | ||||
}; | }; | ||||
const composeThreadOptions = { | const composeThreadOptions = { | ||||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |