Skip to content

Commit e738284

Browse files
committed
finished.
1 parent 69e6530 commit e738284

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

MyFinance/Controls/GeneralPopup.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public partial class GeneralPopup : DXPopup
44
{
5-
public GeneralPopup(string title, string desc, string okBtnTxt = "OK", PopupType pType = PopupType.Info, bool allowScrim = false)
5+
public GeneralPopup(string title, string desc, string okBtnTxt = "OK", PopupType pType = PopupType.Info, bool allowScrim = false, string okBtnCommand = "OkBtnPopupCommand")
66
{
77
var color = pType == PopupType.Info ? SkyBlue : pType == PopupType.Warning ? DarkOrange : Red;
88

@@ -58,6 +58,7 @@ public GeneralPopup(string title, string desc, string okBtnTxt = "OK", PopupType
5858
.BackgroundColor(DeepSkyBlue)
5959
.CenterHorizontal()
6060
.Padding(0)
61+
.Command(e => e.Path(okBtnCommand))
6162
.OnClicked((sender, e) =>
6263
{
6364
IsOpen = false;

MyFinance/ViewModels/AddOrEditPageViewModel.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public partial class AddOrEditPageViewModel : BaseViewModel
1717
public AddOrEditPageViewModel(IOperationItemsRepo operationItemsRepo)
1818
{
1919
_operationItemsRepo = operationItemsRepo;
20+
OperationItem.Date = (OperationItem.Id == Guid.Empty ? DateTime.Now : OperationItem.Date);
2021
}
2122

2223
[RelayCommand]
@@ -43,7 +44,6 @@ await _operationItemsRepo.InsertAsync(OperationItem) :
4344
if (result)
4445
{
4546
IsInfoPopupShow = true;
46-
await AppShell.Current.GoToAsync($"//{nameof(ItemsPage)}");
4747
}
4848
else
4949
{
@@ -55,6 +55,8 @@ await _operationItemsRepo.InsertAsync(OperationItem) :
5555
public async Task Cancel()
5656
{
5757
await AppShell.Current.GoToAsync($"//{nameof(ItemsPage)}");
58+
59+
OperationItem = new();
5860
}
5961

6062
[RelayCommand]
@@ -65,6 +67,6 @@ public async Task Loading()
6567
OperationItem = await _operationItemsRepo.GetSingleAsync(e => e.Id == Id);
6668
}
6769
else
68-
OperationItem.Date = OperationItem.Id == Guid.Empty ? DateTime.Now : OperationItem.Date;
70+
OperationItem.Date = (OperationItem.Id == Guid.Empty ? DateTime.Now : OperationItem.Date);
6971
}
7072
}

MyFinance/ViewModels/ItemsPageViewModel.cs

+3-12
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public partial class ItemsPageViewModel : BaseViewModel
3535
[ObservableProperty]
3636
private Guid deleteId;
3737

38-
private int index = 15;
38+
private int index = 0;
3939

4040
public ItemsPageViewModel(IOperationItemsRepo operationItemsRepo, IMapper mapper)
4141
{
@@ -107,18 +107,9 @@ public void ShowFilterPopup()
107107
}
108108

109109
[RelayCommand]
110-
public async void ShowItem()
110+
public async void GotoAddPage(object parameter)
111111
{
112112
await AppShell.Current.GoToAsync($"//{nameof(AddOrEditPage)}");
113-
await GetItems(GetDate());
114-
}
115-
116-
[RelayCommand]
117-
public async void GotoEditPage(object parameter)
118-
{
119-
//AddOrEditPageViewModel.Id = true;
120-
await AppShell.Current.GoToAsync($"//{nameof(AddOrEditPage)}");
121-
await GetItems(GetDate());
122113
}
123114

124115
[RelayCommand]
@@ -133,7 +124,7 @@ public async Task Yes()
133124
{
134125
var result = await _operationItemsRepo.RemoveAsync(DeleteId);
135126
IsLoadingItems = true;
136-
await GetItems(GetDate());
127+
Items = await GetItems(GetDate());
137128
IsDeletePopupShow = false;
138129
await Task.Delay(1500);
139130

MyFinance/Views/AddOrEditPage.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public override void Build()
2727
new DateEdit()
2828
.Assign(out var dateEdit)
2929
.LabelText("Tarih")
30+
.Date(e => e.Path("OperationItem.Date"))
3031
.PickerButtonAreaTemplate(() =>
3132
new HorizontalStackLayout()
3233
.Margin(10)
@@ -47,8 +48,7 @@ public override void Build()
4748
.Text("OK")
4849
.Command(e => e.Path("ConfirmCommand"))
4950
)
50-
)
51-
.Date(e => e.Path("OperationItem.Date")),
51+
),
5252

5353
new TextEdit()
5454
.LabelText("Para Tutarı")
@@ -74,7 +74,7 @@ public override void Build()
7474
.FontSize(15)
7575
.Command(e => e.Path("CancelCommand")),
7676

77-
new GeneralPopup("BİLGİ", "İşlem başarılı oldu. ", "OK", PopupType.Info)
77+
new GeneralPopup("BİLGİ", "İşlem başarılı oldu. ", "OK", PopupType.Info, okBtnCommand: "CancelCommand")
7878
.RowSpan(4)
7979
.IsOpen(e => e.Path("IsInfoPopupShow")),
8080

MyFinance/Views/ItemsPage.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override void Build()
2929
new ImageButton()
3030
.Source("wallet.png")
3131
.SizeRequest(40, 40)
32-
.Command(e => e.Path("ShowItemCommand"))
32+
.Command(e => e.Path("GotoAddPageCommand"))
3333
.Column(1),
3434

3535
new ImageButton()
@@ -80,11 +80,7 @@ public override void Build()
8080
{
8181
AddOrEditPageViewModel.Id = ((OperationItemsVM)e.Item).Id;
8282
await AppShell.Current.GoToAsync($"//{nameof(AddOrEditPage)}");
83-
//BindingContext.ApplyFilterCommand.Execute(null);
8483
})
85-
//.CommandParameter(e => e.Path(nameof(DXCollectionView.SelectedItem)).Source(collectionView))
86-
//.FontColor(Orange)
87-
//.Image("edit.png")
8884
)
8985
.EndSwipeItems(
9086
new SwipeItem()
@@ -98,7 +94,6 @@ public override void Build()
9894
BindingContext.DeleteId = ((OperationItemsVM)e.Item).Id;
9995
BindingContext.IsDeletePopupShow = true;
10096
})
101-
//.Image("home.png")
10297
)
10398
.ItemView(
10499
new DXStackLayout()
@@ -311,4 +306,11 @@ public override void Build()
311306
)
312307
);
313308
}
309+
310+
protected override void OnAppearing()
311+
{
312+
base.OnAppearing();
313+
314+
BindingContext.ApplyFilterCommand.Execute(null);
315+
}
314316
}

0 commit comments

Comments
 (0)