mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using System.ComponentModel;
|
|
using Xamarin.Forms;
|
|
using TINK.Services.CopriApi.ServerUris;
|
|
using System;
|
|
|
|
namespace TINK.ViewModel.Contact
|
|
{
|
|
public class HelpContactViewModel : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
/// <summary> Gets the platfrom specific prefix. </summary>
|
|
private Func<string, string> ResourceProvider { get; set; }
|
|
|
|
/// <summary> Holds value wether site caching is on or off.</summary>
|
|
bool IsSiteCachingOn { get; }
|
|
|
|
/// <summary> Constructs view model.</summary>
|
|
/// <param name="isSiteCachingOn">Set of user permissions</param>
|
|
/// <param name="resourceProvider">Delegate to get an an embedded html ressource. Used as fallback if download from web page does not work and cache is empty.</param>
|
|
public HelpContactViewModel(
|
|
string hostName,
|
|
bool isSiteCachingOn,
|
|
Func<string, string> resourceProvider)
|
|
{
|
|
HostName = hostName;
|
|
IsSiteCachingOn = isSiteCachingOn;
|
|
|
|
ResourceProvider = resourceProvider
|
|
?? throw new ArgumentException($"Can not instantiate {typeof(HelpContactViewModel)}-object. No ressource provider availalbe.");
|
|
|
|
}
|
|
|
|
/// <summary> Holds the name of the host.</summary>
|
|
private string HostName { get; }
|
|
|
|
/// <summary> Called when page is shown. </summary>
|
|
public async void OnAppearing()
|
|
{
|
|
RentBikeText = new HtmlWebViewSource
|
|
{
|
|
Html = HostName.GetIsCopri()
|
|
? ResourceProvider("HtmlResouces.V02.InfoRentBike.html")
|
|
: await ViewModelHelper.GetSource($"https://{HostName}/{CopriHelper.SHAREE_SILTEFOLDERNAME}/tariff_info_1.html", IsSiteCachingOn)
|
|
};
|
|
|
|
TypesOfBikesText = new HtmlWebViewSource
|
|
{
|
|
Html = HostName.GetIsCopri()
|
|
? ResourceProvider("HtmlResouces.V02.InfoTypesOfBikes.html")
|
|
: await ViewModelHelper.GetSource($"https://{HostName}/{CopriHelper.SHAREE_SILTEFOLDERNAME}/bike_info.html", IsSiteCachingOn)
|
|
};
|
|
}
|
|
|
|
private HtmlWebViewSource rentBikeText;
|
|
|
|
private HtmlWebViewSource typesOfBikesText;
|
|
|
|
public HtmlWebViewSource RentBikeText
|
|
{
|
|
get => rentBikeText;
|
|
set
|
|
{
|
|
rentBikeText = value;
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(RentBikeText)));
|
|
}
|
|
}
|
|
|
|
public HtmlWebViewSource TypesOfBikesText
|
|
{
|
|
get => typesOfBikesText;
|
|
set
|
|
{
|
|
typesOfBikesText = value;
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TypesOfBikesText)));
|
|
}
|
|
}
|
|
}
|
|
}
|