mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-06-02 22:16:34 +02:00
172 lines
6.1 KiB
C#
172 lines
6.1 KiB
C#
|
using Plugin.Connectivity;
|
|||
|
using System;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using TINK.View.MasterDetail;
|
|||
|
using Xamarin.Forms;
|
|||
|
using Xamarin.Forms.Xaml;
|
|||
|
|
|||
|
namespace TINK.View.Map
|
|||
|
{
|
|||
|
using TINK.Model.Services.CopriApi.ServerUris;
|
|||
|
using TINK.ViewModel.Map;
|
|||
|
using Xamarin.Forms.GoogleMaps;
|
|||
|
|
|||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
|||
|
public partial class MapPage : ContentPage, IViewService, IDetailPage
|
|||
|
{
|
|||
|
/// <summary> View model to notify about whether page appears or hides. </summary>
|
|||
|
private MapPageViewModel m_oMapPageViewModel;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Constructs map page instance.
|
|||
|
/// </summary>
|
|||
|
public MapPage()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Displays altert message.
|
|||
|
/// </summary>
|
|||
|
/// <param name="p_strTitle">Title of message.</param>
|
|||
|
/// <param name="p_strMessage">Message to display.</param>
|
|||
|
/// <param name="p_strCancel">Type of buttons.</param>
|
|||
|
public new async Task DisplayAlert(string p_strTitle, string p_strMessage, string p_strCancel)
|
|||
|
{
|
|||
|
await App.Current.MainPage.DisplayAlert(p_strTitle, p_strMessage, p_strCancel);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Displays altert message.</summary>
|
|||
|
/// <param name="title">Title of message.</param>
|
|||
|
/// <param name="message">Message to display.</param>
|
|||
|
/// <param name="details">Detailed error description.</param>
|
|||
|
/// <param name="cancel">Type of buttons.</param>
|
|||
|
public new async Task DisplayAdvancedAlert(
|
|||
|
string title,
|
|||
|
string message,
|
|||
|
string details,
|
|||
|
string cancel)
|
|||
|
=> await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", cancel);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Displays alert message.
|
|||
|
/// </summary>
|
|||
|
/// <param name="p_strTitle">Title of message.</param>
|
|||
|
/// <param name="p_strMessage">Message to display.</param>
|
|||
|
/// <param name="p_strAccept">Text of accept button.</param>
|
|||
|
/// <param name="p_strCancel">Text of button.</param>
|
|||
|
/// <returns>True if user pressed accept.</returns>
|
|||
|
public new async Task<bool> DisplayAlert(string p_strTitle, string p_strMessage, string p_strAccept, string p_strCancel)
|
|||
|
{
|
|||
|
return await App.Current.MainPage.DisplayAlert(p_strTitle, p_strMessage, p_strAccept, p_strCancel);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Creates and a page an shows it.
|
|||
|
/// </summary>
|
|||
|
/// <param name="p_oTypeOfPage">Type of page to show.</param>
|
|||
|
public void ShowPage(ViewTypes p_oType, string p_strTitle = null)
|
|||
|
{
|
|||
|
m_oNavigationMasterDetail.ShowPage(p_oType.GetViewType(), p_strTitle);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Pushes a page onto the modal stack. </summary>
|
|||
|
/// <param name="p_oTypeOfPage">Type of page to display.</param>
|
|||
|
public async Task PushModalAsync(ViewTypes p_oTypeOfPage)
|
|||
|
{
|
|||
|
await Navigation.PushModalAsync((Page)Activator.CreateInstance(p_oTypeOfPage.GetViewType()));
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Pops a page from the modal stack. </summary>
|
|||
|
public async Task PopModalAsync()
|
|||
|
{
|
|||
|
await Navigation.PopModalAsync();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Pushes a page onto the stack. </summary>
|
|||
|
/// <param name="p_oTypeOfPage">Page to display.</param>
|
|||
|
public async Task PushAsync(ViewTypes p_oTypeOfPage)
|
|||
|
{
|
|||
|
var page = Activator.CreateInstance(p_oTypeOfPage.GetViewType()) as IDetailPage;
|
|||
|
if (page == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
page.NavigationMasterDetail = m_oNavigationMasterDetail;
|
|||
|
|
|||
|
await Navigation.PushAsync((Page)page);
|
|||
|
}
|
|||
|
|
|||
|
public Task<IViewService.IUserFeedback> DisplayUserFeedbackPopup() => throw new NotSupportedException();
|
|||
|
|
|||
|
/// <summary> Delegate to perform navigation. </summary>
|
|||
|
private INavigationMasterDetail m_oNavigationMasterDetail;
|
|||
|
|
|||
|
/// <summary> Delegate to perform navigation.</summary>
|
|||
|
public INavigationMasterDetail NavigationMasterDetail
|
|||
|
{
|
|||
|
set
|
|||
|
{
|
|||
|
m_oNavigationMasterDetail = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Invoked when page is shown.
|
|||
|
/// Starts update process.
|
|||
|
/// </summary>
|
|||
|
protected async override void OnAppearing()
|
|||
|
{
|
|||
|
// Pass reference to member Navigation to show bikes at station x dialog.
|
|||
|
#if TRYNOTBACKSTYLE
|
|||
|
m_oMapPageViewModel = new MapPageViewModel();
|
|||
|
#else
|
|||
|
m_oMapPageViewModel = new MapPageViewModel(
|
|||
|
App.ModelRoot,
|
|||
|
(mapspan) => MyMap.MoveToRegion(mapspan),
|
|||
|
this,
|
|||
|
Navigation);
|
|||
|
#endif
|
|||
|
|
|||
|
BindingContext = m_oMapPageViewModel;
|
|||
|
|
|||
|
if (Device.RuntimePlatform == Device.iOS)
|
|||
|
{
|
|||
|
TINKButton.BackgroundColor = Color.LightGray;
|
|||
|
TINKButton.BorderColor = Color.Black;
|
|||
|
TINKButton.Margin = new Thickness(10, 10, 10, 10);
|
|||
|
KonradButton.BackgroundColor = Color.LightGray;
|
|||
|
KonradButton.BorderColor = Color.Black;
|
|||
|
KonradButton.Margin = new Thickness(10, 10, 10, 10);
|
|||
|
}
|
|||
|
|
|||
|
m_oMapPageViewModel.NavigationMasterDetail = m_oNavigationMasterDetail;
|
|||
|
|
|||
|
base.OnAppearing();
|
|||
|
|
|||
|
// Pre move and scanle maps to avoid initial display of map in Rome.
|
|||
|
MapPageViewModel.MoveAndScale(
|
|||
|
(mapSpan) => MyMap.MoveToRegion(mapSpan),
|
|||
|
App.ModelRoot.Uris.ActiveUri,
|
|||
|
App.ModelRoot.GroupFilterMapPage);
|
|||
|
|
|||
|
await m_oMapPageViewModel.OnAppearing();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Invoked when pages is closed/ hidden.
|
|||
|
/// Stops update process.
|
|||
|
/// </summary>
|
|||
|
protected override async void OnDisappearing()
|
|||
|
{
|
|||
|
if (m_oMapPageViewModel != null)
|
|||
|
{
|
|||
|
// View model might be null.
|
|||
|
await m_oMapPageViewModel?.OnDisappearing();
|
|||
|
}
|
|||
|
|
|||
|
base.OnDisappearing();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|