Skip to content

Commit

Permalink
Only expose ApplyPageBehaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jan 18, 2020
1 parent 09f946c commit 73b4fd1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 42 deletions.
33 changes: 0 additions & 33 deletions Source/Xamarin/Prism.Forms/Behaviors/IPageBehaviorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,5 @@ public interface IPageBehaviorFactory
/// <param name="page">The page to apply the behaviors</param>
/// <remarks>The PageLifeCycleAwareBehavior is applied to all pages</remarks>
void ApplyPageBehaviors(Page page);

/// <summary>
/// Applies behaviors to a CarouselPage.
/// </summary>
/// <param name="page">The CarouselPage to apply the behaviors</param>
/// <remarks>The CarouselPageActiveAwareBehavior is applied by default</remarks>
void ApplyCarouselPageBehaviors(CarouselPage page);

/// <summary>
/// Applies behaviors to a ContentPage.
/// </summary>
/// <param name="page">The ContentPage to apply the behaviors</param>
void ApplyContentPageBehaviors(ContentPage page);

/// <summary>
/// Applies behaviors to a MasterDetailPage.
/// </summary>
/// <param name="page">The MasterDetailPage to apply the behaviors</param>
void ApplyMasterDetailPageBehaviors(MasterDetailPage page);

/// <summary>
/// Applies behaviors to a NavigationPage.
/// </summary>
/// <param name="page">The NavigationPage to apply the behaviors</param>
/// <remarks>The NavigationPageSystemGoBackBehavior and NavigationPageActiveAwareBehavior are applied by default</remarks>
void ApplyNavigationPageBehaviors(NavigationPage page);

/// <summary>
/// Applies behaviors to a TabbedPage.
/// </summary>
/// <param name="page">The TabbedPage to apply the behaviors</param>
/// <remarks>The TabbedPageActiveAwareBehavior is added by default</remarks>
void ApplyTabbedPageBehaviors(TabbedPage page);
}
}
26 changes: 17 additions & 9 deletions Source/Xamarin/Prism.Forms/Behaviors/PageBehaviorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PageBehaviorFactory : IPageBehaviorFactory
/// </summary>
/// <param name="page">The CarouselPage to apply the behaviors</param>
/// <remarks>The CarouselPageActiveAwareBehavior is applied by default</remarks>
public virtual void ApplyCarouselPageBehaviors(CarouselPage page)
protected virtual void ApplyCarouselPageBehaviors(CarouselPage page)
{
page.Behaviors.Add(new CarouselPageActiveAwareBehavior());
}
Expand All @@ -21,26 +21,26 @@ public virtual void ApplyCarouselPageBehaviors(CarouselPage page)
/// Applies behaviors to a ContentPage.
/// </summary>
/// <param name="page">The ContentPage to apply the behaviors</param>
public virtual void ApplyContentPageBehaviors(ContentPage page)
protected virtual void ApplyContentPageBehaviors(ContentPage page)
{

}

/// <summary>
/// Applies behaviors to a MasterDetailPage.
/// </summary>
/// <param name="page">The MasterDetailPage to apply the behaviors</param>
public virtual void ApplyMasterDetailPageBehaviors(MasterDetailPage page)
protected virtual void ApplyMasterDetailPageBehaviors(MasterDetailPage page)
{

}

/// <summary>
/// Applies behaviors to a NavigationPage.
/// </summary>
/// <param name="page">The NavigationPage to apply the behaviors</param>
/// <remarks>The NavigationPageSystemGoBackBehavior and NavigationPageActiveAwareBehavior are applied by default</remarks>
public virtual void ApplyNavigationPageBehaviors(NavigationPage page)
protected virtual void ApplyNavigationPageBehaviors(NavigationPage page)
{
page.Behaviors.Add(new NavigationPageSystemGoBackBehavior());
page.Behaviors.Add(new NavigationPageActiveAwareBehavior());
Expand All @@ -50,8 +50,15 @@ public virtual void ApplyNavigationPageBehaviors(NavigationPage page)
/// Applies behaviors to a page based on the page type.
/// </summary>
/// <param name="page">The page to apply the behaviors</param>
/// <remarks>The PageLifeCycleAwareBehavior is applied to all pages</remarks>
public virtual void ApplyPageBehaviors(Page page)
/// <remarks>
/// There is no need to call base.ApplyPageBehaviors when overriding.
/// All Prism behaviors have already been applied.
/// </remarks>
protected virtual void ApplyPageBehaviors(Page page)
{
}

void IPageBehaviorFactory.ApplyPageBehaviors(Page page)
{
switch (page)
{
Expand All @@ -73,14 +80,15 @@ public virtual void ApplyPageBehaviors(Page page)
}

page.Behaviors.Add(new PageLifeCycleAwareBehavior());
ApplyPageBehaviors(page);
}

/// <summary>
/// Applies behaviors to a TabbedPage.
/// </summary>
/// <param name="page">The TabbedPage to apply the behaviors</param>
/// <remarks>The TabbedPageActiveAwareBehavior is added by default</remarks>
public virtual void ApplyTabbedPageBehaviors(TabbedPage page)
protected virtual void ApplyTabbedPageBehaviors(TabbedPage page)
{
page.Behaviors.Add(new TabbedPageActiveAwareBehavior());
}
Expand Down

0 comments on commit 73b4fd1

Please sign in to comment.