我正在编写一个使用react-navigation导航的项目,我想使用lightbox,但是lightbox需要Navigator才能正常运行。我希望看看我是否可以在组件中编写反应导航支持,然后允许PR发生。我的想法是使用Navigator +反应导航,这样我就不必重新制作导航,因为你可以同时拥有" this.props.navigator"和#34; this.props.navigation"但我不确定某些导航和导航功能是如何工作的。
我一直在寻找导航器出现的lightbox.js,我正在搜索react-navigation api以查看我是否可以找到所用函数的替换,因为它只发生了8次(其中2次只是检查看是否存在导航器。)
lightbox.js - navigator occurences
open: function() {
this._root.measure((ox, oy, width, height, px, py) => {
this.props.onOpen();
this.setState({
isOpen: (this.props.navigator ? true : false),
isAnimating: true,
origin: {
width,
height,
x: px,
y: py,
},
}, () => {
if(this.props.navigator) {
创建一个可以使用导航的路线(用于反应导航,它将是navigationOptions)
var route = {
component: LightboxOverlay,
passProps: this.getOverlayProps(),
};
获取当前的一组路线
var routes = this.props.navigator.getCurrentRoutes();
将路线推入堆栈
routes.push(route);
导航器执行的堆栈的某种重置(仍然在查看它,知道这样做的任何帮助都会很好。
this.props.navigator.immediatelyResetRouteStack(routes);
然后打开灯箱的其余代码运行
} else {
this.setState({
isOpen: true,
});
}
this.setTimeout(() => {
this.state.layoutOpacity.setValue(0);
});
});
});
},
用于关闭堆栈,调用相同的行,但使用.pop()而不是.push()
任何具有反应导航和反应原生灯箱经验的人都会有很大的帮助。