Skip to content

Commit 647a360

Browse files
committed
Exp: profile page custom transition
1 parent 59d351d commit 647a360

File tree

7 files changed

+108
-2
lines changed

7 files changed

+108
-2
lines changed

Telegram/Controls/ProfileHeader.xaml.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using Windows.UI.Xaml.Hosting;
3737
using Windows.UI.Xaml.Input;
3838
using Windows.UI.Xaml.Media;
39+
using Windows.UI.Xaml.Media.Animation;
3940

4041
namespace Telegram.Controls
4142
{
@@ -48,7 +49,7 @@ public ProfileHeader()
4849
InitializeComponent();
4950
DescriptionLabel.AddHandler(ContextRequestedEvent, new TypedEventHandler<UIElement, ContextRequestedEventArgs>(About_ContextRequested), true);
5051

51-
HeaderRoot.CreateInsetClip();
52+
//HeaderRoot.CreateInsetClip();
5253

5354
ActualThemeChanged += OnActualThemeChanged;
5455
SizeChanged += OnSizeChanged;
@@ -71,6 +72,33 @@ private void OnSizeChanged(object sender, SizeChangedEventArgs e)
7172
}
7273
}
7374

75+
public void AnimateEntrance()
76+
{
77+
var service = ConnectedAnimationService.GetForCurrentView();
78+
79+
void Start(UIElement element, string key)
80+
{
81+
var animation = service.GetAnimation(key);
82+
if (animation != null)
83+
{
84+
animation.Configuration = new BasicConnectedAnimationConfiguration();
85+
animation.TryStart(element);
86+
}
87+
}
88+
89+
Start(HeaderPhoto, "Photo");
90+
Start(TitleRoot, "Title");
91+
Start(SubtitleRoot, "Subtitle");
92+
}
93+
94+
public void PrepareExit()
95+
{
96+
var service = ConnectedAnimationService.GetForCurrentView();
97+
service.PrepareToAnimate("Photo", HeaderPhoto);
98+
service.PrepareToAnimate("Title", TitleRoot);
99+
service.PrepareToAnimate("Subtitle", SubtitleRoot);
100+
}
101+
74102
public CompositionPropertySet Properties { get; }
75103

76104
public double OccludedHeight => ViewModel.IsSavedMessages ? 0 : HeaderRoot.ActualHeight - 48;

Telegram/Services/Settings/DiagnosticsSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ public bool VideoPreloadDebug
190190
set => AddOrUpdateValue(ref _videoPreloadDebug, "VideoPreloadDebug", value);
191191
}
192192

193+
private bool? _connectedAnimationsDebug;
194+
public bool ConnectedAnimationsDebug
195+
{
196+
get => _connectedAnimationsDebug ??= GetValueOrDefault("ConnectedAnimationsDebug", ApiInfo.IsPackagedRelease);
197+
set => AddOrUpdateValue(ref _connectedAnimationsDebug, "ConnectedAnimationsDebug", value);
198+
}
199+
193200
public bool IsLastErrorDiskFull { get; set; }
194201
}
195202
}

Telegram/Views/ChatPage.xaml.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
using Telegram.Common;
88
using Telegram.Navigation;
99
using Telegram.Navigation.Services;
10+
using Telegram.Services;
1011
using Telegram.ViewModels;
1112
using Telegram.ViewModels.Delegates;
1213
using Windows.UI.Composition;
14+
using Windows.UI.Xaml.Navigation;
1315

1416
namespace Telegram.Views
1517
{
@@ -43,6 +45,25 @@ public void Search()
4345
View.Search();
4446
}
4547

48+
protected override void OnNavigatedTo(NavigationEventArgs e)
49+
{
50+
if (PowerSavingPolicy.AreSmoothTransitionsEnabled && SettingsService.Current.Diagnostics.ConnectedAnimationsDebug)
51+
{
52+
View.AnimateEntrance();
53+
}
54+
}
55+
56+
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
57+
{
58+
if (PowerSavingPolicy.AreSmoothTransitionsEnabled && SettingsService.Current.Diagnostics.ConnectedAnimationsDebug && e.SourcePageType == typeof(ProfilePage) && ViewModel.NavigationService.TryGetChatFromParameter(e.Parameter, out ChatMessageTopic nextTopic))
59+
{
60+
if (ViewModel.Chat.Id == nextTopic.ChatId && ViewModel.TopicId.AreTheSame(nextTopic.MessageTopic))
61+
{
62+
View.PrepareExit();
63+
}
64+
}
65+
}
66+
4667
public void Deactivate(bool navigation)
4768
{
4869
View.Deactivate(navigation);

Telegram/Views/ChatView.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,8 @@
12761276
<RowDefinition Height="Auto" />
12771277
<RowDefinition Height="Auto" />
12781278
</Grid.RowDefinitions>
1279-
<Grid HorizontalAlignment="Left">
1279+
<Grid x:Name="TitleRoot"
1280+
HorizontalAlignment="Left">
12801281
<Grid.ColumnDefinitions>
12811282
<ColumnDefinition Width="Auto" />
12821283
<ColumnDefinition />

Telegram/Views/ChatView.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
using Windows.UI.Xaml.Hosting;
6060
using Windows.UI.Xaml.Input;
6161
using Windows.UI.Xaml.Media;
62+
using Windows.UI.Xaml.Media.Animation;
6263

6364
namespace Telegram.Views
6465
{
@@ -570,6 +571,33 @@ public void Activate(DialogViewModel viewModel)
570571
}
571572
}
572573

574+
public void AnimateEntrance()
575+
{
576+
var service = ConnectedAnimationService.GetForCurrentView();
577+
578+
void Start(string key, UIElement element)
579+
{
580+
var animation = service.GetAnimation(key);
581+
if (animation != null)
582+
{
583+
animation.Configuration = new BasicConnectedAnimationConfiguration();
584+
animation.TryStart(element);
585+
}
586+
}
587+
588+
Start("Photo", Photo);
589+
Start("Title", TitleRoot);
590+
Start("Subtitle", Subtitle);
591+
}
592+
593+
public void PrepareExit()
594+
{
595+
var service = ConnectedAnimationService.GetForCurrentView();
596+
service.PrepareToAnimate("Photo", Photo);
597+
service.PrepareToAnimate("Title", TitleRoot);
598+
service.PrepareToAnimate("Subtitle", Subtitle);
599+
}
600+
573601
public double HeaderHeight
574602
{
575603
get => SavedMessagesTabHeader.Height;

Telegram/Views/DiagnosticsPage.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
<CheckBox IsChecked="{x:Bind services:SettingsService.Current.Diagnostics.VideoPreloadDebug, Mode=TwoWay}"
9090
Content="Video Preload Debug"
9191
Style="{StaticResource SettingsCheckBoxStyle}" />
92+
93+
<CheckBox IsChecked="{x:Bind services:SettingsService.Current.Diagnostics.ConnectedAnimationsDebug, Mode=TwoWay}"
94+
Content="Connected Animations Debug"
95+
Style="{StaticResource SettingsCheckBoxStyle}" />
9296
</controls:HeaderedControl>
9397

9498
<controls:HeaderedControl>

Telegram/Views/ProfilePage.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Telegram.Converters;
1919
using Telegram.Navigation;
2020
using Telegram.Navigation.Services;
21+
using Telegram.Services;
2122
using Telegram.Streams;
2223
using Telegram.Td.Api;
2324
using Telegram.ViewModels;
@@ -144,6 +145,11 @@ public void OnBackRequested(BackRequestedRoutedEventArgs args)
144145

145146
protected override void OnNavigatedTo(NavigationEventArgs e)
146147
{
148+
if (PowerSavingPolicy.AreSmoothTransitionsEnabled && SettingsService.Current.Diagnostics.ConnectedAnimationsDebug)
149+
{
150+
ProfileHeader.AnimateEntrance();
151+
}
152+
147153
ViewModel.PropertyChanged += OnPropertyChanged;
148154

149155
if (ViewModel.SelectedItem is ProfileTabItem tab)
@@ -219,6 +225,17 @@ protected override void OnNavigatedFrom(NavigationEventArgs e)
219225
}
220226
}
221227

228+
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
229+
{
230+
if (PowerSavingPolicy.AreSmoothTransitionsEnabled && SettingsService.Current.Diagnostics.ConnectedAnimationsDebug && e.SourcePageType == typeof(ChatPage) && ViewModel.NavigationService.TryGetChatFromParameter(e.Parameter, out ChatMessageTopic nextTopic))
231+
{
232+
if (ViewModel.Chat.Id == nextTopic.ChatId && ViewModel.Topic.AreTheSame(nextTopic.MessageTopic))
233+
{
234+
ProfileHeader.PrepareExit();
235+
}
236+
}
237+
}
238+
222239
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
223240
{
224241
if (e.PropertyName.Equals("SharedCount") && ViewModel.SelectedItem is ProfileTabItem tab)

0 commit comments

Comments
 (0)