Skip to content

Commit

Permalink
New Features :
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
YBTopaz8 committed Jun 28, 2023
1 parent 53b0349 commit 9637237
Show file tree
Hide file tree
Showing 28 changed files with 1,076 additions and 368 deletions.
2 changes: 1 addition & 1 deletion FlowHub.DataAccess/FlowHub.DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<ItemGroup>
<PackageReference Include="LiteDB.Async" Version="0.1.6" />
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace FlowHub.DataAccess.IRepositories;
public interface IExpendituresRepository
{
// Task<List<ExpendituresModel>> GetAllExpendituresAsync();
event Action OfflineExpendituresListChanged;
Task<List<ExpendituresModel>> GetAllExpendituresAsync();
// List<ExpendituresModel> OnlineExpendituresList { get; set; }

Expand Down
26 changes: 24 additions & 2 deletions FlowHub.DataAccess/Repositories/ExpendituresRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class ExpendituresRepository : IExpendituresRepository

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

bool isBatchUpdate;
public event Action OfflineExpendituresListChanged;

private IMongoCollection<ExpendituresModel> AllOnlineExpenditures;
private IMongoCollection<IDsToBeDeleted> AllOnlineIDsToBeDeleted;

Expand Down Expand Up @@ -55,7 +58,7 @@ public async Task<List<ExpendituresModel>> GetAllExpendituresAsync()
userId = usersRepo.OfflineUser.UserIDOnline;
}
OfflineExpendituresList = await AllExpenditures.Query().Where(x => x.UserId == userId && x.Currency == userCurrency).ToListAsync();

db.Dispose();

return OfflineExpendituresList;
Expand All @@ -80,7 +83,12 @@ public async Task<bool> AddExpenditureAsync(ExpendituresModel expenditure)
{
if (await AllExpenditures.InsertAsync(expenditure) is not null)
{
return true;
OfflineExpendituresList.Add(expenditure);
if (!isBatchUpdate)
{
OfflineExpendituresListChanged?.Invoke();
}
return true;
}
else
{
Expand Down Expand Up @@ -109,6 +117,12 @@ public async Task<bool> UpdateExpenditureAsync(ExpendituresModel expenditure)
if (await AllExpenditures.UpdateAsync(expenditure))
{
db.Dispose();
int index = OfflineExpendituresList.FindIndex(x => x.Id == expenditure.Id);
OfflineExpendituresList[index] = expenditure;
if (!isBatchUpdate)
{
OfflineExpendituresListChanged?.Invoke();
}
return true;
}
else
Expand Down Expand Up @@ -142,6 +156,11 @@ public async Task<bool> DeleteExpenditureAsync(string id)

await AllIDsToBeDeleted.InsertAsync(idToBeDeleted);
db.Dispose();
OfflineExpendituresList.Remove(OfflineExpendituresList.Where(x => x.Id == id).FirstOrDefault());
if (!isBatchUpdate)
{
OfflineExpendituresListChanged?.Invoke();
}
return true;
}
else
Expand Down Expand Up @@ -232,6 +251,7 @@ public async Task<bool> SynchronizeExpendituresAsync(string userEmail, string us

private async Task UpdateLocalDBWithOnlineData(List<ExpendituresModel> tempExpList)
{
isBatchUpdate = true;
foreach (var expOnline in OnlineExpendituresList)
{
if (tempExpList.Exists(x => x.Id == expOnline.Id) && expOnline.UpdateOnSync &&
Expand All @@ -250,6 +270,8 @@ private async Task UpdateLocalDBWithOnlineData(List<ExpendituresModel> tempExpLi
await AddExpenditureAsync(expOnline);
}
}
isBatchUpdate = false;
OfflineExpendituresListChanged?.Invoke();
}

private async Task UpdateOnlineDBWithLocalData(List<ExpendituresModel> tempExpList)
Expand Down
7 changes: 7 additions & 0 deletions FlowHub.Main/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:viewsExpenditures="clr-namespace:FlowHub.Main.Views.Desktop.Expenditures"
xmlns:viewsIncomes="clr-namespace:FlowHub.Main.Views.Desktop.Incomes"
xmlns:viewsSettings="clr-namespace:FlowHub.Main.Views.Desktop.Settings"
xmlns:viewsStatistics="clr-namespace:FlowHub.Main.Views.Desktop.Statistics"
Shell.NavBarIsVisible="False"
Shell.FlyoutBehavior="Disabled"
CurrentItem ="{x:Reference login}">
Expand Down Expand Up @@ -35,6 +36,12 @@
ContentTemplate="{DataTemplate viewsIncomes:ManageIncomesD}"
Route="ManageIncomes"/>
</Tab>

<Tab Title="Flow Insights">
<ShellContent Title="Flow Insights"
ContentTemplate="{DataTemplate viewsStatistics:StatisticsPageD}"
Route="Statistics"/>
</Tab>

<Tab Title="Planning">
<ShellContent Title="Monthly Plannings"/>
Expand Down
5 changes: 4 additions & 1 deletion FlowHub.Main/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using FlowHub.Main.Views.Desktop.Expenditures;
using FlowHub.Main.Views.Desktop.Incomes;
using FlowHub.Main.Views.Desktop.Settings;
using FlowHub.Main.Views.Desktop.Statistics;

namespace FlowHub.Main;

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

Routing.RegisterRoute(nameof(ManageExpendituresPageD), typeof(ManageExpendituresPageD));

Routing.RegisterRoute(nameof(UpSertExpenditurePageD), typeof(UpSertExpenditurePageD));

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

Routing.RegisterRoute(nameof(StatisticsPageD), typeof(StatisticsPageD));

Routing.RegisterRoute(nameof(UserSettingsPageD), typeof(UserSettingsPageD));
}
}
3 changes: 3 additions & 0 deletions FlowHub.Main/FlowHub.Main.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
<MauiXaml Update="Views\Desktop\Settings\UserSettingsPageD.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Desktop\Statistics\StatisticsPageD.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Mobile\Expenditures\ManageExpendituresM.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
Expand Down
3 changes: 3 additions & 0 deletions FlowHub.Main/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using FlowHub.Main.Views.Desktop.Expenditures;
using FlowHub.Main.Views.Desktop.Incomes;
using FlowHub.Main.Views.Desktop.Settings;
using FlowHub.Main.Views.Desktop.Statistics;
using FlowHub.Main.Views.Mobile;
using FlowHub.Main.Views.Mobile.Expenditures;
using FlowHub.Main.Views.Mobile.Expenditures.PlannedExpenditures.MonthlyPlannedExp;
Expand Down Expand Up @@ -120,6 +121,8 @@ public static MauiApp CreateMauiApp()
builder.Services.AddSingleton<UpSertMonthlyPlannedExpPageM>();

/* -- Section For Statistics --*/
builder.Services.AddTransient<StatisticsPageD>();

builder.Services.AddTransient<StatisticsPageM>();
builder.Services.AddSingleton<SingleMonthStatsPageM>();
/*--------------------------------------------------------------------------------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static async Task FromUpsertExpToManageExpenditures(Dictionary<string, ob

public static async Task FromManageExpToSingleMonthStats(Dictionary<string, object> navParams)
{
await Shell.Current.GoToAsync(nameof(SingleMonthStatsPageM), true, navParams);
await Shell.Current.GoToAsync(nameof(StatisticsPageM), true, navParams);
}
public static async Task ReturnOnce()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FlowHub.Main.Views.Desktop.Expenditures;
using FlowHub.Main.Views.Desktop.Statistics;

namespace FlowHub.Main.Platforms.NavigationMethods;

Expand All @@ -14,7 +15,7 @@ public static async Task FromUpsertExpToManageExpenditures(Dictionary<string, ob
}
public static async Task FromManageExpToSingleMonthStats(Dictionary<string, object> navParams)
{
//await Shell.Current.GoToAsync(nameof(SingleMonthStatsPageM), true, navParams);
await Shell.Current.GoToAsync(nameof(StatisticsPageD), true, navParams);
}

public static async Task ReturnOnce()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public InputCurrencyForPrintPopUpPage(string DisplayText, string UserCurrency)
DisplayAlertText.Text = DisplayText;
//TODO: Pass the user currency in th title of the popup page and remove this display text


List<string> ListOfCurrencies = new()
{
"AED", // United Arab Emirates Dirham
Expand Down
2 changes: 1 addition & 1 deletion FlowHub.Main/Utilities/EnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
return null;
}

private object GetDescription(Enum enumValue)
public static string GetDescription(Enum enumValue)
{
FieldInfo fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
var attribute = (DescriptionAttribute)fieldInfo.GetCustomAttribute(typeof(DescriptionAttribute));
Expand Down
Loading

0 comments on commit 9637237

Please sign in to comment.