using System; using System.Threading.Tasks; using TINK.Model.Device; using TINK.View.MasterDetail; using TINK.ViewModel.Info; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace TINK.View.Contact { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class ContactPage : ContentPage, IViewService, IDetailPage { public ContactPage () { InitializeComponent (); ContactPageView.BindingContext = new ContactPageViewModel( App.ModelRoot.SelectedStation, App.ModelRoot.Uris.ActiveUri, () => App.CreateAttachment(), () => DependencyService.Get().OpenUrl(DependencyService.Get().StoreUrl), this); } /// Displays alert 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); /// Displays detailed alert message. /// Title of message. /// Message to display. /// Detailed error description. /// Text of accept button. /// Text of cancel button. /// True if user pressed accept. public async Task DisplayAdvancedAlert(string title, string message, string details, string accept, string cancel) => await App.Current.MainPage.DisplayAlert(title, $"{message}\r\nDetails:\r\n{details}", accept, cancel); #if USEMASTERDETAIL || USEFLYOUT public void ShowPage(ViewTypes p_oType, string p_strTitle = null) => throw new NotImplementedException(); #else /// Shows a page. /// Route of the page to show. public async Task ShowPage(string route) => await Shell.Current.GoToAsync(route); #endif /// Pushes a page onto the modal stack. /// Page to display. public Task PushModalAsync(ViewTypes p_oTypeOfPage) { throw new NotSupportedException(); } /// Pops a page from the modal stack. public Task PopModalAsync() { throw new NotSupportedException(); } /// Pushes a page onto the stack. /// Page to display. public async Task PushAsync(ViewTypes typeOfPage) { if (!(Activator.CreateInstance(typeOfPage.GetViewType()) is IDetailPage detailPage)) { await Task.CompletedTask; return; } // Set reference to navigation object to be able to show page on newly shown detailPage. detailPage.NavigationMasterDetail = NavigationMasterDetail; await Navigation.PushAsync((Page)detailPage); } #if USCSHARP9 public Task DisplayUserFeedbackPopup() => throw new NotSupportedException(); #else public Task DisplayUserFeedbackPopup() => throw new NotSupportedException(); #endif #if USEFLYOUT /// /// Delegate to perform navigation. /// public INavigationMasterDetail NavigationMasterDetail { set; private get; } #endif } }