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

Convert Color properties into Brush properties #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
75 changes: 49 additions & 26 deletions src/TemplateUI.Gallery/Views/AvatarViewGallery.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
BarBackgroundColor="{StaticResource NavBarBackgroundColor}"
BarTextColor="White"
Title="AvatarView Gallery">
<TabbedPage.Resources>
<ResourceDictionary>

<LinearGradientBrush
x:Key="BorderGradient"
StartPoint="0,0"
EndPoint="1,1">
<GradientStop
Color="Yellow"
Offset="0.0" />
<GradientStop
Color="Red"
Offset="0.25" />
<GradientStop
Color="Blue"
Offset="0.75" />
<GradientStop
Color="LimeGreen"
Offset="1.0" />
</LinearGradientBrush>

</ResourceDictionary>
</TabbedPage.Resources>
<ContentPage
Title="Getting Started"
IconImageSource="started.png">
Expand All @@ -16,29 +39,29 @@
<controls:AvatarView
AvatarName="Javier"
AvatarSurName="Suarez"
BorderColor="Black"
BackgroundColor="Red"/>
BorderBrush="Black"
Background="Red"/>
<Label
Text="Using Initials (Ellipse)"/>
<controls:AvatarView
AvatarShape="Square"
AvatarName="Javier"
AvatarSurName="Suarez"
BorderColor="Black"
BackgroundColor="Red"/>
BorderBrush="Black"
Background="Red"/>
<Label
Text="Using Initials (Square)"/>
<controls:AvatarView
ImageSource="javier.jpg"
BorderColor="Black"
BackgroundColor="Red"/>
BorderBrush="Black"
Background="Red"/>
<Label
Text="Using an Image (Ellipse)"/>
<controls:AvatarView
AvatarShape="Square"
ImageSource="javier.jpg"
BorderColor="Black"
BackgroundColor="Red"/>
BorderBrush="Black"
Background="Red"/>
<Label
Text="Using an Image (Square)"/>
</StackLayout>
Expand All @@ -63,7 +86,7 @@
</Grid.RowDefinitions>
<StackLayout>
<controls:AvatarView
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="ExtraSmall"/>
Expand All @@ -74,7 +97,7 @@
Grid.Column="1">
<controls:AvatarView
AvatarShape="Square"
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="ExtraSmall"/>
Expand All @@ -84,7 +107,7 @@
<StackLayout
Grid.Row="1">
<controls:AvatarView
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="Small"/>
Expand All @@ -96,7 +119,7 @@
Grid.Row="1">
<controls:AvatarView
AvatarShape="Square"
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="Small"/>
Expand All @@ -106,7 +129,7 @@
<StackLayout
Grid.Row="2">
<controls:AvatarView
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="Medium"/>
Expand All @@ -118,7 +141,7 @@
Grid.Row="2">
<controls:AvatarView
AvatarShape="Square"
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="Medium"/>
Expand All @@ -128,7 +151,7 @@
<StackLayout
Grid.Row="3">
<controls:AvatarView
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="Large"/>
Expand All @@ -140,7 +163,7 @@
Grid.Row="3">
<controls:AvatarView
AvatarShape="Square"
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="Large"/>
Expand All @@ -150,7 +173,7 @@
<StackLayout
Grid.Row="4">
<controls:AvatarView
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="ExtraLarge"/>
Expand All @@ -162,7 +185,7 @@
Grid.Row="4">
<controls:AvatarView
AvatarShape="Square"
BackgroundColor="Orange"
Background="Orange"
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarSize="ExtraLarge"/>
Expand Down Expand Up @@ -190,8 +213,8 @@
<controls:AvatarView
AvatarName="Javier"
AvatarSurName="Suarez"
BackgroundColor="Red"
BorderColor="Orange"
Background="Red"
BorderBrush="{StaticResource BorderGradient}"
BorderWidth="3"/>
<Label
Text="BorderWidth (Circle)"/>
Expand All @@ -202,8 +225,8 @@
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarShape="Square"
BackgroundColor="Red"
BorderColor="Orange"
Background="Red"
BorderBrush="{StaticResource BorderGradient}"
BorderWidth="3"/>
<Label
Text="BorderWidth (Square)"/>
Expand All @@ -213,8 +236,8 @@
<controls:AvatarView
AvatarName="Javier"
AvatarSurName="Suarez"
BorderColor="Black"
BackgroundColor="Red"
BorderBrush="Black"
Background="Red"
HeightRequest="100"
WidthRequest="100"/>
<Label
Expand All @@ -227,8 +250,8 @@
AvatarName="Javier"
AvatarSurName="Suarez"
AvatarShape="Square"
BorderColor="Black"
BackgroundColor="Red"
BorderBrush="Black"
Background="Red"
HeightRequest="100"
WidthRequest="100"/>
<Label
Expand Down
29 changes: 26 additions & 3 deletions src/TemplateUI.Gallery/Views/DataVisualizationGallery.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,37 @@
BarBackgroundColor="{StaticResource NavBarBackgroundColor}"
BarTextColor="White"
Title="DataVisualization Gallery">
<TabbedPage.Resources>
<ResourceDictionary>

<LinearGradientBrush
x:Key="DataVisualizationGradient"
StartPoint="0,0"
EndPoint="1,1">
<GradientStop
Color="Yellow"
Offset="0.0" />
<GradientStop
Color="Red"
Offset="0.25" />
<GradientStop
Color="Blue"
Offset="0.75" />
<GradientStop
Color="LimeGreen"
Offset="1.0" />
</LinearGradientBrush>

</ResourceDictionary>
</TabbedPage.Resources>
<ContentPage
Title="Line Chart">
<StackLayout
Padding="12">
<datavisualization:LineChart
HeightRequest="200"
Title="Line Chart"
Color="OrangeRed"
Brush="OrangeRed"
CategoryMemberPath="Title"
ValueMemberPath="Value"
DataSource="{Binding Data}"/>
Expand All @@ -27,7 +50,7 @@
<datavisualization:AreaChart
HeightRequest="200"
Title="Area Chart"
Color="LawnGreen"
Brush="{StaticResource DataVisualizationGradient}"
CategoryMemberPath="Title"
ValueMemberPath="Value"
DataSource="{Binding Data}"/>
Expand All @@ -40,7 +63,7 @@
<datavisualization:BarChart
HeightRequest="200"
Title="Bar Chart"
Color="BlueViolet"
Brush="BlueViolet"
CategoryMemberPath="Title"
ValueMemberPath="Value"
DataSource="{Binding Data}"/>
Expand Down
20 changes: 10 additions & 10 deletions src/TemplateUI/Controls/AvatarView/AvatarView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ public string AvatarSurName
set => SetValue(AvatarSurNameProperty, value);
}

public static new readonly BindableProperty BackgroundColorProperty =
BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(AvatarView), Color.Default);
public static new readonly BindableProperty BackgroundProperty =
BindableProperty.Create(nameof(Background), typeof(Brush), typeof(AvatarView), Brush.Default);

public new Color BackgroundColor
public new Brush Background
{
get => (Color)GetValue(BackgroundColorProperty);
set => SetValue(BackgroundColorProperty, value);
get => (Brush)GetValue(BackgroundProperty);
set => SetValue(BackgroundProperty, value);
}

public static readonly BindableProperty BorderColorProperty =
BindableProperty.Create(nameof(BorderColor), typeof(Color), typeof(AvatarView), Color.Default);
public static readonly BindableProperty BorderBrushProperty =
BindableProperty.Create(nameof(BorderBrush), typeof(Brush), typeof(AvatarView), Brush.Default);

public Color BorderColor
public Brush BorderBrush
{
get => (Color)GetValue(BorderColorProperty);
set => SetValue(BorderColorProperty, value);
get => (Brush)GetValue(BorderBrushProperty);
set => SetValue(BorderBrushProperty, value);
}

public static readonly BindableProperty BorderWidthProperty =
Expand Down
10 changes: 5 additions & 5 deletions src/TemplateUI/DataVisualization/AreaChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void InitializeAreaChart()
_areaChart = new Polygon
{
Aspect = Stretch.Fill,
Fill = new SolidColorBrush(Color),
Stroke = new SolidColorBrush(Color),
Fill = Brush,
Stroke = Brush,
StrokeThickness = 2
};
}
Expand All @@ -117,10 +117,10 @@ public override void UpdateDataSource()
UpdateCategoryData();
}

public override void UpdateColor()
public override void UpdateBrush()
{
_areaChart.Stroke = new SolidColorBrush(Color);
_areaChart.Fill = new SolidColorBrush(Color);
_areaChart.Stroke = Brush;
_areaChart.Fill = Brush;
}

void UpdateValueData()
Expand Down
10 changes: 5 additions & 5 deletions src/TemplateUI/DataVisualization/BarChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ void InitializeBarChart()
_barChart = new Path
{
Aspect = Stretch.Fill,
Stroke = new SolidColorBrush(Color),
Fill = new SolidColorBrush(Color),
Stroke = Brush,
Fill = Brush,
StrokeThickness = 1,
Margin = new Thickness(24, 0)
};
Expand All @@ -134,10 +134,10 @@ public override void UpdateDataSource()
UpdateCategoryData();
}

public override void UpdateColor()
public override void UpdateBrush()
{
_barChart.Stroke = new SolidColorBrush(Color);
_barChart.Fill = new SolidColorBrush(Color);
_barChart.Stroke = Brush;
_barChart.Fill = Brush;
}

void UpdateValueData()
Expand Down
22 changes: 11 additions & 11 deletions src/TemplateUI/DataVisualization/Base/SerialChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,28 @@ public Color AxisColor
set { SetValue(AxisColorProperty, value); }
}

public static readonly BindableProperty ColorProperty =
BindableProperty.Create(nameof(Color), typeof(Color), typeof(SerialChart), Color.Black,
propertyChanged: OnColorPropertyChanged);
public static readonly BindableProperty BrushProperty =
BindableProperty.Create(nameof(Brush), typeof(Brush), typeof(SerialChart), new SolidColorBrush(Color.Black),
propertyChanged: OnBrushPropertyChanged);

static void OnColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
static void OnBrushPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
SerialChart chart = bindable as SerialChart;
chart.NotifyColorChanges();
chart.NotifyBrushChanges();
}

public Color Color
public Brush Brush
{
get { return (Color)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
get { return (Brush)GetValue(BrushProperty); }
set { SetValue(BrushProperty, value); }
}

public virtual void UpdateDataSource()
{

}

public virtual void UpdateColor()
public virtual void UpdateBrush()
{

}
Expand All @@ -108,9 +108,9 @@ void NotifyDataSourceChanges()
UpdateDataSource();
}

void NotifyColorChanges()
void NotifyBrushChanges()
{
UpdateColor();
UpdateBrush();
}
}
}
Loading