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

@ -2,6 +2,7 @@
using Serilog;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Input;
using TINK.Model.Services.CopriApi.ServerUris;
@ -14,27 +15,33 @@ using Xamarin.Forms;
namespace TINK.ViewModel.Info
{
/// <summary> View model for contact page.</summary>
public class ContactPageViewModel
public class ContactPageViewModel : INotifyPropertyChanged
{
/// <summary> Reference on view service to show modal notifications and to perform navigation. </summary>
private IViewService ViewService { get; }
/// <summary> Station selected by user. </summary>
private IStation SelectedStation;
private IStation SelectedStation { get; set; } = new NullStation();
Uri ActiveUri { get; }
/// <summary> Holds the name of the app (sharee.bike, Mein konrad, ...)</summary>
string AppName { get; }
/// <summary> Holds a reference to the external trigger service. </summary>
private Action OpenUrlInExternalBrowser { get; }
Func<string> CreateAttachment { get; }
/// <summary> Notifies view about changes. </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary> Constructs a contact page view model. </summary>
/// <param name="openUrlInExternalBrowser">Action to open an external browser.</param>
/// <param name="viewService">View service to notify user.</param>
public ContactPageViewModel(
IStation selectedStation,
Uri activeUri,
string appName,
Func<string> createAttachment,
Action openUrlInExternalBrowser,
IViewService viewService)
@ -42,6 +49,10 @@ namespace TINK.ViewModel.Info
ActiveUri = activeUri
?? throw new ArgumentException("Can not instantiate contact page view model- object. No active uri available.");
AppName = !string.IsNullOrEmpty(appName)
? appName
: throw new ArgumentException("Can not instantiate contact page view model- object. No app name availalbe.");
CreateAttachment = createAttachment
?? throw new ArgumentException("Can not instantiate contact page view model- object. No create attachment provider available.");
@ -50,9 +61,27 @@ namespace TINK.ViewModel.Info
OpenUrlInExternalBrowser = openUrlInExternalBrowser
?? throw new ArgumentException("Can not instantiate contact page view model- object. No user external browse service available.");
}
/// <summary> Is invoked when page is shown. </summary>
public async Task OnAppearing(
IStation selectedStation)
{
if (SelectedStation?.Id == selectedStation?.Id)
{
// Nothing to do because either both are null or of same id.
return;
}
// Station might be null-station, if no station info is avialable.
SelectedStation = selectedStation;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MailAddressText)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(OfficeHoursText)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PhoneNumberText)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ProviderNameText)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsOperatorInfoAvaliable)));
await Task.CompletedTask;
}
/// <summary> Command object to bind login button to view model. </summary>
@ -186,7 +215,7 @@ namespace TINK.ViewModel.Info
#if USEFLYOUT
ViewService.PushAsync(ViewTypes.SelectStationPage);
#else
await ViewService.ShowPage("//SelectStationPage");
await ViewService.PushAsync(ViewTypes.SelectStationPage);
#endif
}
catch (Exception p_oException)
@ -249,7 +278,7 @@ namespace TINK.ViewModel.Info
get
{
var l_oHint = new FormattedString();
l_oHint.Spans.Add(new Span { Text = string.Format(AppResources.MessageRateMail, GetAppName(ActiveUri)) });
l_oHint.Spans.Add(new Span { Text = string.Format(AppResources.MessageRateMail, AppName) });
return l_oHint;
}
}

View file

@ -21,7 +21,7 @@ using System.Threading;
using TINK.MultilingualResources;
using TINK.ViewModel.Info;
using TINK.Repository;
using TINK.Model.Services.Geolocation;
using TINK.Services.Geolocation;
namespace TINK.ViewModel.Contact
{
@ -85,7 +85,7 @@ namespace TINK.ViewModel.Contact
/// <summary> False if user tabed on station marker to show bikes at a given station.</summary>
private bool isMapPageEnabled = false;
Model.Services.Geolocation.IGeolocation GeolocationService { get; }
IGeolocation GeolocationService { get; }
/// <summary> False if user tabed on station marker to show bikes at a given station.</summary>
public bool IsMapPageEnabled
@ -628,9 +628,8 @@ namespace TINK.ViewModel.Contact
if (Exception != null)
{
// An error occurred getting data from copri.
return TinkApp.IsReportLevelVerbose
? Exception.GetShortErrorInfoText()
: AppResources.ActivityTextException;
return Exception.GetShortErrorInfoText(TinkApp.IsReportLevelVerbose);
}
if (!IsConnected)