如何在其他屏幕上方制作屏幕或组件

时间:2019-07-01 12:48:27

标签: react-native react-navigation

我正在制作一个音乐应用程序,我想要做的是实现一个音乐播放器屏幕,该屏幕可以在所有其他屏幕上处于活动状态,如下所示: https://reactnativeexample.com/react-native-swipe-up-down-component/

这是我的app.js:

import React, {Component} from 'react';
import { createDrawerNavigator, createStackNavigator, createAppContainer } from "react-navigation";

import HomeScreen from './screens/home';
import SideBar from './screens/sidebar';
import SongScreen from './screens/song';

const Drawer = createDrawerNavigator(
  {
    Home: {screen: HomeScreen}
  },
  {
    initialRouteName: "Home",
    contentOptions: {
      activeTintColor: "#e91e63"
    },
    contentComponent: props => <SideBar {...props} />
  }
);

const AppNavigator = createStackNavigator(
  {
    Drawer: { screen: Drawer },
    SongScreen: { screen: SongScreen }
  },
  {
    initialRouteName: "Drawer",
    headerMode: "none"
  }
);

const AppContainer = createAppContainer(AppNavigator);

export default class App extends Component {

  render() {
    return (
      <AppContainer />
    );
  }

}

1 个答案:

答案 0 :(得分:2)

使用https://github.com/octopitus/rn-sliding-up-panel,并使您的主屏幕看起来像这样:

<View>
 <AppContainer/>
 <SlidingUpPanel/>
</View