Skip to content

Commit e932f82

Browse files
committed
Simplify gift pattern background
1 parent 89603a4 commit e932f82

13 files changed

+187
-605
lines changed

Telegram/Controls/Cells/ReceivedGiftCell.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
CornerRadius="4"
2828
Grid.RowSpan="2" />
2929
<controls:PatternBackground x:Name="Pattern"
30-
ScaleXY="0.6"
3130
BorderBrush="{ThemeResource SettingsItemBorderBrush}"
3231
BorderThickness="1"
3332
CornerRadius="4"
34-
Grid.RowSpan="2" />
33+
Grid.RowSpan="2">
34+
<Border Width="88" />
35+
</controls:PatternBackground>
3536

3637
<controls:ProfilePicture x:Name="Photo"
3738
Width="24"
@@ -228,7 +229,9 @@
228229
<Path x:Name="RibbonPath"
229230
Data="M59.6569 31.1569L30.8431 2.34315C29.3429 0.842855 27.308 0 25.1863 0H2.82843C1.04662 0 0.154282 2.15428 1.41421 3.41421L58.5858 60.5858C59.8457 61.8457 62 60.9534 62 59.1716V36.8137C62 34.692 61.1571 32.6571 59.6569 31.1569Z">
230231
<Path.Fill>
231-
<LinearGradientBrush x:Name="RibbonGradient">
232+
<LinearGradientBrush x:Name="RibbonGradient"
233+
StartPoint="0,0"
234+
EndPoint="1,1">
232235
<GradientStop x:Name="RibbonTop"
233236
Color="#6ED2FF"
234237
Offset="0" />

Telegram/Controls/Cells/ReceivedGiftCell.xaml.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ public void UpdateGift(IClientService clientService, ReceivedGift gift)
9090
}
9191
else if (gift.Gift is SentGiftUpgraded upgraded)
9292
{
93-
var source = DelayedFileSource.FromSticker(clientService, upgraded.Gift.Symbol.Sticker);
9493
var centerColor = upgraded.Gift.Backdrop.Colors.CenterColor.ToColor();
9594
var edgeColor = upgraded.Gift.Backdrop.Colors.EdgeColor.ToColor();
9695

97-
Pattern.Update(source, centerColor, edgeColor);
96+
Pattern.Update(clientService, upgraded.Gift);
9897

9998
if (gift.IsPinned)
10099
{
@@ -139,8 +138,8 @@ public void UpdateGift(IClientService clientService, ReceivedGift gift)
139138
{
140139
Ribbon.Text = string.Format(Strings.Gift2Limited1OfRibbon, Formatter.ShortNumber(upgraded.Gift.MaxUpgradedCount, true));
141140

142-
RibbonTop.Color = centerColor.WithBrightness(-0.1f);
143-
RibbonBottom.Color = edgeColor.WithBrightness(-0.1f);
141+
RibbonTop.Color = centerColor.WithBrightness(-0.2f);
142+
RibbonBottom.Color = edgeColor.WithBrightness(-0.2f);
144143

145144
if (ResaleStarCountRoot != null)
146145
{
@@ -167,11 +166,7 @@ public void UpdateGift(IClientService clientService, GiftForResale gift)
167166
{
168167
StarCountRoot.Visibility = Visibility.Collapsed;
169168

170-
var source = DelayedFileSource.FromSticker(clientService, gift.Gift.Symbol.Sticker);
171-
var centerColor = gift.Gift.Backdrop.Colors.CenterColor.ToColor();
172-
var edgeColor = gift.Gift.Backdrop.Colors.EdgeColor.ToColor();
173-
174-
Pattern.Update(source, centerColor, edgeColor);
169+
Pattern.Update(clientService, gift.Gift);
175170

176171
Pinned.Visibility = Visibility.Collapsed;
177172

@@ -180,15 +175,18 @@ public void UpdateGift(IClientService clientService, GiftForResale gift)
180175

181176
Animated.Source = new DelayedFileSource(clientService, gift.Gift.Model.Sticker);
182177

178+
var centerColor = gift.Gift.Backdrop.Colors.CenterColor.ToColor();
179+
var edgeColor = gift.Gift.Backdrop.Colors.EdgeColor.ToColor();
180+
183181
FindName(nameof(ResaleStarCountRoot));
184182
ResaleStarCountRoot.Background = new SolidColorBrush(edgeColor.WithBrightness(-0.1f));
185183
ResaleStarCount.Text = gift.Gift.ResaleStarCount.ToString("N0");
186184

187185
RibbonRoot.Visibility = Visibility.Visible;
188186
Ribbon.Text = string.Format("#{0:N0}", gift.Gift.Number);
189187

190-
RibbonTop.Color = centerColor.WithBrightness(-0.1f);
191-
RibbonBottom.Color = edgeColor.WithBrightness(-0.1f);
188+
RibbonTop.Color = centerColor.WithBrightness(-0.2f);
189+
RibbonBottom.Color = edgeColor.WithBrightness(-0.2f);
192190
}
193191

194192
private readonly Color _ribbonResaleTop = Color.FromArgb(0xFF, 0xAC, 0xDC, 0x89);

Telegram/Controls/Messages/MessageService.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,17 @@ private void UpdateContent(MessageViewModel message)
235235
return;
236236
}
237237

238-
var pattern = FindName("Pattern") as PatternBackground;
239-
240-
var source = DelayedFileSource.FromSticker(message.ClientService, upgradedGift.Gift.Symbol.Sticker);
241238
var centerColor = upgradedGift.Gift.Backdrop.Colors.CenterColor.ToColor();
242239
var edgeColor = upgradedGift.Gift.Backdrop.Colors.EdgeColor.ToColor();
243240

244-
pattern.Update(source, centerColor, edgeColor);
241+
var ribbonTop = FindName("RibbonTop") as GradientStop;
242+
var ribbonBottom = FindName("RibbonBottom") as GradientStop;
243+
244+
ribbonTop.Color = centerColor.WithBrightness(-0.2f);
245+
ribbonBottom.Color = edgeColor.WithBrightness(-0.2f);
246+
247+
var pattern = FindName("Pattern") as PatternBackground;
248+
pattern.Update(message.ClientService, upgradedGift.Gift);
245249

246250
var animation = FindName("Animation") as AnimatedImage;
247251
animation.Source = DelayedFileSource.FromSticker(message.ClientService, upgradedGift.Gift.Model.Sticker);

Telegram/Controls/PatternBackground.xaml

Lines changed: 7 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,6 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
mc:Ignorable="d">
77

8-
<Style x:Key="ProfileHeaderPatternStyle"
9-
TargetType="controls:ProfileHeaderPattern">
10-
<Setter Property="Template">
11-
<Setter.Value>
12-
<ControlTemplate TargetType="controls:ProfileHeaderPattern">
13-
<Grid Width="1000"
14-
Height="320">
15-
<Border x:Name="LayoutRoot" />
16-
<controls:AnimatedImage x:Name="Animated"
17-
FrameSize="36,36"
18-
DecodeFrameType="Logical"
19-
AutoPlay="False"
20-
IsViewportAware="False"
21-
ReplacementColor="{TemplateBinding Foreground}"
22-
Source="{TemplateBinding Source}"
23-
HorizontalAlignment="Center"
24-
VerticalAlignment="Center"
25-
Width="36"
26-
Height="36"
27-
Opacity="0"
28-
IsTabStop="False" />
29-
</Grid>
30-
</ControlTemplate>
31-
</Setter.Value>
32-
</Setter>
33-
</Style>
34-
358
<Style TargetType="controls:PatternBackground">
369
<!--<Setter Property="BorderBrush"
3710
Value="{ThemeResource CardStrokeColorDefaultBrush}" />
@@ -59,31 +32,15 @@
5932
<RowDefinition Height="Auto" />
6033
</Grid.RowDefinitions>
6134

62-
<Border x:Name="HeaderGlow"
63-
Width="1000"
64-
Height="320"
65-
Margin="-500,0,-500,-200"
66-
RenderTransformOrigin="0.5,0.0"
67-
VerticalAlignment="Top"
68-
Grid.RowSpan="2">
69-
<Border.RenderTransform>
70-
<ScaleTransform ScaleX="{Binding ScaleXY, RelativeSource={RelativeSource Mode=TemplatedParent}}"
71-
ScaleY="{Binding ScaleXY, RelativeSource={RelativeSource Mode=TemplatedParent}}" />
72-
</Border.RenderTransform>
73-
</Border>
74-
75-
<controls:ProfileHeaderPattern x:Name="Pattern"
76-
IsSmall="True"
77-
Margin="-500,0,-500,-200"
78-
Width="1000"
79-
Height="320"
80-
Opacity="0"
81-
Style="{StaticResource ProfileHeaderPatternStyle}"
82-
Grid.RowSpan="2" />
35+
<controls:ProfilePatternCover x:Name="Pattern"
36+
Opacity="0.4"
37+
Grid.RowSpan="2" />
8338

8439
<Grid HorizontalAlignment="Center"
85-
VerticalAlignment="Center">
86-
<ContentPresenter Content="{TemplateBinding Content}"
40+
VerticalAlignment="Center"
41+
Padding="{TemplateBinding Padding}">
42+
<ContentPresenter x:Name="ContentPresenter"
43+
Content="{TemplateBinding Content}"
8744
ContentTemplate="{TemplateBinding ContentTemplate}"
8845
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
8946
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
@@ -95,43 +52,6 @@
9552
VerticalAlignment="Bottom"
9653
HorizontalAlignment="Stretch"
9754
Grid.Row="1" />
98-
99-
<!--<Border VerticalAlignment="Bottom"
100-
HorizontalAlignment="Center"
101-
Grid.Row="1">
102-
<Grid x:Name="LabelTitle">
103-
<Grid.ColumnDefinitions>
104-
<ColumnDefinition Width="Auto" />
105-
<ColumnDefinition />
106-
<ColumnDefinition Width="Auto" />
107-
</Grid.ColumnDefinitions>
108-
<controls:CustomEmojiIcon x:Name="BotVerified"
109-
VerticalAlignment="Bottom"
110-
Margin="0,0,4,4" />
111-
112-
<TextBlock x:Name="Title"
113-
TextWrapping="NoWrap"
114-
TextTrimming="CharacterEllipsis"
115-
TextAlignment="Center"
116-
IsTextSelectionEnabled="True"
117-
Style="{StaticResource SubtitleTextBlockStyle}"
118-
FontFamily="{ThemeResource EmojiThemeFontFamily}"
119-
Grid.Column="1" />
120-
121-
<controls:IdentityIcon x:Name="Identity"
122-
VerticalAlignment="Bottom"
123-
Margin="4,0,0,4"
124-
Grid.Column="2" />
125-
</Grid>
126-
</Border>
127-
<Border VerticalAlignment="Top"
128-
Margin="0,-2,0,0"
129-
Grid.Row="2">
130-
<TextBlock x:Name="Subtitle"
131-
Style="{StaticResource BodyTextBlockStyle}"
132-
Foreground="{ThemeResource PageHeaderDisabledBrush}"
133-
TextAlignment="Center" />
134-
</Border>-->
13555
</Grid>
13656
</ControlTemplate>
13757
</Setter.Value>

0 commit comments

Comments
 (0)