mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 20:46:28 +02:00
Version 3.0.381
This commit is contained in:
parent
f963c0a219
commit
3a363acf3a
1525 changed files with 60589 additions and 125098 deletions
78
SharedBusinessLogic/ViewModel/WhatsNew/Gtc/GtcViewModel.cs
Normal file
78
SharedBusinessLogic/ViewModel/WhatsNew/Gtc/GtcViewModel.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using ShareeBike.View;
|
||||
using ShareeBike.ViewModel.LegalInformation;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace ShareeBike.ViewModel.WhatsNew.Gtc
|
||||
{
|
||||
public class GtcViewModel : 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 whether site caching is on or off.</summary>
|
||||
bool IsSiteCachingOn { get; }
|
||||
|
||||
/// <summary> Constructs AGB view model</summary>
|
||||
/// <param name="isSiteCachingOn">Holds value whether site caching is on or off.</param>
|
||||
/// <param name="uiIsoLangugageName">Two letter ISO language name.</param>
|
||||
/// <param name="resourceProvider">Delegate to get embedded html resource. Used as fallback if download from web page does not work and cache is empty.</param>
|
||||
/// <param name="viewService">View service to close page.</param>
|
||||
public GtcViewModel(
|
||||
string hostName,
|
||||
bool isSiteCachingOn,
|
||||
Func<string, string> resourceProvider,
|
||||
IViewService viewService)
|
||||
{
|
||||
HostName = hostName;
|
||||
IsSiteCachingOn = isSiteCachingOn;
|
||||
|
||||
ViewService = viewService
|
||||
?? throw new ArgumentException($"Can not instantiate {typeof(WhatsNewViewModel)}-object. No view available.");
|
||||
|
||||
ResourceProvider = resourceProvider
|
||||
?? throw new ArgumentException($"Can not instantiate {typeof(WhatsNewViewModel)}-object. No resource provider centered.");
|
||||
}
|
||||
|
||||
/// <summary> Gets the platfrom specific prefix. </summary>
|
||||
private Func<string, string> ResourceProvider { get; set; }
|
||||
|
||||
/// <summary> Agb information text.</summary>
|
||||
private HtmlWebViewSource gtcHtml;
|
||||
|
||||
/// <summary> Agb information text.</summary>
|
||||
public HtmlWebViewSource GtcHtml
|
||||
{
|
||||
get => gtcHtml;
|
||||
set
|
||||
{
|
||||
gtcHtml = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(GtcHtml)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Called when page is shown. </summary>
|
||||
public async Task OnAppearing()
|
||||
{
|
||||
GtcHtml = await LegalInformationPageViewModel.GetGtc(HostName, "agbResourcePath", IsSiteCachingOn);
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
107
SharedBusinessLogic/ViewModel/WhatsNew/WhatsNewViewModel.cs
Normal file
107
SharedBusinessLogic/ViewModel/WhatsNew/WhatsNewViewModel.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using ShareeBike.View;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace ShareeBike.ViewModel.WhatsNew
|
||||
{
|
||||
public class WhatsNewViewModel
|
||||
{
|
||||
/// <summary> Constructs view model. </summary>
|
||||
/// <param name="currentVersion"></param>
|
||||
/// <param name="whatsNewText"></param>
|
||||
/// <param name="isShowAgbRequired"></param>
|
||||
/// <param name="showMasterDetail">Delegate to invoke master detail.</param>
|
||||
/// <param name="p_oViewService">View service to show agb- page.</param>
|
||||
public WhatsNewViewModel(
|
||||
Version currentVersion,
|
||||
IDictionary<Version, string> whatsNewText,
|
||||
bool isShowAgbRequired,
|
||||
Action showMasterDetail,
|
||||
IViewService p_oViewService)
|
||||
{
|
||||
ViewService = p_oViewService
|
||||
?? throw new ArgumentException($"Can not instantiate {typeof(WhatsNewViewModel)}-object. No view available.");
|
||||
|
||||
ShowMasterDetail = showMasterDetail
|
||||
?? throw new ArgumentException($"Can not instantiate {typeof(WhatsNewViewModel)}-object. No delegate to activated maste detail page available.");
|
||||
|
||||
CurrentVersion = currentVersion;
|
||||
WhatsNewText = new FormattedString();
|
||||
WhatsNewText.Spans.Add(new Span { Text = GetWhatNextHtmlText(whatsNewText) });
|
||||
IsAgbChangedVisible = isShowAgbRequired;
|
||||
}
|
||||
|
||||
public Version CurrentVersion { get; }
|
||||
|
||||
public FormattedString WhatsNewText { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Title of the WhatsNewPage.
|
||||
/// </summary>
|
||||
public string WhatsNewTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
// Get version info.
|
||||
return $"Neu in Version {CurrentVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Text saying that AGBs were modified.</summary>
|
||||
public FormattedString AgbChangedText
|
||||
{
|
||||
get
|
||||
{
|
||||
var l_oHint = new FormattedString();
|
||||
l_oHint.Spans.Add(new Span { Text = "AGBs ", ForegroundColor = ViewModelHelper.LINK_COLOR });
|
||||
l_oHint.Spans.Add(new Span { Text = "überarbeitet.\r\n" });
|
||||
|
||||
return l_oHint;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAgbChangedVisible { get; }
|
||||
|
||||
/// <summary> Command object to bind agb link to view model.</summary>
|
||||
public ICommand OnShowAgbTapped
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Command(async () => await ViewService.PushModalAsync(ViewTypes.GtcPage));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Called when dialog is disappearing.</summary>
|
||||
/// <param name="setWhatsNewWasShown"></param>
|
||||
public void OnDisappearing(Action setWhatsNewWasShown)
|
||||
{
|
||||
setWhatsNewWasShown();
|
||||
}
|
||||
|
||||
#if !SHOWFEEDBACK
|
||||
public bool IsFeedbackVisible => false;
|
||||
#else
|
||||
public bool IsFeedbackVisible => true;
|
||||
#endif
|
||||
/// <summary> User clicks rate button.</summary>
|
||||
public ICommand OnOk
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Command(() => ShowMasterDetail());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Reference to view service object.</summary>
|
||||
private readonly IViewService ViewService;
|
||||
|
||||
/// <summary>Reference to view service object.</summary>
|
||||
private Action ShowMasterDetail { get; }
|
||||
|
||||
public static string GetWhatNextHtmlText(IDictionary<Version, string> whatsNew)
|
||||
=> string.Join("", whatsNew.Select(element => $"<p><b>{element.Key}</b><br/>{element.Value}</p>").ToArray());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue