Skip to content

Commit

Permalink
Updated monetization UI
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Apr 2, 2024
1 parent 42a900a commit 2c0ba92
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 148 deletions.
27 changes: 12 additions & 15 deletions Telegram/Controls/Cells/CryptoAmountCell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<RichTextBlock IsTextSelectionEnabled="False">
<Paragraph>
<InlineUIContainer>
<controls:CustomEmojiIcon x:Name="Icon"
Margin="0,-2,0,-4" />
</InlineUIContainer>
<Run x:Name="CryptocurrencyAmountLabel"
FontWeight="SemiBold" /><Run x:Name="CryptocurrencyDecimalLabel"
FontWeight="SemiBold"
FontSize="12" />
<Run x:Name="AmountLabel"
Foreground="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}"
FontSize="12" />
</Paragraph>
</RichTextBlock>
<TextBlock>
<Run Text="&#xEA7E;"
Foreground="{ThemeResource SystemColorControlAccentBrush}"
FontFamily="{StaticResource SymbolThemeFontFamily}" />
<Run x:Name="CryptocurrencyAmountLabel"
FontWeight="SemiBold" /><Run x:Name="CryptocurrencyDecimalLabel"
FontWeight="SemiBold"
FontSize="12" />
<Run x:Name="AmountLabel"
Foreground="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}"
FontSize="12" />
</TextBlock>
<TextBlock x:Name="TextLabel"
Style="{StaticResource InfoCaptionTextBlockStyle}"
Grid.Row="1" />
Expand Down
11 changes: 6 additions & 5 deletions Telegram/Controls/Cells/CryptoAmountCell.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using Telegram.Converters;
using Telegram.Services;
using Telegram.Streams;
using Windows.UI.Xaml.Controls;

namespace Telegram.Controls.Cells
Expand Down Expand Up @@ -30,7 +28,12 @@ public string Text
set => TextLabel.Text = value;
}

public void UpdateAmount(IClientService clientService, CryptoAmount value)
public CryptoAmount Amount
{
set => UpdateAmount(value);
}

public void UpdateAmount(CryptoAmount value)
{
if (value == null)
{
Expand All @@ -44,8 +47,6 @@ public void UpdateAmount(IClientService clientService, CryptoAmount value)
CryptocurrencyAmountLabel.Text = integerAmount.ToString("N0");
CryptocurrencyDecimalLabel.Text = string.Format(".{0:N0}", decimalAmount);

Icon.Source = new AnimatedEmojiFileSource(clientService, "\U0001F48E");

AmountLabel.Text = string.Format("~{0}", Formatter.FormatAmount(value.Amount, value.Currency));
}
}
Expand Down
92 changes: 0 additions & 92 deletions Telegram/Streams/AnimatedEmojiFileSource.cs

This file was deleted.

39 changes: 18 additions & 21 deletions Telegram/Views/Chats/ChatMonetizationPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@
<controls:HeaderedControl Header="{CustomResource MonetizationOverview}"
Background="{ThemeResource SettingsItemBackground}">
<cells:CryptoAmountCell x:Name="AvailableAmount"
Amount="{x:Bind ViewModel.AvailableAmount, Mode=OneWay}"
Text="{CustomResource MonetizationOverviewAvailable}"
Margin="12,8" />
<cells:CryptoAmountCell x:Name="PreviousAmount"
Amount="{x:Bind ViewModel.PreviousAmount, Mode=OneWay}"
Text="{CustomResource MonetizationOverviewLastWithdrawal}"
Margin="12,0" />
<cells:CryptoAmountCell x:Name="TotalAmount"
Amount="{x:Bind ViewModel.TotalAmount, Mode=OneWay}"
Text="{CustomResource MonetizationOverviewTotal}"
Margin="12,8" />
</controls:HeaderedControl>
Expand All @@ -60,27 +63,21 @@
Header="{CustomResource MonetizationBalance}"
Footer="{CustomResource MonetizationBalanceInfo}">
<StackPanel Background="{ThemeResource SettingsItemBackground}">
<RichTextBlock IsTextSelectionEnabled="False"
TextAlignment="Center"
Margin="0,8,0,0">
<Paragraph>
<InlineUIContainer>
<controls:CustomEmojiIcon x:Name="Icon"
Width="32"
Height="32"
FrameSize="32,32"
Margin="0,3,0,-4" />
</InlineUIContainer>
<Run x:Name="CryptocurrencyAmountLabel"
FontWeight="SemiBold"
FontSize="28" /><Run x:Name="CryptocurrencyDecimalLabel"
FontWeight="SemiBold"
FontSize="20" />
<LineBreak />
<Run x:Name="AmountLabel"
Foreground="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}" />
</Paragraph>
</RichTextBlock>
<TextBlock TextAlignment="Center"
Margin="0,8,0,0">
<Run Text="&#xEA7E;"
Foreground="{ThemeResource SystemColorControlAccentBrush}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
FontSize="28" />
<Run x:Name="CryptocurrencyAmountLabel"
FontWeight="SemiBold"
FontSize="28" /><Run x:Name="CryptocurrencyDecimalLabel"
FontWeight="SemiBold"
FontSize="20" />
<LineBreak />
<Run x:Name="AmountLabel"
Foreground="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}" />
</TextBlock>

<Button x:Name="TransferButton"
Click="{x:Bind ViewModel.Transfer}"
Expand Down
15 changes: 0 additions & 15 deletions Telegram/Views/Chats/ChatMonetizationPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Telegram.Controls.Cells;
using Telegram.Controls.Cells.Monetization;
using Telegram.Converters;
using Telegram.Streams;
using Telegram.ViewModels.Chats;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand All @@ -26,9 +25,6 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
ViewModel.PropertyChanged += OnPropertyChanged;

UpdateAmount(ViewModel.AvailableAmount);
AvailableAmount.UpdateAmount(ViewModel.ClientService, ViewModel.AvailableAmount);
PreviousAmount.UpdateAmount(ViewModel.ClientService, ViewModel.PreviousAmount);
TotalAmount.UpdateAmount(ViewModel.ClientService, ViewModel.TotalAmount);

FooterInfo.Text = string.Format(Strings.MonetizationInfo, 50);
}
Expand All @@ -43,15 +39,6 @@ private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChan
if (e.PropertyName == nameof(AvailableAmount))
{
UpdateAmount(ViewModel.AvailableAmount);
AvailableAmount.UpdateAmount(ViewModel.ClientService, ViewModel.AvailableAmount);
}
else if (e.PropertyName == nameof(PreviousAmount))
{
PreviousAmount.UpdateAmount(ViewModel.ClientService, ViewModel.PreviousAmount);
}
else if (e.PropertyName == nameof(TotalAmount))
{
TotalAmount.UpdateAmount(ViewModel.ClientService, ViewModel.TotalAmount);
}
}

Expand All @@ -69,8 +56,6 @@ public void UpdateAmount(CryptoAmount value)
CryptocurrencyAmountLabel.Text = integerAmount.ToString("N0");
CryptocurrencyDecimalLabel.Text = string.Format(".{0:N0}", decimalAmount);

Icon.Source = new AnimatedEmojiFileSource(ViewModel.ClientService, "\U0001F48E");

AmountLabel.Text = string.Format("~{0}", Formatter.FormatAmount(value.Amount, value.Currency));
}

Expand Down

0 comments on commit 2c0ba92

Please sign in to comment.