Skip to content

Commit

Permalink
feat: NeedsFrame porperty for SampleAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Oct 19, 2022
1 parent 913da44 commit eacb4a0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#if HAS_UNO
using Uno.Foundation.Logging;
using MUXControlsTestApp;
#else
using Microsoft.Extensions.Logging;
using Uno.Logging;
Expand Down Expand Up @@ -689,7 +690,8 @@ SampleChooserContent GetContent(TypeInfo type, SampleAttribute attribute)
Description = attribute.Description,
ControlType = type.AsType(),
IgnoreInSnapshotTests = attribute.IgnoreInSnapshotTests,
IsManualTest = attribute.IsManualTest
IsManualTest = attribute.IsManualTest,
UsesFrame = attribute.UsesFrame
};
}

Expand Down Expand Up @@ -847,7 +849,6 @@ private async Task<List<SampleChooserContent>> GetFavoriteSamples(CancellationTo
}
}


/// <summary>
/// This method receives a newContent and returns a newly built content. It also adds the content to the settings for the latest ran tests.
/// </summary>
Expand All @@ -859,10 +860,12 @@ public async Task<object> UpdateContent(CancellationToken ct, SampleChooserConte
SampleChanging?.Invoke(this, EventArgs.Empty);

FrameworkElement container = null;
if (typeof(Page).IsAssignableFrom(newContent.ControlType))
{
// Content is a page, for MUX compatibility we use Frame to navigate to it.
// This ensures the Page.Frame property is not null.

var frameRequested =
newContent.UsesFrame &&
typeof(Page).IsAssignableFrom(newContent.ControlType);
if (frameRequested)
{
var frame = new Frame();
frame.Navigate(newContent.ControlType);
container = frame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public partial class SampleChooserContent : INotifyPropertyChanged
public string Description { get; set; }
public bool IgnoreInSnapshotTests { get; internal set; }
public bool IsManualTest { get; internal set; }
public bool UsesFrame { get; internal set; }

bool _isFavorite;
public bool IsFavorite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public SampleControlInfoAttribute(
Type viewModelType = null,
bool ignoreInSnapshotTests = false,
string description = null,
bool isManualTest = false
bool isManualTest = false,
bool usesFrame = true
)
: base(category)
{
Expand All @@ -24,6 +25,7 @@ public SampleControlInfoAttribute(
IgnoreInSnapshotTests = ignoreInSnapshotTests;
IsManualTest = isManualTest;
Description = description;
UsesFrame = usesFrame;
}

}
Expand Down Expand Up @@ -89,5 +91,11 @@ public SampleAttribute(params Type[] categories)
/// An optional description of the sample. A good practice is to explain the expected result of the sample.
/// </summary>
public string Description { get; set; }

/// <summary>
/// Set to true if the sample is navigated to using frame navigation.
/// </summary>
/// <remarks>Defaults to true.</remarks>
public bool UsesFrame { get; set; } = true;
}
}

0 comments on commit eacb4a0

Please sign in to comment.