-
-
Notifications
You must be signed in to change notification settings - Fork 492
/
Copy pathCreateChatPhotoViewModel.cs
92 lines (82 loc) · 3.54 KB
/
CreateChatPhotoViewModel.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
//
// 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 Rg.DiffUtils;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Telegram.Navigation;
using Telegram.Navigation.Services;
using Telegram.Services;
using Telegram.Td.Api;
using Windows.UI.Xaml.Navigation;
namespace Telegram.ViewModels
{
public partial class CreateChatPhotoViewModel : ViewModelBase
{
public CreateChatPhotoViewModel(IClientService clientService, ISettingsService settingsService, IEventAggregator aggregator)
: base(clientService, settingsService, aggregator)
{
Items = new ObservableCollection<BackgroundFill>
{
new BackgroundFillFreeformGradient(new[] { 0x5A7FFF, 0x2CA0F2, 0x4DFF89, 0x6BFCEB }),
new BackgroundFillFreeformGradient(new[] { 0xFF011D, 0xFF530D, 0xFE64DC, 0xFFDC61 }),
new BackgroundFillFreeformGradient(new[] { 0xFE64DC, 0xFF6847, 0xFFDD02, 0xFFAE10 }),
new BackgroundFillFreeformGradient(new[] { 0x84EC00, 0x00B7C2, 0x00C217, 0xFFE600 }),
new BackgroundFillFreeformGradient(new[] { 0x86B0FF, 0x35FFCF, 0x69FFFF, 0x76DEFF }),
new BackgroundFillFreeformGradient(new[] { 0xFAE100, 0xFF54EE, 0xFC2B78, 0xFF52D9 }),
new BackgroundFillFreeformGradient(new[] { 0x73A4FF, 0x5F55FF, 0xFF49F8, 0xEC76FF }),
new BackgroundFillFreeformGradient(new[] { 0x73A4FF, 0x5F55FF, 0xFF49F8, 0xEC76FF }),
};
SelectedBackground = Items[0];
}
protected override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, NavigationState state)
{
var foreground = await ClientService.SendAsync(new GetAnimatedEmoji("\U0001F916")) as AnimatedEmoji;
if (foreground != null)
{
SelectedForeground = foreground.Sticker;
}
}
private Sticker _selectedForeground;
public Sticker SelectedForeground
{
get => _selectedForeground;
set => Set(ref _selectedForeground, value);
}
private BackgroundFill _selectedBackground;
public BackgroundFill SelectedBackground
{
get => _selectedBackground;
set => Set(ref _selectedBackground, value);
}
public ObservableCollection<BackgroundFill> Items { get; private set; }
public InputChatPhoto Send()
{
if (SelectedForeground is not Sticker foreground || SelectedBackground is not BackgroundFill background)
{
return null;
}
else
{
ChatPhotoStickerType stickerType = foreground.FullType is StickerFullTypeCustomEmoji customEmoji
? new ChatPhotoStickerTypeCustomEmoji(customEmoji.CustomEmojiId)
: new ChatPhotoStickerTypeRegularOrMask(foreground.SetId, foreground.Id);
InputChatPhoto inputPhoto = new InputChatPhotoSticker(new ChatPhotoSticker(stickerType, background));
return inputPhoto;
}
}
}
public partial class BackgroundDiffHandler : IDiffHandler<Background>
{
public bool CompareItems(Background oldItem, Background newItem)
{
return oldItem.Id == newItem.Id;
}
public void UpdateItem(Background oldItem, Background newItem)
{
}
}
}