Version 3.0.290

This commit is contained in:
Oliver Hauff 2022-04-10 17:38:34 +02:00
parent af3c20ea1c
commit ad3cdbcadf
231 changed files with 14555 additions and 7798 deletions

View file

@ -1,10 +1,12 @@
using System;
using Serilog;
using System;
using System.Threading.Tasks;
using TINK.Model.Device;
#if USEFLYOUT
using TINK.View.MasterDetail;
#endif
using TINK.ViewModel.Info;
using Xamarin.Essentials;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
@ -18,16 +20,36 @@ namespace TINK.View.Contact
#endif
{
public ContactPage ()
{
InitializeComponent ();
/// <summary> View model to notify view model if page appears. </summary>
private ContactPageViewModel ViewModel { get; set; }
ContactPageView.BindingContext = new ContactPageViewModel(
App.ModelRoot.SelectedStation,
App.ModelRoot.Uris.ActiveUri,
public ContactPage()
{
InitializeComponent();
ViewModel = new ContactPageViewModel(App.ModelRoot.Uris.ActiveUri,
AppInfo.Name,
() => App.CreateAttachment(),
() => DependencyService.Get<IExternalBrowserService>().OpenUrl(DependencyService.Get<IAppInfo>().StoreUrl),
this);
() => DependencyService.Get<IExternalBrowserService>().OpenUrl(DependencyService.Get<IAppInfo>().StoreUrl),
this);
ContactPageView.BindingContext = ViewModel;
}
/// <summary> Invoked when page is shown. </summary>
protected async override void OnAppearing()
{
try
{
Log.ForContext<ContentPage>().Verbose("OnAppearing...");
await ViewModel.OnAppearing(App.ModelRoot.SelectedStation);
}
catch (Exception exception)
{
Log.ForContext<ContentPage>().Error("Invoking OnAppearing on view model failed. {Exception}", exception);
return;
}
}
/// <summary> Displays alert message.</summary>
@ -50,7 +72,7 @@ namespace TINK.View.Contact
/// <param name="cancel">Text of cancel button.</param>
/// <returns>True if user pressed accept.</returns>
public async Task<bool> DisplayAdvancedAlert(string title, string message, string details, string accept, string cancel)
=> await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", accept, cancel);
=> await App.Current.MainPage.DisplayAlert(title, !string.IsNullOrEmpty(details) ? $"{message}\r\nDetails:\r\n{details}" : $"{message}", accept, cancel);
#if USEFLYOUT
public void ShowPage(ViewTypes p_oType, string title = null)
@ -79,17 +101,19 @@ namespace TINK.View.Contact
public async Task PushAsync(ViewTypes typeOfPage)
{
#if USEFLYOUT
if (!(Activator.CreateInstance(typeOfPage.GetViewType()) is IDetailPage detailPage))
var page = Activator.CreateInstance(typeOfPage.GetViewType()) as IDetailPage;
#else
var page = Activator.CreateInstance(typeOfPage.GetViewType());
#endif
if (page == null)
{
await Task.CompletedTask;
return;
}
// Set reference to navigation object to be able to show page on newly shown detailPage.
detailPage.NavigationMasterDetail = NavigationMasterDetail;
await Navigation.PushAsync((Page)detailPage);
#if USEFLYOUT
page.NavigationMasterDetail = NavigationMasterDetail;
#endif
await Navigation.PushAsync((Page)page);
}
#if USCSHARP9

View file

@ -55,7 +55,7 @@ namespace TINK.View.Contact
/// <param name="cancel">Text of cancel button.</param>
/// <returns>True if user pressed accept.</returns>
public async Task<bool> DisplayAdvancedAlert(string title, string message, string details, string accept, string cancel)
=> await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", accept, cancel);
=> await App.Current.MainPage.DisplayAlert(title, !string.IsNullOrEmpty(details) ? $"{message}\r\nDetails:\r\n{details}" : $"{message}", accept, cancel);
/// <summary>
/// Displays alert message.
@ -140,7 +140,7 @@ namespace TINK.View.Contact
App.ModelRoot,
App.PermissionsService,
App.BluetoothService,
App.GeolocationServicesContainer.Active,
App.LocationServicesContainer.Active,
(mapspan) => MyMap.MoveToRegion(mapspan),
this,
Navigation);