Skip to content

Commit e28392d

Browse files
authored
FIx - Add ReactiveFlyoutPage to Maui (#3720)
<!-- 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**:
1 parent 9c36b0f commit e28392d

File tree

9 files changed

+56
-18
lines changed

9 files changed

+56
-18
lines changed

src/Directory.build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3434
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
3535
<PublishRepositoryUrl>true</PublishRepositoryUrl>
36-
<XunitVersion>2.6.4</XunitVersion>
36+
<XunitVersion>2.6.6</XunitVersion>
3737
</PropertyGroup>
3838
<!--<PropertyGroup Condition="$(IsTestProject) != 'true'">
3939
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -58,7 +58,7 @@
5858
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.0" />
5959
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
6060
<PackageReference Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="All" />
61-
<PackageReference Include="Verify.Xunit" Version="22.11.1" />
61+
<PackageReference Include="Verify.Xunit" Version="23.0.1" />
6262
</ItemGroup>
6363

6464
<ItemGroup Condition="'$(IsTestProject)' != 'true'">

src/ReactiveUI.Fody.Tests/API/ApiApprovalTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Threading.Tasks;
88
using ReactiveUI.Fody.Helpers;
99
using ReactiveUI.Tests;
10-
using VerifyXunit;
1110
using Xunit;
1211

1312
namespace ReactiveUI.Fody.Tests.API;
@@ -19,7 +18,6 @@ namespace ReactiveUI.Fody.Tests.API;
1918
/// for version changing reasons.
2019
/// </summary>
2120
[ExcludeFromCodeCoverage]
22-
[UsesVerify]
2321
public class ApiApprovalTests
2422
{
2523
/// <summary>

src/ReactiveUI.Fody.Tests/ApiExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace ReactiveUI.Tests;
1717
/// A helper for doing API approvals.
1818
/// </summary>
1919
[ExcludeFromCodeCoverage]
20-
[UsesVerify]
2120
public static class ApiExtensions
2221
{
2322
/// <summary>
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
2+
// Licensed to the .NET Foundation under one or more agreements.
3+
// The .NET Foundation licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using Microsoft.Maui.Controls;
7+
8+
namespace ReactiveUI.Maui;
9+
10+
/// <summary>
11+
/// Reactive Flyout Page.
12+
/// </summary>
13+
/// <typeparam name="TViewModel">The type of the view model.</typeparam>
14+
/// <seealso cref="FlyoutPage" />
15+
/// <seealso cref="IViewFor{TViewModel}" />
16+
public class ReactiveFlyoutPage<TViewModel> : FlyoutPage, IViewFor<TViewModel>
17+
where TViewModel : class
18+
{
19+
/// <summary>
20+
/// The view model bindable property.
21+
/// </summary>
22+
public static readonly BindableProperty ViewModelProperty = BindableProperty.Create(
23+
nameof(ViewModel),
24+
typeof(TViewModel),
25+
typeof(ReactiveFlyoutPage<TViewModel>),
26+
default(TViewModel),
27+
BindingMode.OneWay,
28+
propertyChanged: OnViewModelChanged);
29+
30+
/// <summary>
31+
/// Gets or sets the ViewModel to display.
32+
/// </summary>
33+
public TViewModel? ViewModel
34+
{
35+
get => (TViewModel)GetValue(ViewModelProperty);
36+
set => SetValue(ViewModelProperty, value);
37+
}
38+
39+
/// <inheritdoc/>
40+
object? IViewFor.ViewModel
41+
{
42+
get => ViewModel;
43+
set => ViewModel = (TViewModel?)value;
44+
}
45+
46+
/// <inheritdoc/>
47+
protected override void OnBindingContextChanged()
48+
{
49+
base.OnBindingContextChanged();
50+
ViewModel = BindingContext as TViewModel;
51+
}
52+
53+
private static void OnViewModelChanged(BindableObject bindableObject, object oldValue, object newValue) => bindableObject.BindingContext = newValue;
54+
}

src/ReactiveUI.Tests/API/ApiApprovalTests.cs

-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
using VerifyXunit;
7-
86
namespace ReactiveUI.Tests.API;
97

108
/// <summary>
119
/// Checks to make sure that the API is consistent with previous releases, and new API changes are highlighted.
1210
/// </summary>
1311
[ExcludeFromCodeCoverage]
14-
[UsesVerify]
1512
public class ApiApprovalTests
1613
{
1714
/// <summary>

src/ReactiveUI.Tests/Platforms/windows-xaml/Api/XamlApiApprovalTests.cs

-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
using VerifyXunit;
7-
86
namespace ReactiveUI.Tests.Xaml;
97

108
/// <summary>
119
/// API approvals for the xaml project.
1210
/// </summary>
1311
[ExcludeFromCodeCoverage]
14-
[UsesVerify]
1512
public class XamlApiApprovalTests
1613
{
1714
/// <summary>

src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.cs

-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
using VerifyXunit;
7-
86
namespace ReactiveUI.Tests;
97

108
/// <summary>
119
/// Checks the WinForms API to make sure there aren't any unexpected public API changes.
1210
/// </summary>
1311
[ExcludeFromCodeCoverage]
14-
[UsesVerify]
1512
public class WinformsApiApprovalTests
1613
{
1714
/// <summary>

src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.cs

-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6-
using VerifyXunit;
7-
86
namespace ReactiveUI.Tests.Wpf;
97

108
/// <summary>
119
/// Checks the WPF API to make sure there aren't any unexpected public API changes.
1210
/// </summary>
1311
[ExcludeFromCodeCoverage]
14-
[UsesVerify]
1512
public class WpfApiApprovalTests
1613
{
1714
/// <summary>

src/ReactiveUI.Tests/Utilities/ApiExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace ReactiveUI.Tests;
1616
/// A helper for doing API approvals.
1717
/// </summary>
1818
[ExcludeFromCodeCoverage]
19-
[UsesVerify]
2019
public static class ApiExtensions
2120
{
2221
/// <summary>

0 commit comments

Comments
 (0)