Skip to content

Commit

Permalink
fix(solidcolorbrush): [ANDROID][WASM] Color brushes added to Thumbtin…
Browse files Browse the repository at this point in the history
…t, TrackTint, Fill, and Stroke missing opacity
  • Loading branch information
NicolasChampagne committed May 8, 2020
1 parent ae58377 commit ff059c3
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
<UserControl
x:Class="SamplesApp.Windows_UI_Xaml_Controls.ToggleSwitchControl.ToggleSwitch_Default_Style"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:uBehaviors="using:Uno.UI.Samples.Behaviors"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:wasm="http://uno.ui/android"
xmlns:xamarin="http://uno.ui/xamarin"
mc:Ignorable="d ios android xamarin wasm"
d:DesignHeight="2000"
d:DesignWidth="400">
<UserControl x:Class="SamplesApp.Windows_UI_Xaml_Controls.ToggleSwitchControl.ToggleSwitch_Default_Style"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:uBehaviors="using:Uno.UI.Samples.Behaviors"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:wasm="http://uno.ui/android"
xmlns:xamarin="http://uno.ui/xamarin"
mc:Ignorable="d ios android xamarin wasm"
d:DesignHeight="2000"
d:DesignWidth="400">

<UserControl.Resources>
<ResourceDictionary>

<SolidColorBrush x:Key="LightGreyBrush"
Color="#000000"
Opacity="0.38" />

<xamarin:Style x:Key="UmbrellaToggleSwitchStyle"
TargetType="ToggleSwitch">
TargetType="ToggleSwitch">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleSwitch">
<android:BindableSwitchCompat Checked="{TemplateBinding IsOn, Mode=TwoWay}"
Enabled="{TemplateBinding IsEnabled}"/>
<android:BindableSwitchCompat Checked="{TemplateBinding IsOn, Mode=TwoWay}"
Enabled="{TemplateBinding IsEnabled}"
ThumbTint="{StaticResource LightGreyBrush}"
TrackTint="{StaticResource LightGreyBrush}" />
<ios:BindableUISwitch IsOn="{TemplateBinding IsOn, Mode=TwoWay}"
Enabled="{TemplateBinding IsEnabled}"/>
Enabled="{TemplateBinding IsEnabled}" />
<wasm:TextBlock Text="Not yet supported" />
</ControlTemplate>
</Setter.Value>
Expand All @@ -43,10 +49,10 @@
xamarin:Style="{StaticResource UmbrellaToggleSwitchStyle}"
IsOn="{Binding [IsOn], Mode=TwoWay}" />
<TextBlock Foreground="Blue">
<Run Text="(TextBlock) ToggleSwitch IsOn: "/><Run Text="{Binding [IsOn]}"/>
<Run Text="(TextBlock) ToggleSwitch IsOn: " /><Run Text="{Binding [IsOn]}" />
</TextBlock>
<Button Command="{Binding [Flip]}"
Content="Flip the Switch"/>
Content="Flip the Switch" />
</StackPanel>
</DataTemplate>
</controls:SampleControl.SampleContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Page.Resources>
<ResourceDictionary>

<SolidColorBrush x:Key="LightGreyBrush"
Color="#000000"
Opacity="0.38" />
</ResourceDictionary>
</Page.Resources>


<StackPanel Spacing="5">
<TextBlock FontSize="22">This is an ellipse</TextBlock>
<Ellipse x:Name="ellipse0" Stroke="Black" Height="125" Width="150" StrokeThickness="5" HorizontalAlignment="Left"/>
Expand All @@ -22,22 +32,55 @@
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Width="175" Height="125">
<Rectangle StrokeDashArray="2.5,1" Stroke="Brown" StrokeThickness="3" />
<Ellipse Width="175" Height="125" Fill="DarkSalmon" x:Name="ellipse1" />
<Grid Grid.Column="0"
Width="175"
Height="125">
<Rectangle StrokeDashArray="2.5,1"
Stroke="Brown"
StrokeThickness="3" />
<Ellipse Width="175"
Height="125"
Fill="DarkSalmon"
x:Name="ellipse1" />
</Grid>
<Grid Grid.Column="2" Width="175" Height="125">
<Rectangle StrokeDashArray="2.5,1" Stroke="Brown" StrokeThickness="3" />
<Ellipse Fill="DarkSalmon" x:Name="ellipse2" />
<Grid Grid.Column="2"
Width="175"
Height="125">
<Rectangle StrokeDashArray="2.5,1"
Stroke="Brown"
StrokeThickness="3" />
<Ellipse Fill="DarkSalmon"
x:Name="ellipse2" />
</Grid>
<Grid Grid.Column="4">
<Rectangle StrokeDashArray="2.5,1" Stroke="Brown" StrokeThickness="3" />
<Ellipse Height="125" Fill="DarkSalmon" x:Name="ellipse3" />
<Rectangle StrokeDashArray="2.5,1"
Stroke="Brown"
StrokeThickness="3" />
<Ellipse Height="125"
Fill="DarkSalmon"
x:Name="ellipse3" />
</Grid>
<Grid Grid.Column="6" MaxWidth="175" HorizontalAlignment="Left">
<Rectangle StrokeDashArray="2.5,1" Stroke="Brown" StrokeThickness="3" />
<Ellipse Height="125" Fill="DarkGreen" x:Name="ellipse4" />
<Grid Grid.Column="6"
MaxWidth="175"
HorizontalAlignment="Left">
<Rectangle StrokeDashArray="2.5,1"
Stroke="Brown"
StrokeThickness="3" />
<Ellipse Height="125"
Fill="DarkGreen"
x:Name="ellipse4" />
</Grid>
</Grid>

<TextBlock FontSize="22">This is an ellipse that has a fill with opacity</TextBlock>
<Ellipse x:Name="ellipse5"
Stroke="Black"
Height="125"
Width="150"
StrokeThickness="5"
HorizontalAlignment="Left" />

<TextBlock FontSize="22">This is an ellipse that has a stroke opacity</TextBlock>
<Ellipse x:Name="ellipse6" Stroke="Black" Height="125" Width="150" StrokeThickness="5" HorizontalAlignment="Left"/>
</StackPanel>
</Page>
4 changes: 2 additions & 2 deletions src/Uno.UI/Controls/BindableSwitchCompat.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void OnThumbTintChanged(Brush newValue)
{
if (newValue is SolidColorBrush asColorBrush)
{
ThumbDrawable?.SetColorFilter(asColorBrush.Color, PorterDuff.Mode.SrcIn);
ThumbDrawable?.SetColorFilter(asColorBrush.ColorWithOpacity, PorterDuff.Mode.SrcIn);
}
}

Expand All @@ -100,7 +100,7 @@ private void OnTrackTintChanged(Brush newValue)
{
if (newValue is SolidColorBrush asColorBrush)
{
TrackDrawable?.SetColorFilter(asColorBrush.Color, PorterDuff.Mode.SrcIn);
TrackDrawable?.SetColorFilter(asColorBrush.ColorWithOpacity, PorterDuff.Mode.SrcIn);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ partial void OnFillUpdatedPartial()
switch (fill)
{
case SolidColorBrush scb:
svgElement.SetStyle("fill", scb.Color.ToHexString());
svgElement.SetStyle("fill", scb.ColorWithOpacity.ToHexString());
_fillBrushSubscription.Disposable = null;
break;
case ImageBrush ib:
Expand Down Expand Up @@ -115,7 +115,7 @@ partial void OnStrokeUpdatedPartial()
switch (Stroke)
{
case SolidColorBrush scb:
svgElement.SetStyle("stroke", scb.Color.ToHexString());
svgElement.SetStyle("stroke", scb.ColorWithOpacity.ToHexString());
_strokeBrushSubscription.Disposable = null;
break;
case LinearGradientBrush lgb:
Expand Down

0 comments on commit ff059c3

Please sign in to comment.