using System; using System.Threading.Tasks; using TINK.Model.Device; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace TINK.View.WhatsNew { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class WhatsNewPage : ContentPage, IViewService { /// Holds a reference on the view model. private ViewModel.WhatsNew.WhatsNewViewModel WhatsNewViewModel; /// Constructs whats new page. /// Action to invoke master detail page. public WhatsNewPage(Action showMasterDetail) { InitializeComponent(); WhatsNewViewModel = new ViewModel.WhatsNew.WhatsNewViewModel( DependencyService.Get().Version, App.ModelRoot.WhatsNew.WhatsNewText, App.ModelRoot.WhatsNew.IsShowAgbRequired, showMasterDetail, this); BindingContext = WhatsNewViewModel; } /// Displays altert message. /// Title of message. /// Message to display. /// Detailed error description. /// Type of buttons. public async Task DisplayAdvancedAlert( string title, string message, string details, string cancel) => await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", cancel); public Task PopModalAsync() { throw new NotImplementedException(); ; } /// Pushes a page onto the stack. /// Page to display. public Task PushAsync(ViewTypes p_oTypeOfPage) { throw new NotImplementedException(); } public async Task PushModalAsync(ViewTypes p_oTypeOfPage) { await Navigation.PushModalAsync((Page)Activator.CreateInstance(p_oTypeOfPage.GetViewType())); } public void ShowPage(ViewTypes p_oType, string p_strTitle = null) { throw new NotImplementedException(); } public Task DisplayUserFeedbackPopup() => throw new NotSupportedException(); /// /// Invoked when pages is closed/ hidden. /// /// protected override void OnDisappearing() { base.OnDisappearing(); if (WhatsNewViewModel == null) { // View model might be null. return; } WhatsNewViewModel?.OnDisappearing(() => { App.ModelRoot.SetWhatsNewWasShown(); App.ModelRoot.Save(); }); } } }