Skip to content

Commit 9637237

Browse files
committed
New Features :
- Added statistics page with Graphs and Charts on Desktop and Mobile where users can have an insight of their data. This fixes #35 - Added a little History of latest flows on HomePage on both Platforms. Closes #41 QoL improvemnts: - largely improved the speed/performance when going to the ManageExpenditures pages on both Platforms - Pratically removed the lag that exists when navigating from StatisticsPageM to ManageExpendituresM. Added a bool that will ensure that the Observable collections are not initialized on every navigation - Added an event that will be listened and will be used to notify when OfflineExpendituresList is updated - Probably other stuff that I forgot to mention
1 parent 53b0349 commit 9637237

28 files changed

+1076
-368
lines changed

FlowHub.DataAccess/FlowHub.DataAccess.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<ItemGroup>
3030
<PackageReference Include="LiteDB.Async" Version="0.1.6" />
31-
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
31+
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
3232
</ItemGroup>
3333

3434
<ItemGroup>

FlowHub.DataAccess/IRepositories/IExpendituresRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace FlowHub.DataAccess.IRepositories;
55
public interface IExpendituresRepository
66
{
77
// Task<List<ExpendituresModel>> GetAllExpendituresAsync();
8+
event Action OfflineExpendituresListChanged;
89
Task<List<ExpendituresModel>> GetAllExpendituresAsync();
910
// List<ExpendituresModel> OnlineExpendituresList { get; set; }
1011

FlowHub.DataAccess/Repositories/ExpendituresRepository.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public class ExpendituresRepository : IExpendituresRepository
1414

1515
public List<ExpendituresModel> OfflineExpendituresList { get; set; }
1616

17+
bool isBatchUpdate;
18+
public event Action OfflineExpendituresListChanged;
19+
1720
private IMongoCollection<ExpendituresModel> AllOnlineExpenditures;
1821
private IMongoCollection<IDsToBeDeleted> AllOnlineIDsToBeDeleted;
1922

@@ -55,7 +58,7 @@ public async Task<List<ExpendituresModel>> GetAllExpendituresAsync()
5558
userId = usersRepo.OfflineUser.UserIDOnline;
5659
}
5760
OfflineExpendituresList = await AllExpenditures.Query().Where(x => x.UserId == userId && x.Currency == userCurrency).ToListAsync();
58-
61+
5962
db.Dispose();
6063

6164
return OfflineExpendituresList;
@@ -80,7 +83,12 @@ public async Task<bool> AddExpenditureAsync(ExpendituresModel expenditure)
8083
{
8184
if (await AllExpenditures.InsertAsync(expenditure) is not null)
8285
{
83-
return true;
86+
OfflineExpendituresList.Add(expenditure);
87+
if (!isBatchUpdate)
88+
{
89+
OfflineExpendituresListChanged?.Invoke();
90+
}
91+
return true;
8492
}
8593
else
8694
{
@@ -109,6 +117,12 @@ public async Task<bool> UpdateExpenditureAsync(ExpendituresModel expenditure)
109117
if (await AllExpenditures.UpdateAsync(expenditure))
110118
{
111119
db.Dispose();
120+
int index = OfflineExpendituresList.FindIndex(x => x.Id == expenditure.Id);
121+
OfflineExpendituresList[index] = expenditure;
122+
if (!isBatchUpdate)
123+
{
124+
OfflineExpendituresListChanged?.Invoke();
125+
}
112126
return true;
113127
}
114128
else
@@ -142,6 +156,11 @@ public async Task<bool> DeleteExpenditureAsync(string id)
142156

143157
await AllIDsToBeDeleted.InsertAsync(idToBeDeleted);
144158
db.Dispose();
159+
OfflineExpendituresList.Remove(OfflineExpendituresList.Where(x => x.Id == id).FirstOrDefault());
160+
if (!isBatchUpdate)
161+
{
162+
OfflineExpendituresListChanged?.Invoke();
163+
}
145164
return true;
146165
}
147166
else
@@ -232,6 +251,7 @@ public async Task<bool> SynchronizeExpendituresAsync(string userEmail, string us
232251

233252
private async Task UpdateLocalDBWithOnlineData(List<ExpendituresModel> tempExpList)
234253
{
254+
isBatchUpdate = true;
235255
foreach (var expOnline in OnlineExpendituresList)
236256
{
237257
if (tempExpList.Exists(x => x.Id == expOnline.Id) && expOnline.UpdateOnSync &&
@@ -250,6 +270,8 @@ private async Task UpdateLocalDBWithOnlineData(List<ExpendituresModel> tempExpLi
250270
await AddExpenditureAsync(expOnline);
251271
}
252272
}
273+
isBatchUpdate = false;
274+
OfflineExpendituresListChanged?.Invoke();
253275
}
254276

255277
private async Task UpdateOnlineDBWithLocalData(List<ExpendituresModel> tempExpList)

FlowHub.Main/AppShell.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
xmlns:viewsExpenditures="clr-namespace:FlowHub.Main.Views.Desktop.Expenditures"
88
xmlns:viewsIncomes="clr-namespace:FlowHub.Main.Views.Desktop.Incomes"
99
xmlns:viewsSettings="clr-namespace:FlowHub.Main.Views.Desktop.Settings"
10+
xmlns:viewsStatistics="clr-namespace:FlowHub.Main.Views.Desktop.Statistics"
1011
Shell.NavBarIsVisible="False"
1112
Shell.FlyoutBehavior="Disabled"
1213
CurrentItem ="{x:Reference login}">
@@ -35,6 +36,12 @@
3536
ContentTemplate="{DataTemplate viewsIncomes:ManageIncomesD}"
3637
Route="ManageIncomes"/>
3738
</Tab>
39+
40+
<Tab Title="Flow Insights">
41+
<ShellContent Title="Flow Insights"
42+
ContentTemplate="{DataTemplate viewsStatistics:StatisticsPageD}"
43+
Route="Statistics"/>
44+
</Tab>
3845

3946
<Tab Title="Planning">
4047
<ShellContent Title="Monthly Plannings"/>

FlowHub.Main/AppShell.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using FlowHub.Main.Views.Desktop.Expenditures;
33
using FlowHub.Main.Views.Desktop.Incomes;
44
using FlowHub.Main.Views.Desktop.Settings;
5+
using FlowHub.Main.Views.Desktop.Statistics;
56

67
namespace FlowHub.Main;
78

@@ -15,11 +16,13 @@ public AppShell()
1516
Routing.RegisterRoute(nameof(LoginD), typeof(LoginD));
1617

1718
Routing.RegisterRoute(nameof(ManageExpendituresPageD), typeof(ManageExpendituresPageD));
18-
19+
1920
Routing.RegisterRoute(nameof(UpSertExpenditurePageD), typeof(UpSertExpenditurePageD));
2021

2122
Routing.RegisterRoute(nameof(ManageIncomesD), typeof(ManageIncomesD));
2223

24+
Routing.RegisterRoute(nameof(StatisticsPageD), typeof(StatisticsPageD));
25+
2326
Routing.RegisterRoute(nameof(UserSettingsPageD), typeof(UserSettingsPageD));
2427
}
2528
}

FlowHub.Main/FlowHub.Main.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@
187187
<MauiXaml Update="Views\Desktop\Settings\UserSettingsPageD.xaml">
188188
<Generator>MSBuild:Compile</Generator>
189189
</MauiXaml>
190+
<MauiXaml Update="Views\Desktop\Statistics\StatisticsPageD.xaml">
191+
<Generator>MSBuild:Compile</Generator>
192+
</MauiXaml>
190193
<MauiXaml Update="Views\Mobile\Expenditures\ManageExpendituresM.xaml">
191194
<Generator>MSBuild:Compile</Generator>
192195
</MauiXaml>

FlowHub.Main/MauiProgram.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using FlowHub.Main.Views.Desktop.Expenditures;
1313
using FlowHub.Main.Views.Desktop.Incomes;
1414
using FlowHub.Main.Views.Desktop.Settings;
15+
using FlowHub.Main.Views.Desktop.Statistics;
1516
using FlowHub.Main.Views.Mobile;
1617
using FlowHub.Main.Views.Mobile.Expenditures;
1718
using FlowHub.Main.Views.Mobile.Expenditures.PlannedExpenditures.MonthlyPlannedExp;
@@ -120,6 +121,8 @@ public static MauiApp CreateMauiApp()
120121
builder.Services.AddSingleton<UpSertMonthlyPlannedExpPageM>();
121122

122123
/* -- Section For Statistics --*/
124+
builder.Services.AddTransient<StatisticsPageD>();
125+
123126
builder.Services.AddTransient<StatisticsPageM>();
124127
builder.Services.AddSingleton<SingleMonthStatsPageM>();
125128
/*--------------------------------------------------------------------------------------------------------------------------------*/

FlowHub.Main/Platforms/Android/NavigationsMethods/ManageExpendituresNavs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static async Task FromUpsertExpToManageExpenditures(Dictionary<string, ob
1717

1818
public static async Task FromManageExpToSingleMonthStats(Dictionary<string, object> navParams)
1919
{
20-
await Shell.Current.GoToAsync(nameof(SingleMonthStatsPageM), true, navParams);
20+
await Shell.Current.GoToAsync(nameof(StatisticsPageM), true, navParams);
2121
}
2222
public static async Task ReturnOnce()
2323
{

FlowHub.Main/Platforms/Windows/NavigationsMethods/ManageExpendituresNavs.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using FlowHub.Main.Views.Desktop.Expenditures;
2+
using FlowHub.Main.Views.Desktop.Statistics;
23

34
namespace FlowHub.Main.Platforms.NavigationMethods;
45

@@ -14,7 +15,7 @@ public static async Task FromUpsertExpToManageExpenditures(Dictionary<string, ob
1415
}
1516
public static async Task FromManageExpToSingleMonthStats(Dictionary<string, object> navParams)
1617
{
17-
//await Shell.Current.GoToAsync(nameof(SingleMonthStatsPageM), true, navParams);
18+
await Shell.Current.GoToAsync(nameof(StatisticsPageD), true, navParams);
1819
}
1920

2021
public static async Task ReturnOnce()

FlowHub.Main/PopUpPages/InputCurrencyForPrintPopUpPage.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public InputCurrencyForPrintPopUpPage(string DisplayText, string UserCurrency)
1010
DisplayAlertText.Text = DisplayText;
1111
//TODO: Pass the user currency in th title of the popup page and remove this display text
1212

13-
1413
List<string> ListOfCurrencies = new()
1514
{
1615
"AED", // United Arab Emirates Dirham

0 commit comments

Comments
 (0)