mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-12-23 15:46:29 +01:00
80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
|
using TINK.View;
|
|||
|
using System.Windows.Input;
|
|||
|
using Xamarin.Forms;
|
|||
|
using System;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using TINK.ViewModel.Info;
|
|||
|
using TINK.Model.User.Account;
|
|||
|
|
|||
|
namespace TINK.ViewModel.WhatsNew.Agb
|
|||
|
{
|
|||
|
public class AgbViewModel : INotifyPropertyChanged
|
|||
|
{
|
|||
|
/// <summary> Fired whenever a property changed.</summary>
|
|||
|
public event PropertyChangedEventHandler PropertyChanged;
|
|||
|
|
|||
|
/// <summary> Holds the name of the host.</summary>
|
|||
|
private string HostName { get; }
|
|||
|
|
|||
|
/// <summary> Holds value wether site caching is on or off.</summary>
|
|||
|
bool IsSiteCachingOn { get; }
|
|||
|
|
|||
|
/// <summary> Constructs AGB 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>
|
|||
|
/// <param name="p_oViewService">View service to close page.</param>
|
|||
|
public AgbViewModel(
|
|||
|
string hostName,
|
|||
|
bool isSiteCachingOn,
|
|||
|
Func<string, string> resourceProvider,
|
|||
|
IViewService p_oViewService)
|
|||
|
{
|
|||
|
HostName = hostName;
|
|||
|
|
|||
|
IsSiteCachingOn = isSiteCachingOn;
|
|||
|
|
|||
|
ViewService = p_oViewService
|
|||
|
?? throw new ArgumentException($"Can not instantiate {typeof(WhatsNewViewModel)}-object. No view available.");
|
|||
|
|
|||
|
ResourceProvider = resourceProvider
|
|||
|
?? throw new ArgumentException($"Can not instantiate {typeof(WhatsNewViewModel)}-object. No ressource provider availalbe.");
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Gets the platfrom specific prefix. </summary>
|
|||
|
private Func<string, string> ResourceProvider { get; set; }
|
|||
|
|
|||
|
/// <summary> Agb information text.</summary>
|
|||
|
private HtmlWebViewSource infoAgb;
|
|||
|
|
|||
|
/// <summary> Agb information text.</summary>
|
|||
|
public HtmlWebViewSource InfoAgb
|
|||
|
{
|
|||
|
get => infoAgb;
|
|||
|
set
|
|||
|
{
|
|||
|
infoAgb = value;
|
|||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(InfoAgb)));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Called when page is shown. </summary>
|
|||
|
public async Task OnAppearing()
|
|||
|
{
|
|||
|
InfoAgb = await InfoViewModel.GetAgb(HostName, IsSiteCachingOn, ResourceProvider);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> User clicks OK button.</summary>
|
|||
|
public ICommand OnOk
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return new Command(async () => await ViewService.PopModalAsync());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Reference to view service object.</summary>
|
|||
|
private IViewService ViewService;
|
|||
|
}
|
|||
|
}
|