Skip to content

Commit

Permalink
Fix deleted voucher navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
ncarandini committed Dec 22, 2019
1 parent c18b29c commit aa24559
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/Italia.DiciottoApp/Views/VoucherPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,31 @@ private async void OnDeleteVoucherButtonTapped(object sender, EventArgs e)
{
await DisplayAlert("Annulla buono", "Il buono è stato annullato e il suo valore riassegnato alla tua disponibilità", "OK");

// Find and delete from the navigation history all detail pages of this voucher
var voucherPages = Navigation.NavigationStack.Where(p => p is VoucherPage).ToList();
if (voucherPages != null)
{
foreach (var voucherPage in voucherPages)
{
VoucherViewModel voucherViewModel = (VoucherViewModel)voucherPage.BindingContext;
if (voucherPage != this && voucherViewModel.Voucher.Id == vm.Voucher.Id)
{
Navigation.RemovePage(voucherPage);
}
}
}

// Go back
await Navigation.PopAsync();
//// Find and delete from the navigation history all detail pages of this voucher
//var voucherPages = Navigation.NavigationStack.Where(p => p is VoucherPage).ToList();
//if (voucherPages != null)
//{
// foreach (var voucherPage in voucherPages)
// {
// VoucherViewModel voucherViewModel = (VoucherViewModel)voucherPage.BindingContext;
// if (voucherPage != this && voucherViewModel.Voucher.Id == vm.Voucher.Id)
// {
// Navigation.RemovePage(voucherPage);
// }
// }
//}

//// Go back
//await Navigation.PopAsync();

// Get the root page
IReadOnlyList<Page> navStack = Navigation.NavigationStack;
Page currentRootPage = navStack[0];

Navigation.InsertPageBefore(new LoggedRootPage(), currentRootPage);

// Clear navigation stack
await Navigation.PopToRootAsync();
}
}
else
Expand Down

0 comments on commit aa24559

Please sign in to comment.