Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify crating IconValues for UnifiedIcon from XAML #953

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

Al12rs
Copy link
Contributor

@Al12rs Al12rs commented Feb 15, 2024

Simplified the various existing Setters on IconValue to be easier to use from XAML.

They now take the original types of string, IImage, Geometry instead of the custom types used internally by IconValue.
This allows them to be set them inline instead of having to wrap them in the custom types.

This maintains the single UnifiedIcon.Value Api, but reduces the number of lines needed to define the contents of an icon from XAML.

Before:

                <unifiedIcon:IconValue x:Key="ProjektankerIconValue">
                    <unifiedIcon:IconValue.ProjektankerIconValueSetter>
                        <unifiedIcon:ProjektankerIcon Value="mdi-cog" />
                    </unifiedIcon:IconValue.ProjektankerIconValueSetter>
                </unifiedIcon:IconValue>

After:

<unifiedIcon:IconValue x:Key="ProjektankerIconValue" MdiValueSetter="mdi-cog"/>
@Al12rs Al12rs requested a review from a team February 15, 2024 12:55
@Al12rs Al12rs self-assigned this Feb 15, 2024
Copy link
Member

@erri120 erri120 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types of the union should be changed back to init-only records. I converted them to have a getter and setter because XAML can't work with constructors.

// before
public class ProjektankerIcon
{
    public string? Value { get; set; }

    public ProjektankerIcon() { }

    public ProjektankerIcon(string? value)
    {
        Value = value;
    }
}

// after
public record ProjektankerIcon(string? Value);
@Al12rs Al12rs requested a review from erri120 February 15, 2024 13:04
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (903e6fb) 58.67% compared to head (16d7e94) 58.74%.
Report is 2 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #953      +/-   ##
==========================================
+ Coverage   58.67%   58.74%   +0.06%     
==========================================
  Files         630      630              
  Lines       20253    20236      -17     
  Branches     1555     1555              
==========================================
+ Hits        11884    11888       +4     
+ Misses       8006     7987      -19     
+ Partials      363      361       -2     
Flag Coverage Δ
Linux 58.05% <0.00%> (+0.01%) ⬆️
Windows 58.01% <0.00%> (+0.04%) ⬆️
clean_environment_tests 58.73% <0.00%> (+0.06%) ⬆️
network_tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...xusMods.App.UI/Controls/UnifiedIcon/UnifiedIcon.cs 42.64% <0.00%> (ø)
...NexusMods.App.UI/Controls/UnifiedIcon/IconValue.cs 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

@Al12rs Al12rs merged commit b36cfeb into main Feb 15, 2024
4 checks passed
@Al12rs Al12rs deleted the IconValue_accessors branch February 15, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants