Skip to content

Commit

Permalink
Improve call header on Windows 10
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Oct 9, 2024
1 parent 021e6ff commit 8659c2f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
19 changes: 19 additions & 0 deletions Telegram/Common/ColorsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@
//
using System;
using Windows.UI;
using Windows.UI.Xaml.Media;

namespace Telegram.Common
{
// ColorHelper is a set of color conversion utilities
public static class ColorsHelper
{
public static LinearGradientBrush LinearGradient(params uint[] colorStops)
{
var linear = new LinearGradientBrush();
linear.StartPoint = new Windows.Foundation.Point(0, 0);
linear.EndPoint = new Windows.Foundation.Point(1, 0);

for (int i = 0; i < colorStops.Length; i++)
{
linear.GradientStops.Add(new GradientStop
{
Offset = i / (colorStops.Length - 1f),
Color = ColorEx.FromHex(colorStops[i])
});
}

return linear;
}

public static Color Mix(Color x, Color y, double amount)
{
static double Mix(double x, double y, double f)
Expand Down
5 changes: 2 additions & 3 deletions Telegram/Controls/GroupCallActiveHeader.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Background="{ThemeResource SettingsItemBackground}"
CornerRadius="8,0,0,0" />
<Border x:Name="RootGrid"
Background="{ThemeResource SettingsItemBackground}" />

<Border x:Name="Curve"
SizeChanged="Curve_SizeChanged"
CornerRadius="8,0,0,0"
Grid.RowSpan="2" />

<HyperlinkButton Click="Title_Click"
Expand Down
21 changes: 18 additions & 3 deletions Telegram/Controls/GroupCallActiveHeader.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Telegram.Td.Api;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

namespace Telegram.Controls
{
Expand Down Expand Up @@ -96,13 +97,27 @@ public void Update(VoipCallBase value)
private void UpdateCurveColors(bool muted)
{
// TODO: there are multiple states to be supported: connecting, active, speaking, can't speak, late
if (muted)
if (PowerSavingPolicy.AreMaterialsEnabled && ApiInfo.CanAnimatePaths)
{
_curveVisual.SetColorStops(0xFF59c7f8, 0xFF0078ff);
if (muted)
{
_curveVisual.SetColorStops(0xFF59c7f8, 0xFF0078ff);
}
else
{
_curveVisual.SetColorStops(0xFF0078ff, 0xFF33c659);
}
}
else
{
_curveVisual.SetColorStops(0xFF0078ff, 0xFF33c659);
if (muted)
{
RootGrid.Background = ColorsHelper.LinearGradient(0xFF59c7f8, 0xFF0078ff);
}
else
{
RootGrid.Background = ColorsHelper.LinearGradient(0xFF0078ff, 0xFF33c659);
}
}
}

Expand Down

0 comments on commit 8659c2f

Please sign in to comment.