Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 9a90042

Browse files
authored
Merge pull request #226 from vardansargsyan92/feature/flyout-page-support
Feature/flyout page support
2 parents e3dc5be + bcd8339 commit 9a90042

File tree

6 files changed

+74
-3
lines changed

6 files changed

+74
-3
lines changed

samples/src/PopupPluginSample/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
3838
containerRegistry.RegisterForNavigation<NavigationPage>();
3939
containerRegistry.RegisterForNavigation<MainPage, MainPageViewModel>();
4040
containerRegistry.RegisterForNavigation<MDPRoot, MDPRootViewModel>();
41+
containerRegistry.RegisterForNavigation<FLPRoot, FLPRootViewModel>();
4142
containerRegistry.RegisterForNavigation<MenuPage, MenuPageViewModel>();
4243
containerRegistry.RegisterForNavigation<NavigationRoot>();
4344
containerRegistry.RegisterForNavigation<PopupView, PopupViewModel>();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Prism.Navigation;
2+
3+
namespace PopupPluginSample.ViewModels
4+
{
5+
public class FLPRootViewModel : BaseViewModel
6+
{
7+
public FLPRootViewModel(INavigationService navigationService)
8+
: base(navigationService)
9+
{
10+
}
11+
}
12+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<FlyoutPage xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:prism="http://prismlibrary.com"
5+
xmlns:local="clr-namespace:PopupPluginSample.Xaml"
6+
x:Class="PopupPluginSample.Views.FLPRoot">
7+
8+
<FlyoutPage.Flyout>
9+
<ContentPage Title="Menu">
10+
<Grid>
11+
<Grid.RowDefinitions>
12+
<RowDefinition Height="1*" />
13+
<RowDefinition Height="2*" />
14+
</Grid.RowDefinitions>
15+
16+
<BoxView Color="LightCoral"
17+
HorizontalOptions="FillAndExpand"
18+
VerticalOptions="FillAndExpand" />
19+
<Label Text="A Menu"
20+
TextColor="White"
21+
HorizontalOptions="CenterAndExpand"
22+
VerticalOptions="CenterAndExpand"
23+
Grid.Row="0" />
24+
25+
<StackLayout Padding="40"
26+
Grid.Row="1">
27+
<Label Text="You might have menu options here" Grid.Row="1" />
28+
<Button Text="Launch Popup (XAML)"
29+
Command="{local:DebugNavigateTo PopupView}" />
30+
<Button Text="Launch Popup (Classic)"
31+
Command="{Binding NavigateCommand}"
32+
CommandParameter="PopupView" />
33+
<Button Text="Sample Dialog"
34+
Command="{prism:ShowDialog SampleDialog}" />
35+
<Button Text="Back to Menu"
36+
Command="{prism:NavigateTo '/MenuPage'}" />
37+
</StackLayout>
38+
</Grid>
39+
</ContentPage>
40+
</FlyoutPage.Flyout>
41+
42+
</FlyoutPage>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Prism.Navigation;
2+
using Xamarin.Forms;
3+
4+
namespace PopupPluginSample.Views
5+
{
6+
public partial class FLPRoot : FlyoutPage, IFlyoutPageOptions
7+
{
8+
public FLPRoot()
9+
{
10+
InitializeComponent();
11+
}
12+
13+
public bool IsPresentedAfterNavigation => Device.Idiom != TargetIdiom.Phone;
14+
}
15+
}

samples/src/PopupPluginSample/Views/MenuPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
VerticalOptions="Center">
1616
<Label Text="Select the root page to test from" />
1717
<Button Text="Master Detail Page" Command="{prism:NavigateTo '/MDPRoot/NavigationRoot/MainPage'}" />
18+
<Button Text="Flyout Page" Command="{prism:NavigateTo '/FLPRoot/NavigationRoot/MainPage'}" />
1819
<Button Text="Tabbed Page" Command="{prism:NavigateTo '/TabbedRoot'}" />
1920
<Button Text="Navigation Page" Command="{prism:NavigateTo '/NavigationRoot/MainPage'}" />
2021
<Button Text="Sample Dialog" Command="{prism:ShowDialog SampleDialog}" />

src/Prism.Plugin.Popups/Extensions/PageExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public static bool IsOrDerivesFrom<T>(this Page page) where T : Page =>
2525
/// <returns>The displayed page.</returns>
2626
public static Page GetDisplayedPage(this Page page)
2727
{
28-
while (page.IsOrDerivesFrom<MasterDetailPage>() ||
28+
while (page.IsOrDerivesFrom<FlyoutPage>() ||
2929
page.IsOrDerivesFrom<TabbedPage>() ||
3030
page.IsOrDerivesFrom<NavigationPage>())
3131
{
3232
switch (page)
3333
{
34-
case MasterDetailPage mdp:
35-
page = mdp.Detail;
34+
case FlyoutPage flp:
35+
page = flp.Detail;
3636
break;
3737
case TabbedPage tabbed:
3838
page = tabbed.CurrentPage;

0 commit comments

Comments
 (0)