Skip to content

Commit

Permalink
add support for back button image in native stack (#515)
Browse files Browse the repository at this point in the history
backButtonImage prop is supported on the v4 native stack but is not exposed with v5 native stack. This PR brings that in the native-stack as well.
  • Loading branch information
chirag04 committed May 22, 2020
1 parent eabe8ab commit bbaaa73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion native-stack/types.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
import { StyleProp, ViewStyle } from 'react-native';
import { StyleProp, ViewStyle, ImageSourcePropType } from 'react-native';
import { ScreenProps } from 'react-native-screens';
import {
DefaultNavigatorOptions,
Expand Down Expand Up @@ -75,6 +75,11 @@ export type NativeStackNavigationOptions = {
* String to display in the header as title. Defaults to scene `title`.
*/
headerTitle?: string;
/**
* Image to display in the header as the back button.
* Defaults to back icon image for the platform (a chevron on iOS and an arrow on Android).
*/
backButtonImage?: ImageSourcePropType;
/**
* Title to display in the back button.
* Only supported on iOS.
Expand Down
5 changes: 5 additions & 0 deletions native-stack/views/HeaderConfig.tsx
@@ -1,5 +1,6 @@
import * as React from 'react';
import {
ScreenStackHeaderBackButtonImage,
ScreenStackHeaderConfig,
ScreenStackHeaderRightView,
ScreenStackHeaderLeftView,
Expand All @@ -23,6 +24,7 @@ export default function HeaderConfig(props: Props) {
headerTitle,
headerBackTitle,
headerBackTitleVisible = true,
backButtonImage,
headerHideBackButton,
headerHideShadow,
headerLargeTitleHideShadow,
Expand Down Expand Up @@ -79,6 +81,9 @@ export default function HeaderConfig(props: Props) {
{headerRight !== undefined ? (
<ScreenStackHeaderRightView>{headerRight()}</ScreenStackHeaderRightView>
) : null}
{backButtonImage !== undefined ? (
<ScreenStackHeaderBackButtonImage key="backImage" source={backButtonImage} />
) : null}
{headerLeft !== undefined ? (
<ScreenStackHeaderLeftView>{headerLeft()}</ScreenStackHeaderLeftView>
) : null}
Expand Down

0 comments on commit bbaaa73

Please sign in to comment.