using MobileApp1.Services; using System; using System.Threading.Tasks; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace MobileApp1.Views { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class PasswordResetView : ContentView { protected bool isBusy = false; public PasswordResetView() { InitializeComponent(); } private bool IsBusy { get => isBusy; set { isBusy = value; LoginPage cp = (LoginPage)ContentViewHelper.GetParentElement(this); if (cp != null) { cp.IsBusy = value; } Device.BeginInvokeOnMainThread(() => { loadingIndicatorView1.IsRunning = value; textbox1.IsEnabled = !value; button1.IsEnabled = !value; }); } } private async void button1_Clicked(object sender, EventArgs e) { await Task.Run(() => { if (this.Parent == null) { return; } ContentPage cp = ContentViewHelper.GetContentPage(this); if (cp == null) { return; } App ap = ContentViewHelper.GetApp(this); if (ap == null) { return; } this.IsBusy = true; ServiceResult result = ap.CorporationService.RequestPasswordReset(textbox1.Text); loadingIndicatorView1.Message = result.Message; this.IsBusy = false; //ContentViewHelper.SetMainPage(this, new AppShell()); //await cp.DisplayAlert("Clicked", "Login", "OK"); if (result.IsSuccess) { // //await ContentViewHelper.GetApplication(this)?.MainPage.Navigation.PushAsync(new PasswordResetPage()); // //ContentViewHelper.GetApplication(this).MainPage = new NavigationPage(new PasswordResetPage()); ContentViewHelper.SetMainPage(this, new PasswordResetPage()); } }); } } }