-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ValueConverterExtension to allow for comparison of Nullable ty…
…pes to corresponding underlying types (#1307) * UPDATE - Updated ValidateTargetType to allow comparison on nullable types * UPDATE - Removed incorrect ValueConverterExtension.shared.cs file. Updated failing test in BoolToObjectConverterTests.cs * REVERT - Reverted changes to BoolToObjectConverterTests.cs * DELETE - Deleted ValueConverterExtensionTests.cs * ADD - Introduced PerformNullableTypeValidation in ValueConverterExtension.shared.cs, added unit tests to IsStringNotNullOrEmptyConverterTests.cs * REFACTOR - Refactored ValueConverterExtension.shared.cs to remove redundant code and checks * ADD - Added sample to IsStringNotNullOrEmptyConverterPage.xaml * ADD - Implemented additional tests for IsStringNotNullOrWhiteSpaceConverterTests.cs, IsStringNullOrEmptyConverterTests.cs and IsStringNullOrWhiteSpaceConverterTests.cs * ADD - Added further tests. Renamed new tests to use Name_Should_When convention * Move `NullableBoolComponentWithLabel` to `Views`, `dotnet format` * Add logic to allow Nullable Value Types for `TTo` * Add nullable input test * Remove unnecessary `ContentView` * Add `NullableBoolComponentWithLabel` to `IsStringNullOrEmptyConverterPage` * Fix failing `GravatarImageSource` test * Update InvertedBoolConverterTests.cs --------- Co-authored-by: Brandon Minnick <[email protected]>
- Loading branch information
1 parent
172a1e7
commit 112ff60
Showing
19 changed files
with
287 additions
and
40 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
11 changes: 11 additions & 0 deletions
11
samples/CommunityToolkit.Maui.Sample/Views/NullableBoolComponentWithLabel.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,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
|
||
<Label | ||
x:Class="CommunityToolkit.Maui.Sample.Views.NullableBoolComponentWithLabel" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Name="This" | ||
IsVisible="{Binding NullableIsVisible, Source={x:RelativeSource Self}}" | ||
Text="Binding to a nullable `bool` (`bool?`) is also allowed. If the `bool?` is null, the converter will return false." | ||
TextColor="{StaticResource NormalLabelTextColor}" | ||
VerticalOptions="Center" /> |
21 changes: 21 additions & 0 deletions
21
samples/CommunityToolkit.Maui.Sample/Views/NullableBoolComponentWithLabel.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,21 @@ | ||
namespace CommunityToolkit.Maui.Sample.Views; | ||
|
||
public partial class NullableBoolComponentWithLabel : Label | ||
{ | ||
public static readonly BindableProperty NullableIsVisibleProperty = BindableProperty.Create( | ||
nameof(NullableIsVisible), | ||
typeof(bool?), | ||
typeof(NullableBoolComponentWithLabel)); | ||
|
||
|
||
public NullableBoolComponentWithLabel() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public bool? NullableIsVisible | ||
{ | ||
get => (bool?)GetValue(NullableIsVisibleProperty); | ||
set => SetValue(NullableIsVisibleProperty, value); | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.