Skip to content
This repository has been archived by the owner on Apr 15, 2021. It is now read-only.

Commit

Permalink
Extract avatars to separate controls
Browse files Browse the repository at this point in the history
  • Loading branch information
x2bool committed Jan 7, 2019
1 parent 4ac881a commit d1e362a
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 236 deletions.
141 changes: 12 additions & 129 deletions src/Tel.Egram.Gui.Views/Messenger/Catalog/EntryControl.xaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
<UserControl
xmlns="https://github.com/avaloniaui">
xmlns="https://github.com/avaloniaui"
xmlns:shared="clr-namespace:Tel.Egram.Gui.Views.Shared">

<Grid
ColumnDefinitions="auto,*,auto">

<Border
Grid.ColumnSpan="3"/>

<Panel
Grid.ColumnSpan="3" />
<shared:AvatarControl
DataContext="{Binding Avatar}"
Classes="Icon"
Grid.Column="0">

<Ellipse
IsVisible="{Binding IsFallback}"
Fill="{Binding Brush}"
Width="22"
Height="22" />

<TextBlock
IsVisible="{Binding IsFallback}"
Text="{Binding Label}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#ffffff" />

<Image
Source="{Binding Bitmap}"
Width="22"
Height="22" >

<Image.Clip>
<EllipseGeometry Rect="0,0,22,22" />
</Image.Clip>

</Image>

</Panel>
Grid.Row="0"
Grid.Column="0"
Source="{Binding Bitmap}"
Color="{Binding Color}"
TextColor="{Binding TextColor}"
Text="{Binding Label}"
Size="22" />

<Panel
Classes="Title"
Expand Down Expand Up @@ -70,101 +50,4 @@

</Grid>

<!-- <UserControl.Styles> -->
<!-- -->
<!-- <Style Selector="TextBox"> -->
<!-- <Setter Property="Height" Value="28" /> -->
<!-- <Setter Property="Margin" Value="10,4,0,0" /> -->
<!-- <Setter Property="BorderThickness" Value="1" /> -->
<!-- <Setter Property="Foreground" Value="#ffffff" /> -->
<!-- <Setter Property="Background" Value="#1b2333" /> -->
<!-- <Setter Property="BorderBrush" Value="#3a455a" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="TextBox /template/ Border"> -->
<!-- <Setter Property="CornerRadius" Value="4" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="Button"> -->
<!-- <Setter Property="Width" Value="26" /> -->
<!-- <Setter Property="Height" Value="26" /> -->
<!-- <Setter Property="Margin" Value="6,4,6,0" /> -->
<!-- <Setter Property="Padding" Value="0" /> -->
<!-- <Setter Property="Background" Value="Transparent" /> -->
<!-- <Setter Property="BorderThickness" Value="0" /> -->
<!-- <Setter Property="BorderBrush" Value="Transparent" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="Button Image"> -->
<!-- <Setter Property="Width" Value="14" /> -->
<!-- <Setter Property="Height" Value="14" /> -->
<!-- <Setter Property="Opacity" Value="0.8" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="Button Ellipse"> -->
<!-- <Setter Property="Width" Value="20" /> -->
<!-- <Setter Property="Height" Value="20" /> -->
<!-- <Setter Property="Fill" Value="#435270" /> -->
<!-- <Setter Property="Opacity" Value="0.8" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBox"> -->
<!-- <Setter Property="BorderThickness" Value="0" /> -->
<!-- <Setter Property="Margin" Value="0"/> -->
<!-- <Setter Property="Padding" Value="0"/> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem"> -->
<!-- <Setter Property="Padding" Value="0"/> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem:selected /template/ ContentPresenter"> -->
<!-- <Setter Property="Background" Value="Transparent" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem:pointerover /template/ ContentPresenter"> -->
<!-- <Setter Property="Background" Value="Transparent" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem Grid"> -->
<!-- <Setter Property="Margin" Value="6,2,0,2"/> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem Grid > Border"> -->
<!-- <Setter Property="CornerRadius" Value="14,0,0,14" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem:selected Grid > Border"> -->
<!-- <Setter Property="Background" Value="#435270" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem Panel"> -->
<!-- <Setter Property="Margin" Value="4,3,8,3"/> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem TextBlock"> -->
<!-- <Setter Property="Foreground" Value="#92a3b3"/> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem:selected TextBlock"> -->
<!-- <Setter Property="Foreground" Value="#ffffff"/> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem Panel.Indicator > Border"> -->
<!-- <Setter Property="Margin" Value="0,2" /> -->
<!-- <Setter Property="Padding" Value="6,0" /> -->
<!-- <Setter Property="Background" Value="#435270" /> -->
<!-- <Setter Property="CornerRadius" Value="8" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem Panel.Indicator > Border > TextBlock"> -->
<!-- <Setter Property="FontSize" Value="11" /> -->
<!-- </Style> -->
<!-- -->
<!-- <Style Selector="ListBoxItem:selected Panel.Indicator > Border"> -->
<!-- <Setter Property="Background" Value="#242e44" /> -->
<!-- </Style> -->
<!-- -->
<!-- </UserControl.Styles> -->

</UserControl>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ContentControl
xmlns="https://github.com/avaloniaui"
xmlns:shared="clr-namespace:Tel.Egram.Gui.Views.Messenger.Explorer.Messages.Shared">
xmlns:shared="clr-namespace:Tel.Egram.Gui.Views.Messenger.Explorer.Messages.Shared"
xmlns:shared1="clr-namespace:Tel.Egram.Gui.Views.Shared">

<ContentControl.Styles>

Expand All @@ -13,40 +14,18 @@
ColumnDefinitions="auto,*,auto"
Margin="8,0,8,0">

<Panel
<shared1:AvatarControl
DataContext="{Binding Avatar}"
Classes="Avatar"
VerticalAlignment="Top"
Margin="8,8,8,0"
Grid.Row="0"
Grid.Column="0"
Grid.RowSpan="3"
VerticalAlignment="Top"
Margin="8,8,8,0">

<Ellipse
IsVisible="{Binding IsFallback}"
Fill="{Binding Brush}"
Width="32"
Height="32" />

<TextBlock
IsVisible="{Binding IsFallback}"
Text="{Binding Label}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#ffffff" />

<Image
Source="{Binding Bitmap}"
Width="32"
Height="32" >

<Image.Clip>
<EllipseGeometry Rect="0,0,32,32" />
</Image.Clip>

</Image>

</Panel>
Source="{Binding Bitmap}"
Color="{Binding Color}"
TextColor="{Binding TextColor}"
Text="{Binding Label}"
Size="32" />

<Border
Grid.Row="0"
Expand Down
41 changes: 10 additions & 31 deletions src/Tel.Egram.Gui.Views/Messenger/Informer/InformerControl.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<UserControl
xmlns="https://github.com/avaloniaui">
xmlns="https://github.com/avaloniaui"
xmlns:shared="clr-namespace:Tel.Egram.Gui.Views.Shared">

<Grid
Width="516"
Expand All @@ -11,38 +12,16 @@
Grid.ColumnSpan="3"
Grid.RowSpan="2" />

<Panel
<shared:AvatarControl
DataContext="{Binding Avatar}"
Classes="Avatar"
Margin="8,0,0,0"
Margin="16,0,8,0"
Grid.Column="0"
Grid.RowSpan="2">

<Ellipse
IsVisible="{Binding IsFallback}"
Fill="{Binding Brush}"
Width="32"
Height="32" />

<TextBlock
IsVisible="{Binding IsFallback}"
Text="{Binding Label}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#ffffff" />

<Image
Source="{Binding Bitmap}"
Width="32"
Height="32" >

<Image.Clip>
<EllipseGeometry Rect="0,0,32,32" />
</Image.Clip>

</Image>

</Panel>
Grid.RowSpan="2"
Source="{Binding Bitmap}"
Color="{Binding Color}"
TextColor="{Binding TextColor}"
Text="{Binding Label}"
Size="32" />

<TextBlock
Grid.Column="1"
Expand Down
37 changes: 37 additions & 0 deletions src/Tel.Egram.Gui.Views/Shared/AvatarControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<ContentControl
xmlns="https://github.com/avaloniaui"
xmlns:shared="clr-namespace:Tel.Egram.Gui.Views.Shared">

<ContentControl.Styles>

<Style Selector="shared|AvatarControl">
<Setter Property="Template">
<ControlTemplate>

<Panel>

<Ellipse
Width="{TemplateBinding Size}"
Height="{TemplateBinding Size}"
Fill="{TemplateBinding ColorBrush}" />

<TextBlock
Text="{TemplateBinding Text}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{TemplateBinding TextColorBrush}" />

<Ellipse
Width="{TemplateBinding Size}"
Height="{TemplateBinding Size}"
Fill="{TemplateBinding SourceBrush}"/>

</Panel>

</ControlTemplate>
</Setter>
</Style>

</ContentControl.Styles>

</ContentControl>
Loading

0 comments on commit d1e362a

Please sign in to comment.