Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 9f753fd

Browse files
committed
Updated account ui
1 parent 15a79cc commit 9f753fd

File tree

2 files changed

+57
-54
lines changed

2 files changed

+57
-54
lines changed

Views/AccountView.xaml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@
99
mc:Ignorable="d"
1010
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
1111

12-
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Orientation="Horizontal" Padding="0, 50, 0, 0" >
13-
<Border Width="128px"
14-
Height="128px"
15-
HorizontalAlignment="Left"
16-
VerticalAlignment="Top"
17-
CornerRadius="100">
18-
<Border.Background>
19-
<ImageBrush x:Name="image_ProfilePicture" />
20-
</Border.Background>
21-
</Border>
22-
<StackPanel Orientation="Vertical">
23-
<TextBox x:Name="textBlock_FirstName" PlaceholderText="Enter your first name" />
24-
<TextBox x:Name="textBlock_LastName" PlaceholderText="Enter your last name" />
25-
<TextBox x:Name="textBlock_Username" PlaceholderText="Enter your @username" />
26-
<TextBox x:Name="textBlock_Bio" PlaceholderText="Enter your bio" />
27-
<HyperlinkButton x:Name="textBlock_PhoneNumber" Click="TextBlock_PhoneNumber_OnClick"/>
28-
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
29-
<Button x:Name="button_Apply" Content="Apply" Click="Button_Apply_OnClick" IsEnabled="False" />
30-
<Button x:Name="button_LogOut" Content="Log out" Click="Button_LogOut_OnClick" />
12+
<Border Background="#383838" Width="300" Height="500" HorizontalAlignment="Center" VerticalAlignment="Center" CornerRadius="20">
13+
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Center" Orientation="Vertical" Padding="0, 50, 0, 0" >
14+
<Border Background="#2D2D2D" Width="134" Height="134" Margin="0, 10, 0, 10" HorizontalAlignment="Center" VerticalAlignment="Top" CornerRadius="100">
15+
<Border Width="128" Height="128" HorizontalAlignment="Center" VerticalAlignment="Center" CornerRadius="100">
16+
<Border.Background>
17+
<ImageBrush x:Name="ImageProfilePicture" />
18+
</Border.Background>
19+
</Border>
20+
</Border>
21+
<StackPanel Orientation="Vertical" Width="Auto">
22+
<TextBox x:Name="TextBoxFirstName" PlaceholderText="Enter your first name" />
23+
<TextBox x:Name="TextBoxLastName" PlaceholderText="Enter your last name" />
24+
<TextBox x:Name="TextBoxUsername" PlaceholderText="Enter your @username" />
25+
<TextBox x:Name="TextBoxBio" PlaceholderText="Enter your bio" />
26+
<HyperlinkButton x:Name="TextBoxPhoneNumber" Width="Auto" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
27+
<StackPanel Orientation="Horizontal" Width="Auto" HorizontalAlignment="Stretch">
28+
<Button x:Name="ButtonApply" Content="Apply" Click="Button_Apply_OnClick" IsEnabled="True" />
29+
<Button x:Name="ButtonLogOut" Content="Log out" Click="Button_LogOut_OnClick" />
30+
</StackPanel>
3131
</StackPanel>
32-
</StackPanel>
33-
</StackPanel>
32+
</StackPanel>
33+
</Border>
3434
</Page>

Views/AccountView.xaml.cs

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using Microsoft.UI.Xaml.Controls;
34
using TdLib;
45
using System.Threading.Tasks;
@@ -17,7 +18,6 @@ public sealed partial class AccountView : Page
1718
private string _username;
1819
private string _bio;
1920
private string _phoneNumber;
20-
private TdApi.ProfilePhoto _profilePicture;
2121

2222
public AccountView()
2323
{
@@ -29,19 +29,20 @@ public AccountView()
2929
private async void InitializeAllVariables()
3030
{
3131
var currentUser = await GetCurrentUser();
32+
var userFullInfo = await _client.GetUserFullInfoAsync(currentUser.Id);
3233
GetProfilePhoto(currentUser);
3334

3435
_firstName = $"{currentUser.FirstName}";
3536
_lastName = $"{currentUser.LastName}";
3637
_username = $"@{currentUser.Usernames?.ActiveUsernames[0]}";
37-
//_bio = $"{}"
38+
_bio = $"{userFullInfo.Bio.Text}";
3839
_phoneNumber = $"+{currentUser.PhoneNumber}";
3940

40-
textBlock_Username.Text = _username;
41-
textBlock_FirstName.Text = _firstName;
42-
textBlock_LastName.Text = _lastName;
43-
textBlock_Bio.Text = "я не ебу как достать био, чес слово";
44-
textBlock_PhoneNumber.Content = _phoneNumber;
41+
TextBoxUsername.Text = _username;
42+
TextBoxFirstName.Text = _firstName;
43+
TextBoxLastName.Text = _lastName;
44+
TextBoxBio.Text = _bio;
45+
TextBoxPhoneNumber.Content = _phoneNumber;
4546
}
4647

4748
private async void GetProfilePhoto(TdApi.User user)
@@ -53,8 +54,10 @@ private async void GetProfilePhoto(TdApi.User user)
5354
FileId = user.ProfilePhoto.Big.Id,
5455
Priority = 1
5556
});
56-
57-
image_ProfilePicture.ImageSource = new BitmapImage(new Uri(profilePhoto.Local.Path));
57+
58+
if (!Directory.Exists(profilePhoto.Local.Path)) return;
59+
60+
ImageProfilePicture.ImageSource = new BitmapImage(new Uri(profilePhoto.Local.Path));
5861
}
5962
catch (Exception e)
6063
{
@@ -73,37 +76,37 @@ private async void Button_LogOut_OnClick(object sender, RoutedEventArgs e)
7376
await _client.ExecuteAsync(new TdApi.LogOut());
7477
}
7578

76-
private void TextBlock_PhoneNumber_OnClick(object sender, RoutedEventArgs e)
77-
{
78-
throw new NotImplementedException();
79-
}
80-
8179
private void Button_Apply_OnClick(object sender, RoutedEventArgs e)
8280
{
83-
//_client.ExecuteAsync(new TdApi.SetProfilePhoto
84-
//{
85-
// Photo = _profilePicture
86-
//});
87-
88-
_client.ExecuteAsync(new TdApi.SetName
81+
if (TextBoxUsername.Text != _username)
8982
{
90-
FirstName = _firstName,
91-
LastName = _lastName
92-
});
83+
_username = TextBoxUsername.Text;
84+
85+
_client.ExecuteAsync(new TdApi.SetUsername
86+
{
87+
Username = _username
88+
});
89+
}
9390

94-
//if (_bio != GetCurrentUser().Result.Extra.)
95-
//{
96-
// _client.ExecuteAsync(new TdApi.SetBio
97-
// {
98-
// Bio = _bio
99-
// });
100-
//}
91+
if (TextBoxFirstName.Text != _firstName || TextBoxLastName.Text != _lastName)
92+
{
93+
_firstName = TextBoxFirstName.Text;
94+
_lastName = TextBoxLastName.Text;
95+
96+
_client.ExecuteAsync(new TdApi.SetName
97+
{
98+
FirstName = _firstName,
99+
LastName = _lastName
100+
});
101+
}
101102

102-
if (_username != GetCurrentUser().Result.Usernames.ActiveUsernames[0])
103+
if (TextBoxBio.Text != _bio)
103104
{
104-
_client.ExecuteAsync(new TdApi.SetUsername
105+
_bio = TextBoxBio.Text;
106+
107+
_client.ExecuteAsync(new TdApi.SetBio
105108
{
106-
Username = _username
109+
Bio = _bio
107110
});
108111
}
109112
}

0 commit comments

Comments
 (0)