Skip to content

Commit

Permalink
Merge pull request PrismLibrary#2172 from PrismLibrary/platformnaviga…
Browse files Browse the repository at this point in the history
…tion

Remove IPlatformNavigationService
  • Loading branch information
dansiegel authored Aug 22, 2020
2 parents 522799b + 818495b commit 23527f7
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 195 deletions.
41 changes: 41 additions & 0 deletions src/Forms/Prism.Forms/Navigation/INavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ public interface INavigationService
/// <returns>If <c>true</c> a go back operation was successful. If <c>false</c> the go back operation failed.</returns>
Task<INavigationResult> GoBackAsync(INavigationParameters parameters);

/// <summary>
/// Navigates to the most recent entry in the back navigation history by popping the calling Page off the navigation stack.
/// </summary>
/// <param name="parameters">The navigation parameters</param>
/// <param name="useModalNavigation">If <c>true</c> uses PopModalAsync, if <c>false</c> uses PopAsync</param>
/// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
Task<INavigationResult> GoBackAsync(INavigationParameters parameters, bool? useModalNavigation, bool animated);

/// <summary>
/// When navigating inside a NavigationPage: Pops all but the root Page off the navigation stack
/// </summary>
/// <param name="parameters">The navigation parameters</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
/// <remarks>Only works when called from a View within a NavigationPage</remarks>
Task<INavigationResult> GoBackToRootAsync(INavigationParameters parameters);

/// <summary>
/// Initiates navigation to the target specified by the <paramref name="uri"/>.
/// </summary>
Expand Down Expand Up @@ -54,5 +71,29 @@ public interface INavigationService
/// <param name="name">The name of the target to navigate to.</param>
/// <param name="parameters">The navigation parameters</param>
Task<INavigationResult> NavigateAsync(string name, INavigationParameters parameters);

/// <summary>
/// Initiates navigation to the target specified by the <paramref name="name"/>.
/// </summary>
/// <param name="name">The name of the target to navigate to.</param>
/// <param name="parameters">The navigation parameters</param>
/// <param name="useModalNavigation">If <c>true</c> uses PushModalAsync, if <c>false</c> uses PushAsync</param>
/// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
Task<INavigationResult> NavigateAsync(string name, INavigationParameters parameters, bool? useModalNavigation, bool animated);

/// <summary>
/// Initiates navigation to the target specified by the <paramref name="uri"/>.
/// </summary>
/// <param name="uri">The Uri to navigate to</param>
/// <param name="parameters">The navigation parameters</param>
/// <param name="useModalNavigation">If <c>true</c> uses PopModalAsync, if <c>false</c> uses PopAsync</param>
/// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
/// <remarks>Navigation parameters can be provided in the Uri and by using the <paramref name="parameters"/>.</remarks>
/// <example>
/// NavigateAsync(new Uri("MainPage?id=3&amp;name=brian", UriKind.RelativeSource), parameters);
/// </example>
Task<INavigationResult> NavigateAsync(Uri uri, INavigationParameters parameters, bool? useModalNavigation, bool animated);
}
}
53 changes: 5 additions & 48 deletions src/Forms/Prism.Forms/Navigation/INavigationServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Prism.Navigation
{
/// <summary>
/// Common extensions for the <see cref="INavigationService"/>
/// </summary>
public static class INavigationServiceExtensions
{
/// <summary>
Expand All @@ -24,61 +27,15 @@ public static void OnNavigationError(this Task<INavigationResult> navigationTask
});
}

/// <summary>
/// Navigates to the most recent entry in the back navigation history by popping the calling Page off the navigation stack.
/// </summary>
/// <param name="navigationService">Service for handling navigation between views</param>
/// <param name="parameters">The navigation parameters</param>
/// <param name="useModalNavigation">If <c>true</c> uses PopModalAsync, if <c>false</c> uses PopAsync</param>
/// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
public static Task<INavigationResult> GoBackAsync(this INavigationService navigationService, INavigationParameters parameters = null, bool? useModalNavigation = null, bool animated = true)
{
return ((IPlatformNavigationService)navigationService).GoBackAsync(parameters, useModalNavigation, animated);
}

/// <summary>
/// When navigating inside a NavigationPage: Pops all but the root Page off the navigation stack
/// </summary>
/// <param name="navigationService">The INavigatinService instance</param>
/// <param name="parameters">The navigation parameters</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
/// <remarks>Only works when called from a View within a NavigationPage</remarks>
public static Task<INavigationResult> GoBackToRootAsync(this INavigationService navigationService, INavigationParameters parameters = null)
{
return ((IPlatformNavigationService)navigationService).GoBackToRootAsync(parameters);
}

/// <summary>
/// Initiates navigation to the target specified by the <paramref name="name"/>.
/// </summary>
/// <param name="navigationService">Service for handling navigation between views</param>
/// <param name="name">The name of the target to navigate to.</param>
/// <param name="parameters">The navigation parameters</param>
/// <param name="useModalNavigation">If <c>true</c> uses PushModalAsync, if <c>false</c> uses PushAsync</param>
/// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
public static Task<INavigationResult> NavigateAsync(this INavigationService navigationService, string name, INavigationParameters parameters = null, bool? useModalNavigation = null, bool animated = true)
{
return ((IPlatformNavigationService)navigationService).NavigateAsync(name, parameters, useModalNavigation, animated);
}

/// <summary>
/// Initiates navigation to the target specified by the <paramref name="uri"/>.
/// </summary>
/// <param name="navigationService">Service for handling navigation between views</param>
/// <param name="uri">The Uri to navigate to</param>
/// <param name="parameters">The navigation parameters</param>
/// <param name="useModalNavigation">If <c>true</c> uses PopModalAsync, if <c>false</c> uses PopAsync</param>
/// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param>
/// <returns><see cref="INavigationResult"/> indicating whether the request was successful or if there was an encountered <see cref="Exception"/>.</returns>
/// <remarks>Navigation parameters can be provided in the Uri and by using the <paramref name="parameters"/>.</remarks>
/// <example>
/// NavigateAsync(new Uri("MainPage?id=3&amp;name=brian", UriKind.RelativeSource), parameters);
/// </example>
public static Task<INavigationResult> NavigateAsync(this INavigationService navigationService, Uri uri, INavigationParameters parameters = null, bool? useModalNavigation = null, bool animated = true)
public static Task<INavigationResult> GoBackToRootAsync(this INavigationService navigationService)
{
return ((IPlatformNavigationService)navigationService).NavigateAsync(uri, parameters, useModalNavigation, animated);
return navigationService.GoBackToRootAsync(new NavigationParameters());
}

/// <summary>
Expand Down
16 changes: 0 additions & 16 deletions src/Forms/Prism.Forms/Navigation/IPlatformNavigationService.cs

This file was deleted.

Loading

0 comments on commit 23527f7

Please sign in to comment.