Skip to content

Commit 2792fa3

Browse files
committed
ShimmerView added.
1 parent 7a5e84e commit 2792fa3

File tree

3 files changed

+400
-14
lines changed

3 files changed

+400
-14
lines changed

MyFinance/MauiProgram.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace MyFinance;
1010
[MauiMarkup(typeof(PasswordEdit), typeof(CheckEdit), typeof(DXPopup), typeof(ComboBoxEditBase), typeof(ItemsEditBase))]
1111
[MauiMarkup(typeof(DXImage), typeof(DXButton), typeof(DXViewBase), typeof(DXBorder), typeof(DXContentPresenterBase))]
1212
[MauiMarkup(typeof(DXContentPresenter), typeof(DXCollectionView), typeof(CartesianChart), typeof(TabView), typeof(TabViewItem))]
13-
[MauiMarkup(typeof(TabItem), typeof(DXButtonBase))]
13+
[MauiMarkup(typeof(TabItem), typeof(DXButtonBase), typeof(ShimmerView))]
1414
public static class MauiProgram
1515
{
1616
public static MauiApp CreateMauiApp()

MyFinance/ViewModels/ItemsPageViewModel.cs

+136
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,140 @@
22

33
public partial class ItemsPageViewModel : BaseViewModel
44
{
5+
[ObservableProperty]
6+
private List<OperatonItemsVM> allItems = new();
7+
8+
[ObservableProperty]
9+
private List<OperatonItemsVM> inItems = new();
10+
11+
[ObservableProperty]
12+
private List<OperatonItemsVM> outItems = new();
13+
14+
[ObservableProperty]
15+
private List<int> loadingItems = new() { 0,0,0,0,0,0,0,0,0,0,0 };
16+
17+
[ObservableProperty]
18+
private bool isLoadingAllItems = false;
19+
20+
[ObservableProperty]
21+
private bool isLoadingInItems = false;
22+
23+
[ObservableProperty]
24+
private bool isLoadingOutItems = false;
25+
26+
[ObservableProperty]
27+
private int allIType = 0;
28+
29+
[ObservableProperty]
30+
private int inIType = 0;
31+
32+
[ObservableProperty]
33+
private int outIType = 0;
34+
35+
public ItemsPageViewModel()
36+
{
37+
Random random = new Random();
38+
for (int i = 1; i <= 40; i++)
39+
{
40+
var amount = random.Next(1, 10000);
41+
AllItems.Add(
42+
new OperatonItemsVM
43+
{
44+
Id = Guid.NewGuid(),
45+
Icon = amount % 2 == 0 ? "loss.png" : "profits.png",
46+
Color = amount % 2 == 0 ? Red : Green,
47+
Date = DateTime.Now.AddDays(-(amount % 30)).ToString("dd.MM.yyyy HH:mm"),
48+
Title = amount % 2 == 0 ? "Borç ödendi" : "Ödeme Alındı",
49+
Description = amount % 2 == 0 ? "Ödemeler yapıldı" : "Yaka parası alındı.",
50+
Amount = $"{amount} ₺"
51+
}
52+
);
53+
}
54+
AllItems = AllItems.OrderByDescending(e => DateTime.Parse(e.Date)).ToList();
55+
InItems = AllItems.Where(e => e.Color == Green).ToList();
56+
OutItems = AllItems.Where(e => e.Color == Red).ToList();
57+
}
58+
59+
60+
//[RelayCommand]
61+
public List<OperatonItemsVM> GetItems(DateTime date, bool? isIncome = null)
62+
{
63+
IsLoadingAllItems = true;
64+
65+
List<OperatonItemsVM> tempList = new List<OperatonItemsVM>();
66+
Random random = new Random();
67+
for (int i = 1; i <= 70; i++)
68+
{
69+
var amount = random.Next(1, 10000);
70+
tempList.Add(
71+
new OperatonItemsVM
72+
{
73+
Id = Guid.NewGuid(),
74+
Icon = amount % 2 == 0 ? "loss.png" : "profits.png",
75+
Color = amount % 2 == 0 ? Red : Green,
76+
Date = DateTime.Now.AddDays(-(amount % 30)).ToString("dd.MM.yyyy HH:mm"),
77+
Title = amount % 2 == 0 ? "Borç ödendi" : "Ödeme Alındı",
78+
Description = amount % 2 == 0 ? "Ödemeler yapıldı" : "Yaka parası alındı.",
79+
Amount = $"{amount} ₺"
80+
}
81+
);
82+
}
83+
tempList = tempList
84+
.Where(e => DateTime.Parse(e.Date) >= date && isIncome.HasValue ? isIncome.Value ? e.Color == Green : e.Color == Red : true)
85+
.OrderByDescending(e => DateTime.Parse(e.Date))
86+
.ToList();
87+
88+
return tempList;
89+
}
90+
91+
[RelayCommand]
92+
public async Task AllItemTypeChanged()
93+
{
94+
IsLoadingAllItems = true;
95+
await Task.Delay(3500);
96+
if (AllIType == 0)
97+
AllItems = GetItems(DateTime.Now.AddDays(-7));
98+
else if (AllIType == 1)
99+
AllItems = GetItems(DateTime.Now.AddMonths(-1));
100+
else if (AllIType == 2)
101+
AllItems = GetItems(DateTime.Now.AddMonths(-6));
102+
else if (AllIType == 3)
103+
AllItems = GetItems(DateTime.Now.AddYears(-1));
104+
105+
IsLoadingAllItems = false;
106+
}
107+
108+
[RelayCommand]
109+
public async Task InItemTypeChanged()
110+
{
111+
IsLoadingInItems = true;
112+
await Task.Delay(3500);
113+
if (InIType == 0)
114+
InItems = GetItems(DateTime.Now.AddDays(-7), true);
115+
else if (InIType == 1)
116+
InItems = GetItems(DateTime.Now.AddMonths(-1), true);
117+
else if (InIType == 2)
118+
InItems = GetItems(DateTime.Now.AddMonths(-6), true);
119+
else if (InIType == 3)
120+
InItems = GetItems(DateTime.Now.AddYears(-1), true);
121+
122+
IsLoadingInItems = false;
123+
}
124+
125+
[RelayCommand]
126+
public async Task OutItemTypeChanged()
127+
{
128+
IsLoadingOutItems = true;
129+
await Task.Delay(3500);
130+
if (OutIType == 0)
131+
OutItems = GetItems(DateTime.Now.AddDays(-7), false);
132+
else if (OutIType == 1)
133+
OutItems = GetItems(DateTime.Now.AddMonths(-1), false);
134+
else if (OutIType == 2)
135+
OutItems = GetItems(DateTime.Now.AddMonths(-6), false);
136+
else if (OutIType == 3)
137+
OutItems = GetItems(DateTime.Now.AddYears(-1), false);
138+
139+
IsLoadingOutItems = false;
140+
}
5141
}

0 commit comments

Comments
 (0)