Skip to content

Commit

Permalink
FIx - Add ReactiveFlyoutPage to Maui (#3720)
Browse files Browse the repository at this point in the history
<!-- Please be sure to read the
[Contribute](https://github.com/reactiveui/reactiveui#contribute)
section of the README -->

**What kind of change does this PR introduce?**
<!-- Bug fix, feature, docs update, ... -->

FIx for #3719 

**What is the current behavior?**
<!-- You can also link to an open issue here. -->

Maui is missing ReactiveFlyoutPage 

**What is the new behavior?**
<!-- If this is a feature change -->

Added ReactiveFlyoutPage to Maui
Updated Verify.Xunit and made code changes as required.

**What might this PR break?**

None

**Please check if the PR fulfills these requirements**
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)

**Other information**:
  • Loading branch information
ChrisPulman committed Jan 24, 2024
1 parent 9c36b0f commit e28392d
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Directory.build.props
Expand Up @@ -33,7 +33,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<XunitVersion>2.6.4</XunitVersion>
<XunitVersion>2.6.6</XunitVersion>
</PropertyGroup>
<!--<PropertyGroup Condition="$(IsTestProject) != 'true'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -58,7 +58,7 @@
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="All" />
<PackageReference Include="Verify.Xunit" Version="22.11.1" />
<PackageReference Include="Verify.Xunit" Version="23.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true'">
Expand Down
2 changes: 0 additions & 2 deletions src/ReactiveUI.Fody.Tests/API/ApiApprovalTests.cs
Expand Up @@ -7,7 +7,6 @@
using System.Threading.Tasks;
using ReactiveUI.Fody.Helpers;
using ReactiveUI.Tests;
using VerifyXunit;
using Xunit;

namespace ReactiveUI.Fody.Tests.API;
Expand All @@ -19,7 +18,6 @@ namespace ReactiveUI.Fody.Tests.API;
/// for version changing reasons.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class ApiApprovalTests
{
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/ReactiveUI.Fody.Tests/ApiExtensions.cs
Expand Up @@ -17,7 +17,6 @@ namespace ReactiveUI.Tests;
/// A helper for doing API approvals.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public static class ApiExtensions
{
/// <summary>
Expand Down
54 changes: 54 additions & 0 deletions src/ReactiveUI.Maui/ReactiveFlyoutPage.cs
@@ -0,0 +1,54 @@
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using Microsoft.Maui.Controls;

namespace ReactiveUI.Maui;

/// <summary>
/// Reactive Flyout Page.
/// </summary>
/// <typeparam name="TViewModel">The type of the view model.</typeparam>
/// <seealso cref="FlyoutPage" />
/// <seealso cref="IViewFor{TViewModel}" />
public class ReactiveFlyoutPage<TViewModel> : FlyoutPage, IViewFor<TViewModel>
where TViewModel : class
{
/// <summary>
/// The view model bindable property.
/// </summary>
public static readonly BindableProperty ViewModelProperty = BindableProperty.Create(
nameof(ViewModel),
typeof(TViewModel),
typeof(ReactiveFlyoutPage<TViewModel>),
default(TViewModel),
BindingMode.OneWay,
propertyChanged: OnViewModelChanged);

/// <summary>
/// Gets or sets the ViewModel to display.
/// </summary>
public TViewModel? ViewModel
{
get => (TViewModel)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}

/// <inheritdoc/>
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (TViewModel?)value;
}

/// <inheritdoc/>
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
ViewModel = BindingContext as TViewModel;
}

private static void OnViewModelChanged(BindableObject bindableObject, object oldValue, object newValue) => bindableObject.BindingContext = newValue;
}
3 changes: 0 additions & 3 deletions src/ReactiveUI.Tests/API/ApiApprovalTests.cs
Expand Up @@ -3,15 +3,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using VerifyXunit;

namespace ReactiveUI.Tests.API;

/// <summary>
/// Checks to make sure that the API is consistent with previous releases, and new API changes are highlighted.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class ApiApprovalTests
{
/// <summary>
Expand Down
Expand Up @@ -3,15 +3,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using VerifyXunit;

namespace ReactiveUI.Tests.Xaml;

/// <summary>
/// API approvals for the xaml project.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class XamlApiApprovalTests
{
/// <summary>
Expand Down
Expand Up @@ -3,15 +3,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using VerifyXunit;

namespace ReactiveUI.Tests;

/// <summary>
/// Checks the WinForms API to make sure there aren't any unexpected public API changes.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class WinformsApiApprovalTests
{
/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.cs
Expand Up @@ -3,15 +3,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using VerifyXunit;

namespace ReactiveUI.Tests.Wpf;

/// <summary>
/// Checks the WPF API to make sure there aren't any unexpected public API changes.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public class WpfApiApprovalTests
{
/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/ReactiveUI.Tests/Utilities/ApiExtensions.cs
Expand Up @@ -16,7 +16,6 @@ namespace ReactiveUI.Tests;
/// A helper for doing API approvals.
/// </summary>
[ExcludeFromCodeCoverage]
[UsesVerify]
public static class ApiExtensions
{
/// <summary>
Expand Down

0 comments on commit e28392d

Please sign in to comment.