AndroidSystemNavigationManager.cs 804 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using Avalonia.Interactivity;
  3. using Avalonia.Platform;
  4. namespace Avalonia.Android.Platform
  5. {
  6. internal class AndroidSystemNavigationManagerImpl : ISystemNavigationManagerImpl
  7. {
  8. public event EventHandler<RoutedEventArgs> BackRequested;
  9. public AndroidSystemNavigationManagerImpl(IActivityNavigationService? navigationService)
  10. {
  11. if(navigationService != null)
  12. {
  13. navigationService.BackRequested += OnBackRequested;
  14. }
  15. }
  16. private void OnBackRequested(object sender, AndroidBackRequestedEventArgs e)
  17. {
  18. var routedEventArgs = new RoutedEventArgs();
  19. BackRequested?.Invoke(this, routedEventArgs);
  20. e.Handled = routedEventArgs.Handled;
  21. }
  22. }
  23. }