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

Added the ability to set an image title in the NavigatorIOS #8182

Closed
wants to merge 1 commit into from

Conversation

alvaromb
Copy link
Contributor

Motivation

This pull request adds support for setting an image title in NavigatorIOS. It sets the titleView property of UINavigationItem.

Example

Added an example into UIExplorer

ex

## Coding style

The code follows the same style as the rest of RCTNavItem and RCTWrapperViewController.

@ghost
Copy link

ghost commented Jun 17, 2016

By analyzing the blame information on this pull request, we identified @ericvicenti and @janicduplessis to be potential reviewers.

@ghost ghost added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Jun 17, 2016
title: 'Custom title image Example',
titleImage: require('./relay.png'),
component: createExamplePage(null, ViewExample),
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi: Missing semicolon.

@alvaromb alvaromb force-pushed the navigator_img branch 2 times, most recently from 64e3656 to 9e3ebbe Compare June 17, 2016 10:29
- (UIImageView *)titleImageView
{
if (!_titleImageView) {
if (_titleImage) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not be properly invalidated when you update the titleImage property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for jumping in @javache!

Yes, you're right, I reproduced the issue using replacePreviousAndPop with a previous route with an image and it doesn't get updated. I'll update the PR.

- (UIImageView *)titleImageView
{
if (_titleImage) {
_titleImageView = [[UIImageView alloc] initWithImage:_titleImage];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're always recreating it, it doesn't seem to be useful to keep it around as an instance variable. Could you remove the @synthesize and just return the UIImageView immediately?

I'm assuming this will be efficient enough since it only gets called on viewWillAppear. If not, you need to figure out a way to reuse the _titleImageView here if the image didn't change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favour of removing the @synthesize, comparing UIImages will be more expensive. Will update the PR later today.

@alvaromb
Copy link
Contributor Author

There you go @javache! AFAIK, removing @synthesize with a readonly property with a getter defined avoids the creation of the ivar.

@javache
Copy link
Member

javache commented Jun 22, 2016

@facebook-github-bot shipit

@ghost ghost added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Jun 22, 2016
@ghost
Copy link

ghost commented Jun 22, 2016

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost
Copy link

ghost commented Jun 22, 2016

I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification.

@ghost ghost added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Jun 22, 2016
Added an example to UIExplorer

Solved lint issue

Added the ability to set an image title in the NavigatorIOS

Added an example to UIExplorer

Solved lint issue

Added the ability to set an image title in the NavigatorIOS

Added an example to UIExplorer

Solved lint issue

Properly regenerated the title image view

Removed @synthesize to avoid ivar creation for the titleImageView and generated the UIImageView on the fly
@ghost ghost closed this in 9bd80cb Jun 23, 2016
rozele pushed a commit to microsoft/react-native-windows that referenced this pull request Jul 6, 2016
Summary:
This pull request adds support for setting an image title in `NavigatorIOS`. It sets the `titleView` property of `UINavigationItem`.

Added an example into `UIExplorer`

<img width="487" alt="ex" src="https://cloud.githubusercontent.com/assets/289640/16147578/3d552606-3484-11e6-9a26-1e8c113ace03.png">

The code follows the same style as the rest of `RCTNavItem` and `RCTWrapperViewController`.
Closes facebook/react-native#8182

Differential Revision: D3469073

Pulled By: javache

fbshipit-source-id: 2d3e4bad534f92b6e6b24a6b74f2993f3a8c9012
bubblesunyum pushed a commit to iodine/react-native that referenced this pull request Aug 23, 2016
Summary:
This pull request adds support for setting an image title in `NavigatorIOS`. It sets the `titleView` property of `UINavigationItem`.

Added an example into `UIExplorer`

<img width="487" alt="ex" src="https://cloud.githubusercontent.com/assets/289640/16147578/3d552606-3484-11e6-9a26-1e8c113ace03.png">

The code follows the same style as the rest of `RCTNavItem` and `RCTWrapperViewController`.
Closes facebook#8182

Differential Revision: D3469073

Pulled By: javache

fbshipit-source-id: 2d3e4bad534f92b6e6b24a6b74f2993f3a8c9012
mpretty-cyro pushed a commit to HomePass/react-native that referenced this pull request Aug 25, 2016
Summary:
This pull request adds support for setting an image title in `NavigatorIOS`. It sets the `titleView` property of `UINavigationItem`.

Added an example into `UIExplorer`

<img width="487" alt="ex" src="https://cloud.githubusercontent.com/assets/289640/16147578/3d552606-3484-11e6-9a26-1e8c113ace03.png">

The code follows the same style as the rest of `RCTNavItem` and `RCTWrapperViewController`.
Closes facebook#8182

Differential Revision: D3469073

Pulled By: javache

fbshipit-source-id: 2d3e4bad534f92b6e6b24a6b74f2993f3a8c9012
react-one pushed a commit to react-one/react-native that referenced this pull request Sep 24, 2021
I made sure 1.0 is backwards compatible with react-navigation, which means using rn-safe-area-context@1+ with older versions of react-navigation will still work.
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants