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