mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 12:36:28 +02:00
3.0.275
This commit is contained in:
parent
f38b516d25
commit
578fcee611
70 changed files with 6828 additions and 9625 deletions
|
@ -9,7 +9,7 @@ using Xamarin.Forms;
|
|||
namespace TINK.ViewModel.Info
|
||||
{
|
||||
/// <summary> Manges the tabbed info page. </summary>
|
||||
public class InfoViewModel : INotifyPropertyChanged
|
||||
public class InfoPageViewModel : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> Fired whenever a property changed.</summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
@ -20,42 +20,56 @@ namespace TINK.ViewModel.Info
|
|||
/// <summary> Holds value wether site caching is on or off.</summary>
|
||||
bool IsSiteCachingOn { get; }
|
||||
|
||||
private string AgbResourcePath { get; }
|
||||
|
||||
private string PrivacyResourcePath { get; }
|
||||
|
||||
private string ImpressResourcePath { get; }
|
||||
|
||||
/// <summary> Constructs Info view model</summary>
|
||||
/// <param name="isSiteCachingOn">Holds value wether site caching is on or off.</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 InfoViewModel(
|
||||
public InfoPageViewModel(
|
||||
string hostName,
|
||||
bool isSiteCachingOn,
|
||||
string agbResourcePath,
|
||||
string privacyResourcePath,
|
||||
string impressResourcePath,
|
||||
bool isSiteCachingOn,
|
||||
Func<string, string> resourceProvider)
|
||||
{
|
||||
HostName = hostName;
|
||||
|
||||
AgbResourcePath = agbResourcePath;
|
||||
PrivacyResourcePath = privacyResourcePath;
|
||||
ImpressResourcePath = impressResourcePath;
|
||||
IsSiteCachingOn = isSiteCachingOn;
|
||||
|
||||
InfoAgb = new HtmlWebViewSource { Html = "<html>Loading...</html>" };
|
||||
|
||||
ResourceProvider = resourceProvider
|
||||
?? throw new ArgumentException($"Can not instantiate {typeof(InfoViewModel)}-object. No ressource provider availalbe.");
|
||||
?? throw new ArgumentException($"Can not instantiate {typeof(InfoPageViewModel)}-object. No ressource provider availalbe.");
|
||||
}
|
||||
|
||||
/// <summary> Called when page is shown. </summary>
|
||||
public async void OnAppearing()
|
||||
{
|
||||
InfoAgb = await GetAgb(HostName, IsSiteCachingOn, ResourceProvider);
|
||||
|
||||
InfoAgb = await GetAgb(HostName, AgbResourcePath, IsSiteCachingOn);
|
||||
|
||||
InfoPrivacy = new HtmlWebViewSource
|
||||
{
|
||||
Html = await ViewModelHelper.GetSource(
|
||||
$"https://{HostName}/{HostName.GetPrivacyResource()}",
|
||||
IsSiteCachingOn,
|
||||
HostName.GetIsCopri() ? () => ResourceProvider("HtmlResouces.V02.InfoDatenschutz.html") : (Func<string>) null) /* offline resources only available for TINK */,
|
||||
Html = !string.IsNullOrEmpty(PrivacyResourcePath)
|
||||
? await ViewModelHelper.GetSource(
|
||||
$"https://{HostName}/{PrivacyResourcePath}", // "site/privacy.html"
|
||||
IsSiteCachingOn)
|
||||
: await Task.FromResult(ViewModelHelper.FromBody("No privacy resource available. Resource path is null or empty."))
|
||||
};
|
||||
|
||||
InfoImpressum = new HtmlWebViewSource
|
||||
{
|
||||
Html = HostName.GetIsCopri()
|
||||
? ResourceProvider("HtmlResouces.V02.InfoImpressum.html")
|
||||
: await ViewModelHelper.GetSource($"https://{HostName}/{CopriHelper.SHAREE_SILTEFOLDERNAME}/impress.html", IsSiteCachingOn)
|
||||
Html = !string.IsNullOrEmpty(ImpressResourcePath)
|
||||
? await ViewModelHelper.GetSource(
|
||||
$"https://{HostName}/{ImpressResourcePath}", // "site/impress.html"
|
||||
IsSiteCachingOn)
|
||||
: await Task.FromResult(ViewModelHelper.FromBody("No impress resource available. Resource path is null or empty."))
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -64,15 +78,16 @@ namespace TINK.ViewModel.Info
|
|||
/// <returns> AGBs</returns>
|
||||
public static async Task<HtmlWebViewSource> GetAgb(
|
||||
string hostName,
|
||||
bool isSiteCachingOn,
|
||||
Func<string, string> resourceProvider)
|
||||
string agbResourcePath,
|
||||
bool isSiteCachingOn)
|
||||
{
|
||||
return new HtmlWebViewSource
|
||||
{
|
||||
Html = await ViewModelHelper.GetSource(
|
||||
$"https://{hostName}/{hostName.GetAGBResource()}",
|
||||
isSiteCachingOn,
|
||||
hostName.GetIsCopri() ? () => resourceProvider("HtmlResouces.V02.InfoAGB.html") : (Func<string>) null) /* offline resources only available for TINK */,
|
||||
Html = !string.IsNullOrEmpty(agbResourcePath)
|
||||
? await ViewModelHelper.GetSource(
|
||||
$"https://{hostName}/{agbResourcePath}", // "agb.html"
|
||||
isSiteCachingOn)
|
||||
: await Task.FromResult(ViewModelHelper.FromBody("No terms resource available. Resource path is null or empty."))
|
||||
};
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue