mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
107 lines
3.5 KiB
C#
107 lines
3.5 KiB
C#
|
using TINK.View;
|
|||
|
using System.Windows.Input;
|
|||
|
using Xamarin.Forms;
|
|||
|
using System;
|
|||
|
using System.ComponentModel;
|
|||
|
|
|||
|
namespace TINK.ViewModel.WhatsNew
|
|||
|
{
|
|||
|
public class WhatsNewViewModel : INotifyPropertyChanged
|
|||
|
{
|
|||
|
/// <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,
|
|||
|
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 avilable.");
|
|||
|
|
|||
|
CurrentVersion = currentVersion;
|
|||
|
WhatsNewText = new FormattedString();
|
|||
|
WhatsNewText.Spans.Add(new Span { Text = 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.AgbPage));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <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 IViewService ViewService;
|
|||
|
|
|||
|
/// <summary>Reference to view service object.</summary>
|
|||
|
private Action ShowMasterDetail { get; }
|
|||
|
|
|||
|
/// <summary> Fired whenever a property changes.</summary>
|
|||
|
public event PropertyChangedEventHandler PropertyChanged;
|
|||
|
}
|
|||
|
}
|