在我的第一张图中,我有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/firstGraph"
app:startDestination="@id/listFragment">
<fragment
android:id="@+id/listFragment"
android:name="com.example.ListFragment">
<action
android:id="@+id/action_list_to_details"
app:destination="@id/detailsFragment" />
</fragment>
<fragment
android:id="@+id/detailsFragment"
android:name="com.example.DetailsFragment">
</fragment>
</navigation>
Run Code Online (Sandbox Code Playgroud)
在我的第二张图中,我有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/secondGraph"
app:startDestination="@id/dashboardFragment">
<include app:graph="@navigation/firstGraph" />
<fragment
android:id="@+id/dashboardFragment"
android:name="com.example.DashboardFragment">
<action
android:id="@+id/action_dashboard_to_notification"
app:destination="@id/notificationFragment"/>
</fragment>
<fragment
android:id="@+id/notificationFragment"
android:name="com.example.NotificationsFragment">
<action
android:id="@+id/action_notification_to_details"
app:destination="@id/firstGraph"/>
</fragment>
</navigation>
Run Code Online (Sandbox Code Playgroud)
我想直接从“notificationFragment”导航到“detailsFragment”而不是起始目的地,包括第二个图形堆栈
我有以下堆栈导航和屏幕:
export const HomeStack = createStackNavigator({
Home: HomeScreen,
Categories: CategoriesScreen,
Products: ProductsScreen,
ProductDetails: ProductDetailsScreen,
})
Run Code Online (Sandbox Code Playgroud)
我想仅在ProductDetailsScreen中隐藏选项卡
export const hideTabBarComponents = [
'ProductDetails',
]
export const MainTabs = createBottomTabNavigator(
{
Home: HomeStack,
Favorite: FavoriteScreen,
Account: AccountScreen,
Help: HelpScreen,
Events: EventsScreen
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
...
},
tabBarLabel: ({ focused, tintColor }) => {
...
},
tabBarVisible: ! hideTabBarComponents.includes(navigation.state.routeName)
}),
}
);
Run Code Online (Sandbox Code Playgroud)
无法将任何选项传递到"堆栈导航"选项卡导航的问题
并非所有堆叠屏幕都只有其中一个