-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NavigationView Handler for Android (#2336)
* NavigationHandler Android * - code cleanup * - cleanup * - cleanup code * - fix naming * - fix comments * - move toolbar code to controls * - code cleanup * - organized code into NavigationManager * - cleanup * - cleanup * - add to gallery * - update naming * - fix winui
- Loading branch information
Showing
53 changed files
with
2,261 additions
and
1,222 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
src/Compatibility/Core/src/Android/PlatformConfigurationExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/Compatibility/Core/src/Windows/PlatformConfigurationExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Controls/samples/Controls.Sample/Pages/Core/NavigationGallery.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<views:BasePage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Pages.NavigationGallery" | ||
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base"> | ||
<views:BasePage.Content> | ||
<StackLayout | ||
Margin="12"> | ||
<Label Text="Page Count" x:Name="lblPageCount"></Label> | ||
<Button Text="Insert Page Before Current" Clicked="InsertPage" /> | ||
<Button Text="Pop Page" Clicked="PopPage" /> | ||
<Button Text="Push Page" Clicked="PushPage" /> | ||
<Button Text="Remove Page Before Current" Clicked="RemovePage" /> | ||
<Button Text="Pop To Root" Clicked="PopToRoot" /> | ||
<Button Text="Swap Root" Clicked="SwapRoot" /> | ||
<Button Text="Toggle Navigation Bar" Clicked="ToggleNavigationBar" /> | ||
<Button Text="Toggle Back Button" Clicked="ToggleBackButton" /> | ||
</StackLayout> | ||
</views:BasePage.Content> | ||
</views:BasePage> |
83 changes: 83 additions & 0 deletions
83
src/Controls/samples/Controls.Sample/Pages/Core/NavigationGallery.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Graphics; | ||
|
||
namespace Maui.Controls.Sample.Pages | ||
{ | ||
public partial class NavigationGallery | ||
{ | ||
static int pageCount = 0; | ||
|
||
static List<Page> _currentNavStack; | ||
public NavigationGallery() | ||
{ | ||
InitializeComponent(); | ||
pageCount++; | ||
lblPageCount.Text = $"{pageCount}"; | ||
this.Title = $"PAGE NUMBER {pageCount}"; | ||
} | ||
|
||
void InsertPage(object sender, EventArgs e) | ||
{ | ||
Navigation.InsertPageBefore(new NavigationGallery(), Navigation.NavigationStack.Last()); | ||
} | ||
|
||
async void PopPage(object sender, EventArgs e) | ||
{ | ||
await Navigation.PopAsync(true); | ||
} | ||
|
||
async void PushPage(object sender, EventArgs e) | ||
{ | ||
await Navigation.PushAsync(new NavigationGallery(), true); | ||
} | ||
|
||
async void PopToRoot(object sender, EventArgs e) | ||
{ | ||
await Navigation.PopToRootAsync(true); | ||
} | ||
|
||
void RemovePage(object sender, EventArgs e) | ||
{ | ||
if (Navigation.NavigationStack.Count >= 2) | ||
Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]); | ||
} | ||
|
||
void ToggleNavigationBar(object sender, EventArgs e) | ||
{ | ||
NavigationPage.SetHasNavigationBar(this, !NavigationPage.GetHasNavigationBar(this)); | ||
} | ||
|
||
void ToggleBackButton(object sender, EventArgs e) | ||
{ | ||
NavigationPage.SetHasBackButton(this, !NavigationPage.GetHasBackButton(this)); | ||
} | ||
|
||
|
||
void SwapRoot(object sender, EventArgs e) | ||
{ | ||
if (_currentNavStack == null) | ||
{ | ||
_currentNavStack = Navigation.NavigationStack.ToList(); | ||
(Parent as INavigationView).RequestNavigation( | ||
new NavigationRequest( | ||
new List<NavigationGallery> | ||
{ | ||
new NavigationGallery() | ||
}, false)); | ||
} | ||
else | ||
{ | ||
(Parent as INavigationView).RequestNavigation( | ||
new NavigationRequest(_currentNavStack, true)); | ||
|
||
_currentNavStack = null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 0 additions & 123 deletions
123
src/Controls/src/Core/HandlerImpl/NavigationPage.Impl.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.