6 changed files with 134 additions and 8 deletions
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Avalonia.Android |
||||
|
{ |
||||
|
public interface IActivityNavigationService |
||||
|
{ |
||||
|
event EventHandler<AndroidBackRequestedEventArgs> BackRequested; |
||||
|
} |
||||
|
|
||||
|
public class AndroidBackRequestedEventArgs : EventArgs |
||||
|
{ |
||||
|
public bool Handled { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Interactivity; |
||||
|
using Avalonia.Platform; |
||||
|
|
||||
|
namespace Avalonia.Android.Platform |
||||
|
{ |
||||
|
internal class AndroidSystemNavigationManager : ISystemNavigationManager |
||||
|
{ |
||||
|
public event EventHandler<RoutedEventArgs> BackRequested; |
||||
|
|
||||
|
public AndroidSystemNavigationManager(IActivityNavigationService? navigationService) |
||||
|
{ |
||||
|
if(navigationService != null) |
||||
|
{ |
||||
|
navigationService.BackRequested += OnBackRequested; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void OnBackRequested(object sender, AndroidBackRequestedEventArgs e) |
||||
|
{ |
||||
|
var routedEventArgs = new RoutedEventArgs(); |
||||
|
|
||||
|
BackRequested?.Invoke(this, routedEventArgs); |
||||
|
|
||||
|
e.Handled = routedEventArgs.Handled; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Interactivity; |
||||
|
using Avalonia.Metadata; |
||||
|
|
||||
|
namespace Avalonia.Platform |
||||
|
{ |
||||
|
[Unstable] |
||||
|
public interface ITopLevelWithSystemNavigationManager |
||||
|
{ |
||||
|
ISystemNavigationManager SystemNavigationManager { get; } |
||||
|
} |
||||
|
|
||||
|
[Unstable] |
||||
|
public interface ISystemNavigationManager |
||||
|
{ |
||||
|
public event EventHandler<RoutedEventArgs>? BackRequested; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue