scriptBoris / NavigationSam

Can intercept action navigation back by user
17 stars 1 forks source link

PushModal - Android Hardware Back #12

Open Engincode opened 2 years ago

Engincode commented 2 years ago

Hi Sam There are strange bug on the Android side..

When we push with Modal (with NavigationPage); HardwareBack doesn't work.

Example: Page1.xaml, Page2.xaml

Page1, Button1, OnTap body

private void Button1_Tapped(object sender, EventArgs e) { Navigation.PushModalAsync(new NavigationPageSam(new Page2())); }

After that, HardwareBack doesn't work. Can you check?

mlyga commented 1 year ago

You have to implement the INavigationPopInterceptor interface in the ContentPage (class) to be able to handle the backbutton (the software and hardware both acts same using this package).

mlyga commented 1 year ago

Example:

public partial class Page1 : ContentPage, INavigationPopInterceptor
{
    public bool IsPopRequest { get; set; }

    public MainPageView()
    {
        InitializeComponent();
    }

    public Task<bool> RequestPop()
    {
        return Task.Run(() => true);
    }
}