Skip to content

Commit 69e6530

Browse files
committed
fixes
1 parent b7da061 commit 69e6530

14 files changed

+362
-185
lines changed

MyFinance/AppShell.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,22 @@ public AppShell(IServiceProvider serviceProvider)
1414
new ShellContent()
1515
.Title("")
1616
.ContentTemplate(() => new StartedPage())
17-
.Route("StartedPage"),
17+
.Route(nameof(StartedPage)),
1818

1919
new ShellContent()
2020
.Title("")
2121
.ContentTemplate(() => serviceProvider.GetService<LoginPage>())
22-
.Route("LoginPage"),
22+
.Route(nameof(LoginPage)),
2323

2424
new ShellContent()
2525
.Title("")
2626
.ContentTemplate(() => serviceProvider.GetService<RegisterPage>())
27-
.Route("RegisterPage"),
27+
.Route(nameof(RegisterPage)),
28+
29+
new ShellContent()
30+
.Title("")
31+
.ContentTemplate(() => serviceProvider.GetService<AddOrEditPage>())
32+
.Route(nameof(AddOrEditPage)),
2833

2934
new TabBar()
3035
.Items(

MyFinance/Context/MyFinanceContext.cs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public override Task<int> SaveChangesAsync(CancellationToken cancellationToken =
2424
{
2525
EntityState.Added => data.Entity.CreateDate = DateTime.Now,
2626
EntityState.Modified => data.Entity.UpdateDate = DateTime.Now,
27+
_ => data.Entity.UpdateDate = DateTime.Now
2728
};
2829
}
2930
return base.SaveChangesAsync(cancellationToken);

MyFinance/MauiProgram.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Extensions.Logging;
1+
using DevExpress.Maui.Core.Internal;
2+
using Microsoft.Extensions.Logging;
23
using Microsoft.Maui.Controls.Compatibility.Hosting;
34
using SkiaSharp.Views.Maui.Controls.Hosting;
45
using DXImage = DevExpress.Maui.Core.DXImage;
@@ -12,7 +13,9 @@ namespace MyFinance;
1213
[MauiMarkup(typeof(DXImage), typeof(DXButton), typeof(DXViewBase), typeof(DXBorder), typeof(DXContentPresenterBase))]
1314
[MauiMarkup(typeof(DXContentPresenter), typeof(DXCollectionView), typeof(CartesianChart), typeof(TabView), typeof(TabViewItem))]
1415
[MauiMarkup(typeof(TabItem), typeof(DXButtonBase), typeof(ShimmerView), typeof(DXCollectionViewBase), typeof(SwipeContainer))]
15-
[MauiMarkup(typeof(SwipeItem), typeof(DateEdit))]
16+
[MauiMarkup(typeof(SwipeItem), typeof(DateEdit), typeof(CalendarHeaderAppearance), typeof(CalendarDayCellAppearance), typeof(CalendarSelectableCellAppearance))]
17+
[MauiMarkup(typeof(DateEditActualAppearance), typeof(MultilineEdit), typeof(SimpleButton), typeof(DXStackLayout), typeof(DXLayoutBase))]
18+
[MauiMarkup(typeof(SwipeItemBase))]
1619
public static class MauiProgram
1720
{
1821
public static MauiApp CreateMauiApp()
@@ -43,6 +46,7 @@ public static MauiApp CreateMauiApp()
4346
.AddScopedWithShellRoute<AccountPage, AccountPageViewModel>($"//{nameof(AccountPage)}")
4447
.AddScopedWithShellRoute<LoginPage, LoginPageViewModel>($"//{nameof(LoginPage)}")
4548
.AddScopedWithShellRoute<RegisterPage, RegisterPageViewModel>($"//{nameof(RegisterPage)}")
49+
.AddScopedWithShellRoute<AddOrEditPage, AddOrEditPageViewModel>($"//{nameof(AddOrEditPage)}")
4650
.AddScoped<StartedPage>()
4751
.AddScoped<IUserRepo, UserRepo>()
4852
.AddScoped<IOperationItemsRepo, OperationItemsRepo>();

MyFinance/MyFinance.csproj

+6-5
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,20 @@
5959
<None Remove="Resources\Images\profits.png" />
6060
<None Remove="Resources\Images\up_arrow.png" />
6161
<None Remove="Resources\Images\user.png" />
62+
<None Remove="Resources\Images\wallet.png" />
6263
</ItemGroup>
6364

6465
<ItemGroup>
6566
<PackageReference Include="AutoMapper" Version="13.0.1" />
6667
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.0" />
6768
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
68-
<PackageReference Include="DevExpress.Maui.Controls" Version="24.1.1-alpha-24085" />
69-
<PackageReference Include="DevExpress.Maui.Editors" Version="24.1.1-alpha-24085" />
70-
<PackageReference Include="FmgLib.MauiMarkup" Version="8.3.1-prev1.0.2" />
69+
<PackageReference Include="DevExpress.Maui.Controls" Version="23.2.6" />
70+
<PackageReference Include="DevExpress.Maui.Editors" Version="23.2.6" />
71+
<PackageReference Include="FmgLib.MauiMarkup" Version="8.3.1-prev1.0.3" />
7172
<PackageReference Include="LiveChartsCore.SkiaSharpView.Maui" Version="2.0.0-rc2" />
7273
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.5" />
73-
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.21" />
74-
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
74+
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
75+
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
7576
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
7677
</ItemGroup>
7778

MyFinance/Repository/IRepo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public interface IRepo<TModel> where TModel : BaseModel
77
DbSet<TModel> Table { get; }
88
Task<int> SaveAsync();
99

10-
Task<List<TModel>> GetAllAsync(Expression<Func<TModel, bool>> expression = null, Expression<Func<TModel, object>> include = null, Expression<Func<TModel, object>> ordered = null, int? skip = null, int? limit = null);
10+
Task<List<TModel>> GetAllAsync(Expression<Func<TModel, bool>> expression = null, Expression<Func<TModel, object>> include = null, Expression<Func<TModel, object>> ordered = null, int? skip = null, int? limit = null, bool descOrder = false);
1111
Task<double> GetSumAsync(Expression<Func<TModel, double>> sumProp, Expression<Func<TModel, bool>> expression = null, Expression<Func<TModel, object>> include = null, int? skip = null, int? limit = null);
1212
Task<TModel?> GetSingleAsync(Expression<Func<TModel, bool>> expression, Expression<Func<TModel, object>> include = null);
1313
Task<int> GetCountAsync(Expression<Func<TModel, bool>> filter = null);

MyFinance/Repository/Repo.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public Repo(MyFinanceContext context)
1515

1616
public DbSet<TModel> Table => _context.Set<TModel>();
1717

18-
public async Task<List<TModel>> GetAllAsync(Expression<Func<TModel, bool>> expression = null, Expression<Func<TModel, object>> include = null, Expression<Func<TModel, object>> ordered = null, int? skip = null, int? limit = null)
18+
public async Task<List<TModel>> GetAllAsync(Expression<Func<TModel, bool>> expression = null, Expression<Func<TModel, object>> include = null, Expression<Func<TModel, object>> ordered = null, int? skip = null, int? limit = null, bool descOrder = false)
1919
{
2020
var query = Table.AsNoTracking();
2121

@@ -26,7 +26,7 @@ public async Task<List<TModel>> GetAllAsync(Expression<Func<TModel, bool>> expre
2626
query = query.Include(include);
2727

2828
if (ordered != null)
29-
query = query.OrderBy(ordered);
29+
query = descOrder ? query.OrderByDescending(ordered) : query.OrderBy(ordered);
3030

3131
if (skip.HasValue)
3232
query = query.Skip(skip.Value);
@@ -96,12 +96,12 @@ public async Task<bool> RemoveAsync(Guid id)
9696
try
9797
{
9898
var model = await Table.FirstOrDefaultAsync(x => x.Id == id);
99-
Table.Remove(model);
99+
var result = Table.Remove(model);
100100
await SaveAsync();
101101

102102
return true;
103103
}
104-
catch (Exception)
104+
catch (Exception ex)
105105
{
106106
return false;
107107
}

MyFinance/Resources/Images/wallet.png

16.3 KB
Loading

MyFinance/Resources/Styles/AppStyles.cs

+28-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ public class AppStyles
1717
.CursorColor(DeepSkyBlue)
1818
.LabelFontSize(14)),
1919

20+
// "MultilineEdit"
21+
22+
new Style<MultilineEdit>(e => e
23+
.LabelColor(DeepSkyBlue)
24+
.BorderColor(DeepSkyBlue)
25+
.FocusedBorderColor(DeepSkyBlue)
26+
.FocusedLabelColor(DeepSkyBlue)
27+
.CursorColor(DeepSkyBlue)
28+
.LabelFontSize(14)),
29+
2030
// "PasswordEdit"
2131

2232
new Style<PasswordEdit>(e => e
@@ -53,7 +63,24 @@ public class AppStyles
5363
.FocusedBorderColor(DeepSkyBlue)
5464
.FocusedLabelColor(DeepSkyBlue)
5565
.CursorColor(DeepSkyBlue)
56-
.LabelFontSize(14)),
66+
.LabelFontSize(14)
67+
.PickerHeaderAppearance(
68+
new CalendarHeaderAppearance()
69+
.BackgroundColor(DeepSkyBlue)
70+
)
71+
.PickerDayCellAppearance(
72+
new CalendarDayCellAppearance()
73+
.SelectedEllipseBackgroundColor(DeepSkyBlue)
74+
.TodayEllipseBackgroundColor(SkyBlue)
75+
)
76+
.PickerYearCellAppearance(
77+
new CalendarYearCellAppearance()
78+
.SelectedEllipseBackgroundColor(DeepSkyBlue)
79+
)
80+
.PickerMonthCellAppearance(
81+
new CalendarMonthCellAppearance()
82+
.SelectedEllipseBackgroundColor(DeepSkyBlue)
83+
)),
5784

5885
// "ActivityIndicator"
5986

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
namespace MyFinance.ViewModels;
2+
3+
public partial class AddOrEditPageViewModel : BaseViewModel
4+
{
5+
public static Guid Id;
6+
private readonly IOperationItemsRepo _operationItemsRepo;
7+
8+
[ObservableProperty]
9+
private OperationItem operationItem = new();
10+
11+
[ObservableProperty]
12+
private bool isInfoPopupShow = false;
13+
14+
[ObservableProperty]
15+
private bool isErrorPopupShow = false;
16+
17+
public AddOrEditPageViewModel(IOperationItemsRepo operationItemsRepo)
18+
{
19+
_operationItemsRepo = operationItemsRepo;
20+
}
21+
22+
[RelayCommand]
23+
public async Task Save()
24+
{
25+
var currentUser = Preferences.Get(nameof(App.CurrentUserId), string.Empty);
26+
OperationItem.IsActive = true;
27+
28+
if (OperationItem.Id == Guid.Empty)
29+
{
30+
OperationItem.CreatedBy = !string.IsNullOrEmpty(currentUser) ? Guid.Parse(currentUser) : Guid.Empty;
31+
OperationItem.UpdatedBy = !string.IsNullOrEmpty(currentUser) ? Guid.Parse(currentUser) : Guid.Empty;
32+
OperationItem.UpdateDate = DateTime.Now;
33+
}
34+
else
35+
{
36+
OperationItem.UpdatedBy = !string.IsNullOrEmpty(currentUser) ? Guid.Parse(currentUser) : Guid.Empty;
37+
}
38+
39+
var result = OperationItem.Id == Guid.Empty ?
40+
await _operationItemsRepo.InsertAsync(OperationItem) :
41+
await _operationItemsRepo.UpdateAsync(OperationItem);
42+
43+
if (result)
44+
{
45+
IsInfoPopupShow = true;
46+
await AppShell.Current.GoToAsync($"//{nameof(ItemsPage)}");
47+
}
48+
else
49+
{
50+
IsErrorPopupShow = true;
51+
}
52+
}
53+
54+
[RelayCommand]
55+
public async Task Cancel()
56+
{
57+
await AppShell.Current.GoToAsync($"//{nameof(ItemsPage)}");
58+
}
59+
60+
[RelayCommand]
61+
public async Task Loading()
62+
{
63+
if (Id != Guid.Empty)
64+
{
65+
OperationItem = await _operationItemsRepo.GetSingleAsync(e => e.Id == Id);
66+
}
67+
else
68+
OperationItem.Date = OperationItem.Id == Guid.Empty ? DateTime.Now : OperationItem.Date;
69+
}
70+
}

MyFinance/ViewModels/ChartPageViewModel.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ private async Task Calc(int days)
107107
{
108108
var graphVals = (await _operationItemsRepo.GetAllAsync(
109109
expression: e => e.Date > DateTime.Now.AddDays(-days),
110-
ordered: e => e.Date.Date))
110+
ordered: e => e.Date.Date,
111+
descOrder: true))
111112
.Select(e => new OperationGraphVM { Date = e.Date.Date, Amount = e.Amount, IsIncome = e.IsIncome })
112113
.ToList();
113114

MyFinance/ViewModels/ItemsPageViewModel.cs

+22-49
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,10 @@ public partial class ItemsPageViewModel : BaseViewModel
3030
private bool isShowPopup = false;
3131

3232
[ObservableProperty]
33-
private bool isItemPopupShow = false;
33+
private bool isDeletePopupShow = false;
3434

3535
[ObservableProperty]
36-
private OperationItem operationItem = new();
37-
38-
[ObservableProperty]
39-
private bool isInfoPopupShow = false;
40-
41-
[ObservableProperty]
42-
private Color infoPopupColor = SkyBlue;
43-
44-
[ObservableProperty]
45-
private string infoPopupTitle = "BİLGİ";
46-
47-
[ObservableProperty]
48-
private string infoPopupDesc = "İşlem başarılı olmuştur.";
36+
private Guid deleteId;
4937

5038
private int index = 15;
5139

@@ -55,7 +43,6 @@ public ItemsPageViewModel(IOperationItemsRepo operationItemsRepo, IMapper mapper
5543
_mapper = mapper;
5644

5745
Items = GetItems(GetDate()).Result;
58-
OperationItem.Date = DateTime.Now;
5946
}
6047

6148

@@ -65,7 +52,8 @@ private async Task<List<OperationItemsVM>> GetItems(DateTime date)
6552
expression: e => e.Date >= date && (OperationType == 0 ? true : OperationType == 1 ? e.IsIncome : !e.IsIncome),
6653
ordered: e => e.Date,
6754
skip: index,
68-
limit: 15);
55+
limit: 15,
56+
descOrder: true);
6957
index += 15;
7058

7159
if (tempList.Count == 0)
@@ -119,51 +107,36 @@ public void ShowFilterPopup()
119107
}
120108

121109
[RelayCommand]
122-
public void ShowItemPopup()
110+
public async void ShowItem()
123111
{
124-
IsItemPopupShow = true;
112+
await AppShell.Current.GoToAsync($"//{nameof(AddOrEditPage)}");
113+
await GetItems(GetDate());
125114
}
126115

127116
[RelayCommand]
128-
public void CloseItemPopup()
117+
public async void GotoEditPage(object parameter)
129118
{
130-
IsItemPopupShow = false;
131-
OperationItem = new();
119+
//AddOrEditPageViewModel.Id = true;
120+
await AppShell.Current.GoToAsync($"//{nameof(AddOrEditPage)}");
121+
await GetItems(GetDate());
132122
}
133123

134124
[RelayCommand]
135-
public async Task Save()
125+
public void Cancel()
136126
{
137-
var currentUser = Preferences.Get(nameof(App.CurrentUserId), string.Empty);
138-
OperationItem.IsActive = true;
139-
OperationItem.CreatedBy = !string.IsNullOrEmpty(currentUser) ? Guid.Parse(currentUser) : Guid.Empty;
140-
OperationItem.UpdatedBy = !string.IsNullOrEmpty(currentUser) ? Guid.Parse(currentUser) : Guid.Empty;
141-
142-
var result = await _operationItemsRepo.InsertAsync(OperationItem);
143-
if (result)
144-
{
145-
InfoPopupColor = SkyBlue;
146-
InfoPopupTitle = "BİLGİ";
147-
infoPopupDesc = "İşlem başarılı olmuştur.";
148-
}
149-
else
150-
{
151-
InfoPopupColor = DarkOrange;
152-
InfoPopupTitle = "HATA";
153-
infoPopupDesc = "İşlem sırasında beklenmeyen bir hata oluştu.";
154-
}
155-
IsInfoPopupShow = true;
127+
DeleteId = Guid.Empty;
128+
IsDeletePopupShow = false;
156129
}
157130

158131
[RelayCommand]
159-
public void ClosePopup()
132+
public async Task Yes()
160133
{
161-
if (InfoPopupTitle == "BİLGİ")
162-
{
163-
IsInfoPopupShow = false;
164-
IsItemPopupShow = false;
165-
}
166-
else
167-
IsInfoPopupShow = false;
134+
var result = await _operationItemsRepo.RemoveAsync(DeleteId);
135+
IsLoadingItems = true;
136+
await GetItems(GetDate());
137+
IsDeletePopupShow = false;
138+
await Task.Delay(1500);
139+
140+
IsLoadingItems = false;
168141
}
169142
}

MyFinance/ViewModels/MainPageViewModel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public MainPageViewModel(IUserRepo userRepo, IOperationItemsRepo operationItemsR
3030
Email = currentUser?.Email ?? string.Empty
3131
};
3232

33-
Items = mapper.Map<List<OperationItemsVM>>(operationItemsRepo.GetAllAsync(ordered:e => e.Date, limit:10).Result);
33+
Items = mapper.Map<List<OperationItemsVM>>(operationItemsRepo.GetAllAsync(ordered:e => e.Date, limit:10, descOrder: true).Result);
3434

3535
var inA = operationItemsRepo.GetSumAsync(sumProp: e => e.Amount, expression: e => e.Date >= DateTime.Now.AddMonths(-1) && e.IsIncome).Result;
3636
var outA = operationItemsRepo.GetSumAsync(sumProp: e => e.Amount, expression: e => e.Date >= DateTime.Now.AddMonths(-1) && !e.IsIncome).Result;

0 commit comments

Comments
 (0)