Changeset View
Changeset View
Standalone View
Standalone View
native/invite-links/invite-links-navigator.react.js
- This file was added.
// @flow | |||||
import { | |||||
createStackNavigator, | |||||
type StackNavigationHelpers, | |||||
type StackNavigationProp, | |||||
} from '@react-navigation/stack'; | |||||
import * as React from 'react'; | |||||
import { SafeAreaView } from 'react-native-safe-area-context'; | |||||
import ViewInviteLinksHeaderLeftButton from './view-invite-links-header-left-button.react.js'; | |||||
import ViewInviteLinksHeaderTitle from './view-invite-links-header-title.react.js'; | |||||
import ViewInviteLinksScreen from './view-invite-links-screen.react.js'; | |||||
import { defaultStackScreenOptions } from '../navigation/options.js'; | |||||
import type { RootNavigationProp } from '../navigation/root-navigator.react.js'; | |||||
import { | |||||
type InviteLinkParamList, | |||||
ViewInviteLinksRouteName, | |||||
type ScreenParamList, | |||||
} from '../navigation/route-names.js'; | |||||
import { useColors, useStyles } from '../themes/colors.js'; | |||||
const safeAreaEdges = ['bottom']; | |||||
export type InviteLinksNavigationProps< | |||||
RouteName: $Keys<InviteLinkParamList> = $Keys<InviteLinkParamList>, | |||||
> = StackNavigationProp<ScreenParamList, RouteName>; | |||||
const InviteLinksStack = createStackNavigator< | |||||
ScreenParamList, | |||||
InviteLinkParamList, | |||||
StackNavigationHelpers<ScreenParamList>, | |||||
>(); | |||||
const viewInviteLinksOptions = ({ route }) => ({ | |||||
// eslint-disable-next-line react/display-name | |||||
headerTitle: props => ( | |||||
<ViewInviteLinksHeaderTitle community={route.params.community} {...props} /> | |||||
), | |||||
headerLeft: ViewInviteLinksHeaderLeftButton, | |||||
headerBackImage: () => null, | |||||
headerBackTitleStyle: { marginLeft: 20 }, | |||||
}); | |||||
type Props = { | |||||
+navigation: RootNavigationProp<'InviteLinkNavigator'>, | |||||
... | |||||
}; | |||||
// eslint-disable-next-line no-unused-vars | |||||
function InviteLinksNavigator(props: Props): React.Node { | |||||
const styles = useStyles(unboundStyles); | |||||
const colors = useColors(); | |||||
const screenOptions = React.useMemo( | |||||
() => ({ | |||||
...defaultStackScreenOptions, | |||||
headerStyle: { | |||||
backgroundColor: colors.modalBackground, | |||||
borderBottomWidth: 1, | |||||
}, | |||||
}), | |||||
[colors.modalBackground], | |||||
); | |||||
return ( | |||||
<SafeAreaView style={styles.container} edges={safeAreaEdges}> | |||||
<InviteLinksStack.Navigator screenOptions={screenOptions}> | |||||
<InviteLinksStack.Screen | |||||
name={ViewInviteLinksRouteName} | |||||
component={ViewInviteLinksScreen} | |||||
options={viewInviteLinksOptions} | |||||
/> | |||||
</InviteLinksStack.Navigator> | |||||
</SafeAreaView> | |||||
); | |||||
} | |||||
const unboundStyles = { | |||||
container: { | |||||
flex: 1, | |||||
backgroundColor: 'modalBackground', | |||||
}, | |||||
}; | |||||
export default InviteLinksNavigator; |