Skip to content

Commit

Permalink
refactor: rename headerSearchBar to headerSearchBarOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Nov 27, 2022
1 parent 4f00cd2 commit 7dcf33b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/native-stack/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export type NativeStackNavigationOptions = {
*
* @platform ios
*/
headerSearchBar?: SearchBarProps;
headerSearchBarOptions?: SearchBarProps;
/**
* Sets the status bar animation (similar to the `StatusBar` component).
* Requires setting `View controller-based status bar appearance -> YES` (or removing the config) in your `Info.plist` file.
Expand Down
12 changes: 8 additions & 4 deletions packages/native-stack/src/views/HeaderConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function HeaderConfig({
headerTranslucent,
route,
orientation,
headerSearchBar,
headerSearchBarOptions,
statusBarAnimation,
statusBarHidden,
statusBarStyle,
Expand Down Expand Up @@ -84,7 +84,11 @@ export default function HeaderConfig({
? headerTitle({ tintColor, children: titleText })
: null;

if (Platform.OS === 'ios' && headerSearchBar != null && SearchBar == null) {
if (
Platform.OS === 'ios' &&
headerSearchBarOptions != null &&
SearchBar == null
) {
throw new Error(
`The current version of 'react-native-screens' doesn't support SearchBar in the header. Please update to the latest version to use this option.`
);
Expand Down Expand Up @@ -179,9 +183,9 @@ export default function HeaderConfig({
{headerRightElement}
</ScreenStackHeaderRightView>
) : null}
{Platform.OS === 'ios' && headerSearchBar != null ? (
{Platform.OS === 'ios' && headerSearchBarOptions != null ? (
<ScreenStackHeaderSearchBarView>
<SearchBar {...headerSearchBar} />
<SearchBar {...headerSearchBarOptions} />
</ScreenStackHeaderSearchBarView>
) : null}
</ScreenStackHeaderConfig>
Expand Down

0 comments on commit 7dcf33b

Please sign in to comment.