Contact page shows operator specific info

This commit is contained in:
Oliver Hauff 2021-07-20 23:06:09 +02:00
parent e436e83c1d
commit a58c33f005
51 changed files with 948 additions and 221 deletions

View file

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Input;
using TINK.Model.Services.CopriApi.ServerUris;
using TINK.Model.Station;
using TINK.MultilingualResources;
using TINK.View;
using Xamarin.Essentials;
@ -18,6 +19,9 @@ namespace TINK.ViewModel.Info
/// <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;
Uri ActiveUri { get; }
/// <summary> Holds a reference to the external trigger service. </summary>
@ -29,6 +33,7 @@ namespace TINK.ViewModel.Info
/// <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,
Func<string> createAttachment,
Action openUrlInExternalBrowser,
@ -45,6 +50,9 @@ namespace TINK.ViewModel.Info
OpenUrlInExternalBrowser = openUrlInExternalBrowser
?? throw new ArgumentException("Can not instantiate contact page view model- object. No user external browse service available.");
// Station might be null-station, if no station info is avialable.
SelectedStation = selectedStation;
}
/// <summary> Command object to bind login button to view model. </summary>
@ -65,45 +73,19 @@ namespace TINK.ViewModel.Info
/// <summary>Holds the mail address to mail to.</summary>
public string MailAddressText
{
get
{
switch (ActiveUri.AbsoluteUri)
{
case CopriServerUriList.TINK_DEVEL:
case CopriServerUriList.TINK_LIVE:
return "tink@fahrradspezialitaeten.com";
case CopriServerUriList.SHAREE_DEVEL:
case CopriServerUriList.SHAREE_LIVE:
return "hotline@sharee.bike";
default:
return "post@sharee.bike";
}
}
}
=> SelectedStation?.OperatorData?.MailAddressText ?? string.Empty;
/// <summary>Holds the mail address to send mail to.</summary>
public string PhoneNumberText
{
get
{
switch (ActiveUri.AbsoluteUri)
{
case CopriServerUriList.TINK_DEVEL:
case CopriServerUriList.TINK_LIVE:
return "+49 7531 - 3694389";
=> SelectedStation?.OperatorData?.PhoneNumberText ?? string.Empty;
case CopriServerUriList.SHAREE_DEVEL:
case CopriServerUriList.SHAREE_LIVE:
return "+49 761 - 45370097";
/// <summary>Holds the mail address to send mail to.</summary>
public string OfficeHoursText
=> SelectedStation?.OperatorData?.Hours ?? string.Empty;
default:
return "+49 761 5158912";
}
}
}
/// <summary> Gets whether any operator support info is avaliable. </summary>
public bool IsOperatorInfoAvaliable
=> MailAddressText.Length > 0 || PhoneNumberText.Length > 0;
/// <summary> Request to do a phone call. </summary>
public async Task DoSendMail()
@ -256,7 +238,10 @@ namespace TINK.ViewModel.Info
get
{
var l_oHint = new FormattedString();
l_oHint.Spans.Add(new Span { Text = string.Format(AppResources.MessagePhoneMail, GetAppName(ActiveUri)) });
l_oHint.Spans.Add(new Span
{
Text = string.Format(AppResources.MessagePhoneMail, GetAppName(ActiveUri)) + $"{(OfficeHoursText.Length > 0 ? $" {OfficeHoursText}" : string.Empty)}"
});
return l_oHint;
}
}