Skip to content

Commit bbf2a8f

Browse files
committed
account page added.
1 parent f32c044 commit bbf2a8f

14 files changed

+490
-106
lines changed

MyFinance/App.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace MyFinance;
22

3-
public partial class App : MC.Application
3+
public partial class App : Application
44
{
55
public App(IServiceProvider services)
66
{

MyFinance/AppShell.cs

+16-17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ public AppShell(IServiceProvider serviceProvider)
1111
)
1212
.FlyoutBehavior(FlyoutBehavior.Disabled)
1313
.Items(
14+
new ShellContent()
15+
.Title("")
16+
.ContentTemplate(() => new StartedPage())
17+
.Route("StartedPage"),
18+
19+
new ShellContent()
20+
.Title("")
21+
.ContentTemplate(() => serviceProvider.GetService<LoginPage>())
22+
.Route("LoginPage"),
23+
24+
new ShellContent()
25+
.Title("")
26+
.ContentTemplate(() => serviceProvider.GetService<RegisterPage>())
27+
.Route("RegisterPage"),
28+
1429
new TabBar()
1530
.Items(
1631
new Tab()
@@ -40,23 +55,7 @@ public AppShell(IServiceProvider serviceProvider)
4055
.Route(nameof(AccountPage))
4156
.FlyoutDisplayOptions(FlyoutDisplayOptions.AsSingleItem)
4257
.Icon("user.png")
43-
),
44-
45-
new ShellContent()
46-
.Title("")
47-
.ContentTemplate(() => new StartedPage())
48-
.Route("StartedPage"),
49-
50-
new ShellContent()
51-
.Title("")
52-
.ContentTemplate(() => serviceProvider.GetService<LoginPage>())
53-
.Route("LoginPage"),
54-
55-
new ShellContent()
56-
.Title("")
57-
.ContentTemplate(() => serviceProvider.GetService<RegisterPage>())
58-
.Route("RegisterPage")
59-
58+
)
6059
);
6160
}
6261
}

MyFinance/Enums/ChartType.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ public enum ChartType
44
{
55
Weekly,
66
Monthly,
7-
SixMonthly,
8-
Yearly
7+
SixMonthly
98
}

MyFinance/Imports.cs

+1
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@
4545

4646
global using MC = Microsoft.Maui.Controls;
4747
global using DC = DevExpress.Maui.Controls;
48+
global using LC = LiveChartsCore.SkiaSharpView;

MyFinance/MauiProgram.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace MyFinance;
99
[MauiMarkup(typeof(StatusBarBehavior), typeof(TextEdit), typeof(TextEditBase), typeof(EditBase), typeof(ComboBoxEdit))]
1010
[MauiMarkup(typeof(PasswordEdit), typeof(CheckEdit), typeof(DXPopup), typeof(ComboBoxEditBase), typeof(ItemsEditBase))]
1111
[MauiMarkup(typeof(DXImage), typeof(DXButton), typeof(DXViewBase), typeof(DXBorder), typeof(DXContentPresenterBase))]
12-
[MauiMarkup(typeof(DXContentPresenter), typeof(DXCollectionView), typeof(CartesianChart), typeof(DXCalendar), typeof(AnimationBehavior))]
12+
[MauiMarkup(typeof(DXContentPresenter), typeof(DXCollectionView), typeof(CartesianChart))]
1313
public static class MauiProgram
1414
{
1515
public static MauiApp CreateMauiApp()

MyFinance/MyFinance.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<None Remove="Resources\Images\adjust.png" />
5252
<None Remove="Resources\Images\chart.png" />
5353
<None Remove="Resources\Images\down_arrow.png" />
54+
<None Remove="Resources\Images\edit.png" />
5455
<None Remove="Resources\Images\filter.png" />
5556
<None Remove="Resources\Images\getstarted.png" />
5657
<None Remove="Resources\Images\home.png" />

MyFinance/Resources/Images/edit.png

10.2 KB
Loading
+98-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,102 @@
1-
namespace MyFinance.ViewModels;
1+

2+
namespace MyFinance.ViewModels;
23

34
public partial class AccountPageViewModel : BaseViewModel
45
{
6+
private readonly IUserRepo _userRepo;
7+
8+
[ObservableProperty]
9+
private User userModel = new()
10+
{
11+
Email = string.Empty,
12+
FirstName = string.Empty,
13+
LastName = string.Empty,
14+
Password = string.Empty
15+
};
16+
17+
[ObservableProperty]
18+
private UserCardVM user = new();
19+
20+
[ObservableProperty]
21+
private bool isPopupShow = false;
22+
23+
[ObservableProperty]
24+
private bool isInfoPopupShow = false;
25+
26+
[ObservableProperty]
27+
private Color infoPopupColor = SkyBlue;
28+
29+
[ObservableProperty]
30+
private string infoPopupTitle = "BİLGİ";
31+
32+
[ObservableProperty]
33+
private string infoPopupDesc = "İşlem başarılı olmuştur.";
34+
35+
public AccountPageViewModel(IUserRepo userRepo)
36+
{
37+
_userRepo = userRepo;
38+
var accessUser = AuthCheckHelper.ParseBasicAuthToken(SecureStorage.GetAsync("USERAUTH").Result);
39+
var currentUser = _userRepo.GetSingleAsync(e => e.Email == accessUser.Item1 && e.Password == accessUser.Item2).Result;
40+
41+
if (currentUser == null)
42+
currentUser = default;
43+
44+
UserModel = currentUser;
45+
46+
User = new()
47+
{
48+
Name = $"{currentUser?.FirstName} {currentUser?.LastName}",
49+
Email = currentUser?.Email ?? string.Empty
50+
};
51+
}
52+
53+
[RelayCommand]
54+
public void ShowDetails()
55+
{
56+
IsPopupShow = true;
57+
}
58+
59+
[RelayCommand]
60+
public void ClosePopup()
61+
{
62+
if (InfoPopupTitle == "BİLGİ")
63+
{
64+
IsInfoPopupShow = false;
65+
IsPopupShow = false;
66+
}
67+
else
68+
IsInfoPopupShow = false;
69+
}
70+
71+
[RelayCommand]
72+
public void CloseDetailsPopup()
73+
{
74+
IsPopupShow = false;
75+
}
76+
77+
[RelayCommand]
78+
public async void Logout()
79+
{
80+
SecureStorage.Remove("USERAUTH");
81+
await AppShell.Current.GoToAsync($"//{nameof(LoginPage)}");
82+
}
83+
84+
[RelayCommand]
85+
public async Task Save()
86+
{
87+
var result = await _userRepo.UpdateAsync(UserModel);
88+
if (result)
89+
{
90+
InfoPopupColor = SkyBlue;
91+
InfoPopupTitle = "BİLGİ";
92+
infoPopupDesc = "İşlem başarılı olmuştur.";
93+
}
94+
else
95+
{
96+
InfoPopupColor = DarkOrange;
97+
InfoPopupTitle = "HATA";
98+
infoPopupDesc = "İşlem sırasında beklenmeyen bir hata oluştu.";
99+
}
100+
IsInfoPopupShow = true;
101+
}
5102
}

0 commit comments

Comments
 (0)