forked from UnigramDev/Unigram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
140233c
commit 8ad9b39
Showing
7 changed files
with
321 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<controls:ContentPopup x:Class="Telegram.Views.Popups.EmojiStatusPopup" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
xmlns:controls="using:Telegram.Controls" | ||
mc:Ignorable="d" | ||
Padding="24,0,24,24" | ||
IsDismissButtonVisible="True"> | ||
|
||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid Margin="0,24,0,0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<controls:AnimatedImage x:Name="Animated" | ||
Width="120" | ||
Height="120" | ||
FrameSize="120,120" | ||
DecodeFrameType="Logical" | ||
IsViewportAware="True" | ||
LoopCount="1" | ||
Margin="0,-16,0,8" /> | ||
|
||
<TextBlock x:Name="Title" | ||
Text="{CustomResource BotEmojiStatusTitle}" | ||
Style="{StaticResource PopupTextBlockStyle}" | ||
TextAlignment="Center" | ||
VerticalAlignment="Top" | ||
Grid.Row="1" /> | ||
<TextBlock x:Name="Subtitle" | ||
Style="{StaticResource BodyTextBlockStyle}" | ||
TextAlignment="Center" | ||
Margin="12,0,12,24" | ||
Grid.Row="2" /> | ||
|
||
<Grid Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" | ||
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" | ||
BorderThickness="1" | ||
HorizontalAlignment="Center" | ||
CornerRadius="14" | ||
Margin="0,0,0,24" | ||
Grid.Row="3"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<controls:ProfilePicture x:Name="Photo" | ||
Width="28" | ||
Height="28" /> | ||
|
||
<TextBlock x:Name="TitleText" | ||
Style="{StaticResource BodyTextBlockStyle}" | ||
FontFamily="{ThemeResource EmojiThemeFontFamily}" | ||
VerticalAlignment="Center" | ||
Margin="8,1,4,3" | ||
Grid.Column="1" /> | ||
|
||
<controls:CustomEmojiIcon x:Name="Status" | ||
Margin="0,0,8,0" | ||
Grid.Column="2" /> | ||
</Grid> | ||
|
||
</Grid> | ||
|
||
<Grid x:Name="PurchasePanel" | ||
VerticalAlignment="Bottom" | ||
HorizontalAlignment="Stretch" | ||
Grid.Row="1"> | ||
<controls:BadgeButton x:Name="PurchaseCommand" | ||
Click="Purchase_Click" | ||
Style="{StaticResource AccentButtonStyle}" | ||
HorizontalAlignment="Stretch" | ||
HorizontalContentAlignment="Center" | ||
FontWeight="SemiBold" | ||
BorderThickness="1" | ||
Height="32"> | ||
<Grid> | ||
<TextBlock x:Name="PurchaseText" | ||
Text="{CustomResource BotEmojiStatusConfirm}" | ||
VerticalAlignment="Center" | ||
Margin="0,3,0,5" /> | ||
<muxc:ProgressRing x:Name="PurchaseRing" | ||
Visibility="Collapsed" | ||
Foreground="#FFFFFF" | ||
Width="20" | ||
Height="20" /> | ||
</Grid> | ||
</controls:BadgeButton> | ||
</Grid> | ||
</Grid> | ||
</controls:ContentPopup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// | ||
// Copyright Fela Ameghino 2015-2024 | ||
// | ||
// Distributed under the GNU General Public License v3.0. (See accompanying | ||
// file LICENSE or copy at https://www.gnu.org/licenses/gpl-3.0.txt) | ||
// | ||
using System; | ||
using Telegram.Common; | ||
using Telegram.Controls; | ||
using Telegram.Controls.Media; | ||
using Telegram.Converters; | ||
using Telegram.Navigation; | ||
using Telegram.Navigation.Services; | ||
using Telegram.Services; | ||
using Telegram.Streams; | ||
using Telegram.Td.Api; | ||
using Telegram.Views.Popups; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Documents; | ||
using Windows.UI.Xaml.Hosting; | ||
using Windows.UI.Xaml.Media; | ||
|
||
namespace Telegram.Views.Popups | ||
{ | ||
public sealed partial class EmojiStatusPopup : ContentPopup | ||
{ | ||
private readonly IClientService _clientService; | ||
private readonly INavigationService _navigationService; | ||
|
||
private readonly StarTransaction _transaction; | ||
|
||
private readonly long _customEmojiId; | ||
private readonly int _expirationDate; | ||
|
||
private readonly UserGift _gift; | ||
|
||
public EmojiStatusPopup(IClientService clientService, INavigationService navigationService, long sourceUserId, Sticker sticker, int expirationDate) | ||
{ | ||
InitializeComponent(); | ||
|
||
_clientService = clientService; | ||
_navigationService = navigationService; | ||
|
||
if (sticker.FullType is StickerFullTypeCustomEmoji customEmoji) | ||
{ | ||
_customEmojiId = customEmoji.CustomEmojiId; | ||
_expirationDate = expirationDate; | ||
} | ||
|
||
Animated.Source = new DelayedFileSource(clientService, sticker); | ||
Status.Source = new DelayedFileSource(clientService, sticker); | ||
|
||
if (clientService.TryGetUser(sourceUserId, out User user)) | ||
{ | ||
var diff = expirationDate - DateTime.Now.ToTimestamp(); | ||
if (diff > 0) | ||
{ | ||
TextBlockHelper.SetMarkdown(Subtitle, string.Format(Strings.BotEmojiStatusTextFor, user.FirstName, Locale.FormatTtl(diff))); | ||
} | ||
else | ||
{ | ||
TextBlockHelper.SetMarkdown(Subtitle, string.Format(Strings.BotEmojiStatusText, user.FirstName)); | ||
} | ||
} | ||
|
||
if (clientService.TryGetUser(clientService.Options.MyId, out User self)) | ||
{ | ||
Photo.SetUser(clientService, self, 28); | ||
TitleText.Text = self.FullName(); | ||
} | ||
} | ||
|
||
private bool _submitted; | ||
|
||
private async void Purchase_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) | ||
{ | ||
if (_submitted) | ||
{ | ||
return; | ||
} | ||
|
||
_submitted = true; | ||
|
||
PurchaseRing.Visibility = Windows.UI.Xaml.Visibility.Visible; | ||
|
||
var visual1 = ElementComposition.GetElementVisual(PurchaseText); | ||
var visual2 = ElementComposition.GetElementVisual(PurchaseRing); | ||
|
||
ElementCompositionPreview.SetIsTranslationEnabled(PurchaseText, true); | ||
ElementCompositionPreview.SetIsTranslationEnabled(PurchaseRing, true); | ||
|
||
var translate1 = visual1.Compositor.CreateScalarKeyFrameAnimation(); | ||
translate1.InsertKeyFrame(0, 0); | ||
translate1.InsertKeyFrame(1, -32); | ||
|
||
var translate2 = visual1.Compositor.CreateScalarKeyFrameAnimation(); | ||
translate2.InsertKeyFrame(0, 32); | ||
translate2.InsertKeyFrame(1, 0); | ||
|
||
visual1.StartAnimation("Translation.Y", translate1); | ||
visual2.StartAnimation("Translation.Y", translate2); | ||
|
||
//await Task.Delay(2000); | ||
|
||
if (_clientService.IsPremium) | ||
{ | ||
var result = await _clientService.SendAsync(new SetEmojiStatus(new EmojiStatus(_customEmojiId, _expirationDate))); | ||
Hide(result is Ok | ||
? ContentDialogResult.Primary | ||
: ContentDialogResult.Secondary); | ||
} | ||
else | ||
{ | ||
Hide(); | ||
_navigationService.ShowPromo(new PremiumSourceFeature(new PremiumFeatureEmojiStatus())); | ||
} | ||
//ViewModel.Submit(); | ||
} | ||
} | ||
} |
Oops, something went wrong.