NavigationDemoPage.xaml.cs 5.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using Avalonia.Controls;
  3. using Avalonia.Interactivity;
  4. namespace ControlCatalog.Pages
  5. {
  6. public partial class NavigationDemoPage : ContentPage
  7. {
  8. private static readonly (string Group, string Title, string Description, Func<UserControl> Factory)[] Demos =
  9. {
  10. // Overview
  11. ("Overview", "First Look", "Basic NavigationPage with push/pop navigation and back button support.",
  12. () => new NavigationPageFirstLookPage()),
  13. ("Overview", "Modal Navigation", "Push and pop modal pages that appear on top of the navigation stack.",
  14. () => new NavigationPageModalPage()),
  15. ("Overview", "Navigation Events",
  16. "Subscribe to Pushed, Popped, PoppedToRoot, ModalPushed, and ModalPopped events.",
  17. () => new NavigationPageEventsPage()),
  18. // Appearance
  19. ("Appearance", "Bar Customization",
  20. "Customize the navigation bar background, foreground, shadow, and visibility.",
  21. () => new NavigationPageAppearancePage()),
  22. ("Appearance", "Header",
  23. "Set page header content: a string, icon, or any custom control in the navigation bar.",
  24. () => new NavigationPageTitlePage()),
  25. // Data
  26. ("Data", "Pass Data", "Pass data during navigation via constructor arguments or DataContext.",
  27. () => new NavigationPagePassDataPage()),
  28. ("Data", "MVVM Navigation",
  29. "Keep navigation decisions in view models by routing NavigationPage push and pop operations through a small INavigationService.",
  30. () => new NavigationPageMvvmPage()),
  31. // Features
  32. ("Features", "Attached Methods",
  33. "Per-page navigation bar and back button control via static attached methods.",
  34. () => new NavigationPageAttachedMethodsPage()),
  35. ("Features", "Back Button", "Customize, hide, or intercept the back button.",
  36. () => new NavigationPageBackButtonPage()),
  37. ("Features", "CommandBar",
  38. "Add, remove and position CommandBar items inside the navigation bar or as a bottom bar.",
  39. () => new NavigationPageToolbarPage()),
  40. ("Features", "Transitions",
  41. "Configure page transitions: PageSlide, Parallax Slide, CrossFade, Fade Through, and more.",
  42. () => new NavigationPageTransitionsPage()),
  43. ("Features", "Modal Transitions", "Configure modal transition: PageSlide from bottom, CrossFade, or None.",
  44. () => new NavigationPageModalTransitionsPage()),
  45. ("Features", "Stack Management", "Remove or insert pages anywhere in the navigation stack at runtime.",
  46. () => new NavigationPageStackPage()),
  47. ("Features", "Interactive Header",
  48. "Build a header with a title and live search box that filters page content in real time.",
  49. () => new NavigationPageInteractiveHeaderPage()),
  50. ("Features", "Back Swipe Gesture", "Swipe from the left edge to interactively pop the current page.",
  51. () => new NavigationPageGesturePage()),
  52. ("Features", "Scroll-Aware Bar",
  53. "Hide the navigation bar on downward scroll and reveal it on upward scroll.",
  54. () => new NavigationPageScrollAwarePage()),
  55. // Performance
  56. ("Performance", "Performance Monitor",
  57. "Track stack depth, live page instances, and managed heap size. Observe how memory is reclaimed after popping pages.",
  58. () => new NavigationPagePerformancePage()),
  59. // Showcases
  60. ("Showcases", "Pulse Fitness",
  61. "Login flow with RemovePage, TabbedPage dashboard with bottom tabs, and NavigationPage push for workout detail.",
  62. () => new PulseAppPage()),
  63. ("Showcases", "L'Avenir",
  64. "Restaurant app with DrawerPage flyout menu, TabbedPage bottom tabs, and NavigationPage push for dish detail.",
  65. () => new LAvenirAppPage()),
  66. ("Showcases", "AvaloniaFlix",
  67. "Streaming app with dark NavigationPage, hidden nav bar on home, and custom bar tint on movie detail pages.",
  68. () => new AvaloniaFlixAppPage()),
  69. ("Showcases", "Retro Gaming",
  70. "Arcade-style app with NavigationPage header, TabbedPage bottom tabs with CenteredTabPanel, and game detail push.",
  71. () => new RetroGamingAppPage()),
  72. ("Showcases", "Curved Header",
  73. "Shop app with dome-bottomed white header on home (nav bar hidden) and blue curved header on detail (BarLayoutBehavior.Overlay).",
  74. () => new NavigationPageCurvedHeaderPage()),
  75. };
  76. public NavigationDemoPage()
  77. {
  78. InitializeComponent();
  79. Loaded += OnLoaded;
  80. }
  81. private async void OnLoaded(object? sender, RoutedEventArgs e)
  82. {
  83. await SampleNav.PushAsync(NavigationDemoHelper.CreateGalleryHomePage(SampleNav, Demos), null);
  84. }
  85. }
  86. }