Re: Now allowing the custom nav bar to take up the whole space on iOS (#2620)
* Add support for react-native 0.52.0
* Refactore a bit
1. Rename `DevCommandsHandlerProxy` to `DevHelperProxy` so it reflects the changes in RN. See d19afc73f5 .
2. Add few comments to show which code is used on `RN >= 0.52` and which on `RN <= 0.51`.
* Now allowing the custom nav bar to take up the whole space on iOS
The custom nav bar on iOS was really just a custom view applied to the title of the navigation bar.
There were problems with this approach, because the navigation bar messes up the frame of the title very frequently, especially when the orientation is changing. That behaviour is accepted when the title is a label, but not when we have a custom component.
With this pull request the custom nav bar component can take up the full width of the navigation bar, no matter what orientation we're at.
* Added mix of native btns and custom component on the Custom TopBar screen of the example project
* added the ability to change the backing controller's preferredContentSize through props.
* added some documentation outlining preferredContentSize and modalPresentationStyle properties
* setTabButton -> has now the property 'label' to change the label of the TabButton
* Add to documentation
* [BugFix] use i instead of 0 to check all TabItems
* setStyle -> to change bottomTabBar
* update android
* remove hass...-functions
* update iOS set TabStyle
* iOS change icon color on buttonTabColor has been changed
* iOS update style-update rutine to update each viewcontroller in a NavigationViewController
tabButtonColor improvement
* iOS add forgotten header declaration
* iOS fix c&p error
* [Android] initialize colors for an empty AppStyles-Object
* [Android] fix update style of tabbar on display screen
* [Android] revert eventbus changes
[Android] apply guyca's solution
* [Android] rn 50 compatibility
* remove comment
Revert "Now allowing the custom nav bar to take up the whole space on iOS" (#2404)
* Revert "Improve getCurrentlyVisibleScreenId on iOS with drawers. (#2052)"
This reverts commit 2c30a52bb9.
* Revert "introducing navbar shadow on iOS (#2339)"
This reverts commit 8fd496e0c9.
* Revert "This fixes an issue with a custom title-view (which has a title and a subtitle) appearing at the left side of the nav-bar instead of the center during a transition animation: when a screen with this title-view is being pushed or when you pop back to it. (#2384)"
This reverts commit 3f7f6c2612.
* Revert "Now allowing the custom nav bar to take up the whole space on iOS (#2306)"
This reverts commit 74a02ccfc5.
This fixes an issue with a custom title-view (which has a title and a subtitle) appearing at the left side of the nav-bar instead of the center during a transition animation: when a screen with this title-view is being pushed or when you pop back to it. (#2384)
This happens because the title-view is being created again when RVVViewController appears. There's probably no point in setting the title-view again with the same data when it already has it. The title view setup is done anyway in RCCNavigationController.
This can be easily reproduced by calling "this.props.navigator.setSubTitle({subtitle: 'a subtitle'});" from the constructor of a pushed screen.
setTabButton -> has now the property 'label' to change the label of the TabButton
iOS update style-update rutine to update each viewcontroller in a NavigationViewController
tabButtonColor improvement
Add the preview and pop feature
To use the feature you simply call `navigator.push()` but with additional parameter `previewViewID` which is a React Node.
```js
<TouchableOpacity
onPressIn={() => this.props.navigator.push({
screen: 'screenid',
previewView: this.viewRef,
previewActions: [{
title: 'Foo',
style: 'selected', // none, selected, destructive
actions: [{ title: 'Bar' }],
}],
})
/>
```
* added method for getting the currently visible screen ID. Can be useful to decide if logic should be applied according to screen visibility, for example: set buttons/title dynamically, or even determine that you don’t need to show the same screen again if it’s the current one that’s showing
* Implement getCurrentlyVisibleScreenId on Android
Can be used statically:
Navigation.getCurrentlyVisibleScreenId() - returns the unique screen
instance id
With a navigator instance:
await this.props.navigator.screenIsCurrentlyVisible() - resolves a
promise that checks if the current screen is visible
* Add screen visibility listener which can be registered globally
API
new ScreenVisibilityListener({
willAppear: ({screen, timestamp}) => console.log(`Displaying screen ${screen}`),
didAppear: ({screen, timestamp}) => console.log(`Screen ${screen} displayed in ${Date.now() - timestamp} millis`)
}).register();
todo
* Add timestamp to modal, resetTo
* implement unregister
* implement iOS
* Add global screen visibility listener to example app
* Think I better assign a value to emitter
* Send timestamp in resetTo
* Moved listener to library, it can be deleted from the app
* Add push and resetTo buttons to pushed screens
* Send appear/disappear events after animation ends
* Pass pop timestamp from js
* Send timestamp in popToRoot
* Add popToRoot button in push screen
* Add few navigation buttons to modal screen
* Pass timestamp to tabs
relevant only to first/initial tab
* Update timestamp when navigating between BottomTabs
* Send screen visible events after modal dismiss
* log willDisappear and didDisappear
* Report both start and end timestamps
* Implement unregister
* Send NavigationType parameter in visibilityEvent
This indicates the type of the navigation command that triggered the visibility change
* Rename pushInitialScreen to more explicit name
* Fix duplicate initialScreen visibility events
* Update screen visibility log statement
* Show popToRoot in modal screen only if screens were pushed
* implement global screen event for iOS
* fix lint issues
Add ability to set attributes of navigation bar buttons separately. (#937)
* Add ability to set attributes of navigation bar buttons separately.
* Added ability to set button style when calling `setButtons` method.
* Add documentation.
* Adds iOS callback for viewWillAppear/didAppear e.t.c.
* Adds in screen events on Android
* Fixed issue with rightButtons getting ignored in preference for empty Screen buttons
* Android screen lifecycle
This commit is contains a few changes and enhancements to the PR made by simon:
* Use getEventEmitter instead of sendNavigatorEvent
* Dispatch willDisappear and didDisappear events when pushing screens
* Dispatch willAppear and didAppear events when popping screen