grahammendick / navigation

Scene-Based Navigation for React and React Native
https://grahammendick.github.io/navigation/
Apache License 2.0
587 stars 40 forks source link

The NavigationBar's tintColor prop doesn’t update the search bar in iOS 12 #478

Closed grahammendick closed 3 years ago

grahammendick commented 3 years ago

Setting the tintColor prop of the NavigationBar in the zoom example doesn’t change the color of the Cancel button in the search bar in iOS 12. It does work in iOS 14

Screenshot 2020-11-28 at 10 17 03

Solution

In native iOS, need to set the tintColor property of the UISearchBar from the 'tintColor' prop of the NavigationBar. Should be safe to set this for all iOS (no need to target iOS 12, for example).

There are two different approaches

  1. In the NavigationBar React component, loop through its children and find the SearchBar. Clone the SearchBar and add the tintColor to its props
  2. In the NVNavigationBar iOS class, when the tintColor changes, find the search bar from the navigation item and update its tintColor.

~Whichever approach is chosen, make sure that the SearchBar is always rendered as a child of the NavigationBar on iOS. The only time it isn’t is when using a CoordinatorLayout. The CoordinatorLayout pulls the SearchBar out of the NavigationBar. This functionality is needed for Android but not for iOS. So add a Platform check that to the CoordinatorLayout so it only does that processing for Android.~

~### Performance Improvement~

~We can improve the performance of NVSceneController. It tries to find the NVSearchBar when the scene loads. This is expensive because most often there won’t be a search bar and it will go through all views in the hierarchy looking for it. Instead, it should only look for it within the navigation bar. That means it only has to search a small subset of views. Because of the previous fix, the search bar is guaranteed to be a child of the navigation bar (if it exists)~

grahammendick commented 3 years ago

@a-eid I'm closing this because it's confusing having open issues with no activity. If you have any questions with the implementation please still ask them here

grahammendick commented 3 years ago

I did the performance improvement in #490 so I've cross it out in the description