Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for back button image in native stack #515

Merged
merged 1 commit into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion native-stack/types.tsx
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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