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

fix(converters): refactor converters to take type of visibility instead of string #1245

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions src/library/Uno.Material/Styles/Application/Common/Converters.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:um="using:Uno.Material">

<Visibility x:Key="VisibleVal">Visible</Visibility>
<Visibility x:Key="CollapsedVal">Collapsed</Visibility>

<um:FromBoolToValueConverter x:Key="MaterialTrueToVisible"
TrueValue="Visible"
FalseValue="Collapsed"
NullValue="Collapsed" />
TrueValue="{StaticResource VisibleVal}"
FalseValue="{StaticResource CollapsedVal}"
NullValue="{StaticResource CollapsedVal}" />

<um:FromBoolToValueConverter x:Key="MaterialTrueToCollapsed"
TrueValue="Collapsed"
FalseValue="Visible"
NullValue="Visible" />
TrueValue="{StaticResource CollapsedVal}"
FalseValue="{StaticResource VisibleVal}"
NullValue="{StaticResource VisibleVal}" />

<um:FromEmptyStringToValueConverter x:Key="MaterialEmptyToFalse"
NotNullOrEmptyValue="True"
Expand All @@ -21,32 +24,32 @@
NullOrEmptyValue="True" />

<um:FromEmptyStringToValueConverter x:Key="MaterialEmptyToVisible"
NotNullOrEmptyValue="Collapsed"
NullOrEmptyValue="Visible" />
NotNullOrEmptyValue="{StaticResource CollapsedVal}"
NullOrEmptyValue="{StaticResource VisibleVal}" />

<um:FromEmptyStringToValueConverter x:Key="MaterialEmptyToCollapsed"
NotNullOrEmptyValue="Visible"
NullOrEmptyValue="Collapsed" />
NotNullOrEmptyValue="{StaticResource VisibleVal}"
NullOrEmptyValue="{StaticResource CollapsedVal}" />

<um:FromNullToValueConverter x:Key="MaterialNullToCollapsedConverter"
NotNullValue="Visible"
NullValue="Collapsed" />
NotNullValue="{StaticResource VisibleVal}"
NullValue="{StaticResource CollapsedVal}" />

<um:FromNullToValueConverter x:Key="MaterialNullToVisibleConverter"
NotNullValue="Visible"
NullValue="Collapsed" />
NotNullValue="{StaticResource VisibleVal}"
NullValue="{StaticResource CollapsedVal}" />

<um:FromNullToValueConverter x:Key="MaterialNullToTransparent"
NotNullValue="1"
NullValue="0" />

<um:FromEmptyStringOrNullObjectToValueConverter x:Key="MaterialEmptyOrNullToVisible"
NotEmptyOrNullValue="Collapsed"
EmptyOrNullValue="Visible" />
NotEmptyOrNullValue="{StaticResource CollapsedVal}"
EmptyOrNullValue="{StaticResource VisibleVal}" />

<um:FromEmptyStringOrNullObjectToValueConverter x:Key="MaterialEmptyOrNullToCollapsed"
NotEmptyOrNullValue="Visible"
EmptyOrNullValue="Collapsed" />
NotEmptyOrNullValue="{StaticResource VisibleVal}"
EmptyOrNullValue="{StaticResource CollapsedVal}" />

<um:StringFormatConverter x:Key="StringFormatConverter" />
<um:FirstCharacterConverter x:Key="FirstCharacterConverter" />
Expand Down
10 changes: 6 additions & 4 deletions src/library/Uno.Material/Styles/Controls/v2/ComboBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
xmlns:um="using:Uno.Material"
xmlns:xamarin="http://uno.ui/xamarin"
mc:Ignorable="xamarin">
<Visibility x:Key="VisibleVal">Visible</Visibility>
<Visibility x:Key="CollapsedVal">Collapsed</Visibility>

<!-- Converters -->
<um:FromNullToValueConverter x:Key="NullToContentTranslateYConverter"
NotNullValue="5"
NullValue="0" />

<um:FromNullToValueConverter x:Key="NullToVisible"
NotNullValue="Collapsed"
NullValue="Visible" />
NotNullValue="{StaticResource CollapsedVal}"
NullValue="{StaticResource VisibleVal}" />

<um:FromNullToValueConverter x:Key="NullToCollapsed"
NotNullValue="Visible"
NullValue="Collapsed" />
NotNullValue="{StaticResource VisibleVal}"
NullValue="{StaticResource CollapsedVal}" />

<ResourceDictionary.ThemeDictionaries>

Expand Down
15 changes: 9 additions & 6 deletions src/samples/UWP/Uno.Themes.Samples.Shared/Converters.xaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Uno.Themes.Samples.Converters">
<Visibility x:Key="VisibleVal">Visible</Visibility>
<Visibility x:Key="CollapsedVal">Collapsed</Visibility>

<converters:FromStringToValueConverter x:Key="IsNullOrEmptyToCollapsed"
Check="IsNullOrEmpty"
TrueValue="Collapsed"
FalseValue="Visible" />
TrueValue="{StaticResource CollapsedVal}"
FalseValue="{StaticResource VisibleVal}" />

<converters:FromStringToValueConverter x:Key="SelectedItemToVisible"
Check="IsEqualToParameterValue"
TrueValue="Visible"
FalseValue="Collapsed" />
TrueValue="{StaticResource VisibleVal}"
FalseValue="{StaticResource CollapsedVal}" />

<converters:EnumDescriptionConverter x:Key="EnumToDescription" />
<converters:FromBoolToValueConverter x:Key="TrueToVisible"
TrueValue="Visible"
NullOrFalseValue="Collapsed" />
TrueValue="{StaticResource VisibleVal}"
NullOrFalseValue="{StaticResource CollapsedVal}" />
</ResourceDictionary>
Loading