mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-22 21:06:30 +02:00
Version 3.0.255
This commit is contained in:
parent
db9c288584
commit
5a26bf273b
1495 changed files with 159465 additions and 5060 deletions
95
LastenradBayern/TINK/View/RootFlyout/RootPage.xaml.cs
Normal file
95
LastenradBayern/TINK/View/RootFlyout/RootPage.xaml.cs
Normal file
|
@ -0,0 +1,95 @@
|
|||
using System;
|
||||
using TINK.Model.Station;
|
||||
#if USEFLYOUT
|
||||
using TINK.View.MasterDetail;
|
||||
#endif
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace TINK.View.Root
|
||||
{
|
||||
/// <summary>
|
||||
/// Mamages creation of detail pages if a flyout page menu entry is selected.
|
||||
/// Exposes flyout page style navigation which is used by detail pages.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Examples of use cases when detail pages do navigation:
|
||||
// - switch to map page after succesfully logging in/ logging out
|
||||
// - switch to login page form bikes at station page if not yet logged in
|
||||
/// </remarks>
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
#if USEFLYOUT
|
||||
public partial class RootPage : FlyoutPage, INavigationMasterDetail
|
||||
#else
|
||||
public partial class RootPage : FlyoutPage
|
||||
#endif
|
||||
{
|
||||
public RootPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
FlyoutPage.ListView.ItemSelected += OnListViewItemSelected;
|
||||
|
||||
// Any type of split behaviour conflics with map shifting functionality (assuming FlyoutPage behaves same like MasterDetailPage).
|
||||
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;
|
||||
|
||||
var navigationPage = Detail as NavigationPage;
|
||||
if (navigationPage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if USEFLYOUT
|
||||
var detailPage = navigationPage.RootPage as IDetailPage;
|
||||
if (detailPage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
detailPage.NavigationMasterDetail = this;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is called if a flyout page menu entry is selected.
|
||||
/// Creates a new page.
|
||||
/// </summary>
|
||||
private void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
if (!(e.SelectedItem is RootPageFlyoutMenuItem item))
|
||||
{
|
||||
// Unexpected argument detected.
|
||||
return;
|
||||
}
|
||||
|
||||
// Set selected station to new
|
||||
App.ModelRoot.SelectedStation = new NullStation();
|
||||
|
||||
ShowPage(item.TargetType, item.Title);
|
||||
|
||||
IsPresented = false;
|
||||
FlyoutPage.ListView.SelectedItem = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a detail page.
|
||||
/// </summary>
|
||||
/// <param name="typeOfPage">Type of page to show.</param>
|
||||
/// <param name="title">Title of page.</param>
|
||||
public void ShowPage(Type typeOfPage, string title)
|
||||
{
|
||||
var page = (Page)Activator.CreateInstance(typeOfPage);
|
||||
page.Title = title;
|
||||
|
||||
#if USEFLYOUT
|
||||
if (page is IDetailPage detailPage)
|
||||
{
|
||||
// Detail page needs reference to perform navigation.
|
||||
// Examples see above in xdoc of class.
|
||||
detailPage.NavigationMasterDetail = this;
|
||||
}
|
||||
#endif
|
||||
|
||||
Detail = new NavigationPage(page);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue