-
-
Notifications
You must be signed in to change notification settings - Fork 492
/
Copy pathRevenueViewModel.cs
123 lines (106 loc) · 4.02 KB
/
RevenueViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// Copyright Fela Ameghino 2015-2025
//
// 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.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Telegram.Common;
using Telegram.Navigation;
using Telegram.Navigation.Services;
using Telegram.Services;
using Telegram.Td.Api;
using Telegram.ViewModels.Chats;
using Telegram.ViewModels.Profile;
using Telegram.Views;
using Telegram.Views.Chats;
using Windows.UI.Xaml.Navigation;
namespace Telegram.ViewModels
{
public partial class RevenueViewModel : MultiViewModelBase, IHandle
{
protected readonly ChatStatisticsViewModel _statisticsViewModel;
protected readonly ChatBoostsViewModel _boostsViewModel;
protected readonly ChatRevenueViewModel _revenueViewModel;
public RevenueViewModel(IClientService clientService, ISettingsService settingsService, IEventAggregator aggregator)
: base(clientService, settingsService, aggregator)
{
_statisticsViewModel = TypeResolver.Current.Resolve<ChatStatisticsViewModel>(clientService.SessionId);
_boostsViewModel = TypeResolver.Current.Resolve<ChatBoostsViewModel>(clientService.SessionId);
_revenueViewModel = TypeResolver.Current.Resolve<ChatRevenueViewModel>(clientService.SessionId);
Children.Add(_statisticsViewModel);
Children.Add(_boostsViewModel);
Children.Add(_revenueViewModel);
Items = new ObservableCollection<ProfileTabItem>
{
new ProfileTabItem(Strings.Statistics, typeof(ChatStatisticsPage)),
new ProfileTabItem(Strings.Boosts, typeof(ChatBoostsPage)),
};
}
public ObservableCollection<ProfileTabItem> Items { get; }
public ChatStatisticsViewModel Statistics => _statisticsViewModel;
public ChatBoostsViewModel Boosts => _boostsViewModel;
public ChatRevenueViewModel Revenue => _revenueViewModel;
public override Task NavigatedToAsync(object parameter, NavigationMode mode, NavigationState state)
{
var chatId = (long)parameter;
Chat = ClientService.GetChat(chatId);
if (ClientService.TryGetSupergroupFull(Chat, out SupergroupFullInfo fullInfo))
{
if (fullInfo.CanGetRevenueStatistics || fullInfo.CanGetStarRevenueStatistics)
{
Items.Add(new ProfileTabItem(Strings.Monetization, typeof(ChatRevenuePage)));
}
}
if (state.TryGet("selectedIndex", out int selectedIndex))
{
SelectedItem = Items[selectedIndex];
}
else
{
SelectedItem ??= Items.FirstOrDefault();
}
RaisePropertyChanged(nameof(SharedCount));
return base.NavigatedToAsync(parameter, mode, state);
}
private int[] _sharedCount = new int[] { 0, 0, 0, 0, 0, 0 };
public int[] SharedCount
{
get => _sharedCount;
set => Set(ref _sharedCount, value);
}
private ProfileTabItem _selectedItem;
public ProfileTabItem SelectedItem
{
get => _selectedItem;
set => Set(ref _selectedItem, value);
}
protected Chat _chat;
public Chat Chat
{
get => _chat;
set => Set(ref _chat, value);
}
private int _selectedIndex;
public int SelectedIndex
{
get => _selectedIndex;
set => Set(ref _selectedIndex, value);
}
private double _headerHeight;
public double HeaderHeight
{
get => _headerHeight;
set
{
if (Set(ref _headerHeight, value))
{
//Statistics.HeaderHeight = value;
//Boosts.HeaderHeight = value;
}
}
}
}
}