-
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.
- Loading branch information
Showing
3 changed files
with
176 additions
and
5 deletions.
There are no files selected for viewing
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
86 changes: 86 additions & 0 deletions
86
src/Controls/tests/TestCases.HostApp/Issues/Shell/ShellTransientTests.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,86 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.None, 0, "Navigating Between Transient Shell States Recreates Pages")] | ||
public class ShellTransientTests : Shell | ||
{ | ||
List<ContentPage> _contentPages = new List<ContentPage>(); | ||
protected override void OnNavigated(ShellNavigatedEventArgs args) | ||
{ | ||
base.OnNavigated(args); | ||
|
||
if (_contentPages.Contains(this.CurrentPage)) | ||
{ | ||
(CurrentPage as ContentPage).Content = new VerticalStackLayout() | ||
{ | ||
Children = | ||
{ | ||
new Label { Text = "Test Failed I am not a new page", AutomationId = "Failure" } | ||
} | ||
}; | ||
} | ||
else | ||
{ | ||
(CurrentPage as ContentPage).Content = new VerticalStackLayout() | ||
{ | ||
Children = | ||
{ | ||
new Label { Text = "I am a new page", AutomationId = "Success" } | ||
} | ||
}; | ||
} | ||
|
||
_contentPages.Add((ContentPage)this.CurrentPage); | ||
} | ||
|
||
public ShellTransientTests() | ||
{ | ||
var shellContent1 = new ShellContent() | ||
{ | ||
ContentTemplate = new DataTemplate(typeof(TransientPage)) | ||
}; | ||
|
||
|
||
var shellContent2 = new ShellContent() | ||
{ | ||
ContentTemplate = new DataTemplate(typeof(TransientPage)) | ||
}; | ||
|
||
var shellContent3 = new ShellContent() | ||
{ | ||
ContentTemplate = new DataTemplate(typeof(ContentPage)) | ||
}; | ||
|
||
Items.Add(new FlyoutItem() | ||
{ | ||
Title = "Flyout Item 1", | ||
Items = | ||
{ | ||
shellContent1 | ||
} | ||
}); | ||
|
||
Items.Add(new FlyoutItem() | ||
{ | ||
Title = "Flyout Item 2", | ||
Items = | ||
{ | ||
shellContent2 | ||
} | ||
}); | ||
|
||
|
||
Items.Add(new FlyoutItem() | ||
{ | ||
Title = "Flyout Item 3", | ||
Items = | ||
{ | ||
shellContent3 | ||
} | ||
}); | ||
} | ||
} | ||
} |