Skip to content

Commit

Permalink
Merge pull request #44 from YBTopaz8/43-modal-add-edit-flows
Browse files Browse the repository at this point in the history
This merge Closes #43
  • Loading branch information
YBTopaz8 authored Jun 18, 2023
2 parents 4de2e34 + c7c0ef6 commit 51b4dad
Show file tree
Hide file tree
Showing 25 changed files with 393 additions and 174 deletions.
2 changes: 1 addition & 1 deletion FlowHub.DataAccess/Platforms/Windows/DataAccessRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace FlowHub.DataAccess;

public class DataAccessRepo : IDataAccessRepo
{
LiteDatabaseAsync db = null;
LiteDatabaseAsync db;
public LiteDatabaseAsync GetDb() //this function returns the path where the db file is saved
{
string path;
Expand Down
6 changes: 6 additions & 0 deletions FlowHub.Main/FlowHub.Main.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
<MauiXaml Update="Views\Mobile\Statistics\StatisticsPageM.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\UpSertExpendituresPopUp.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -273,6 +276,9 @@
<Compile Update="Views\Mobile\Incomes\UpSertIncomePageM.xaml.cs">
<DependentUpon>UpSertIncomePageM.xaml</DependentUpon>
</Compile>
<Compile Update="Views\UpSertExpendituresPopUp.xaml.cs">
<DependentUpon>UpSertExpendituresPopUp.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FlowHub.Main/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public partial class MainPage : ContentPage
{
int count = 0;
int count;

public MainPage()
{
Expand Down
3 changes: 1 addition & 2 deletions FlowHub.Main/PopUpPages/InputPopUpPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
x:Class="FlowHub.Main.PopUpPages.InputPopUpPage"
xmlns:validation="clr-namespace:InputKit.Shared.Validations;assembly=InputKit.Maui"
xmlns:material="clr-namespace:UraniumUI.Material.Controls;assembly=UraniumUI.Material"
CanBeDismissedByTappingOutsideOfPopup="False"

CanBeDismissedByTappingOutsideOfPopup="False"
Size="300,180"
Color="Transparent">
<Border
Expand Down
12 changes: 1 addition & 11 deletions FlowHub.Main/PopUpPages/InputPopUpPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommunityToolkit.Maui.Views;
using FlowHub.Main.Utilities;
using FlowHub.Models;
using System.Diagnostics;

Expand Down Expand Up @@ -84,17 +85,6 @@ private void OnDeleteButton_Clicked(object sender, EventArgs e)
}
}

public class PopUpCloseResult
{
public object Data { get; set; }
public PopupResult Result { get; set; }
}
public enum PopupResult
{
OK,
Cancel,
Delete
}
[Flags]
public enum InputType
{
Expand Down
1 change: 1 addition & 0 deletions FlowHub.Main/Resources/Styles/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<!-- Color Paletter 'Power' from Twitter -->

<Color x:Key="BackGroundDark">#201F24</Color>
<Color x:Key="BorderDark">#1B1B1B</Color>
<Color x:Key="BackGroundLight">#F2F0F4</Color>
<Color x:Key="DataGridColorDark">#263238</Color>
<Color x:Key="PositiveActionBtnDark">#6B69D6</Color>
Expand Down
2 changes: 1 addition & 1 deletion FlowHub.Main/Resources/Styles/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</Style>

<Style TargetType="Border">
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark=#29343E, Light=#F5F5F5}"/>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark={StaticResource BackGroundDark}, Light=#F5F5F5}"/>
<Setter Property="Stroke" Value="{StaticResource Primary}" />
<Setter Property="StrokeShape" Value="RoundRectangle 10"/>
<Setter Property="StrokeThickness" Value="2"/>
Expand Down
20 changes: 20 additions & 0 deletions FlowHub.Main/Utilities/PopUpCloseResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlowHub.Main.Utilities;

public class PopUpCloseResult
{
public object Data { get; set; }
public PopupResult Result { get; set; }
}

public enum PopupResult
{
OK,
Cancel,
Delete
}
59 changes: 32 additions & 27 deletions FlowHub.Main/ViewModels/Expenditures/ManageExpendituresVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using FlowHub.Main.PDF_Classes;
using FlowHub.Main.Platforms.NavigationMethods;
using FlowHub.Main.PopUpPages;
using FlowHub.Main.Utilities;
using FlowHub.Main.Views;
using FlowHub.Models;
using System.Collections.ObjectModel;
using System.Diagnostics;
Expand Down Expand Up @@ -52,10 +54,10 @@ public ManageExpendituresVM(IExpendituresRepository expendituresRepository, IUse
private bool activ;

[ObservableProperty]
private bool showDayFilter = false;
private bool showDayFilter;

[ObservableProperty]
private bool showStatisticBtn = false;
private bool showStatisticBtn;

[ObservableProperty]
private int dayFilterMonth ;
Expand All @@ -70,13 +72,13 @@ public ManageExpendituresVM(IExpendituresRepository expendituresRepository, IUse
private string filterTitle;

[ObservableProperty]
private bool showClearDayButton = false;
private bool showClearDayButton;

[ObservableProperty]
private bool isExpanderExpanded = false;
private bool isExpanderExpanded;

[ObservableProperty]
private bool isSyncing = false;
private bool isSyncing;

private string filterOption;
private int GlobalSortNamePosition = 1;
Expand All @@ -95,9 +97,8 @@ public async void PageloadedAsync()
UserCurrency = ActiveUser.UserCurrency;
await expendituresService.GetAllExpendituresAsync();
filterOption = "Filter_Curr_Month";
//FilterGetExpOfToday(GlobalSortNamePosition);

FilterGetAllExp();
// FilterGetAllExp();
}

[RelayCommand]
Expand Down Expand Up @@ -360,39 +361,43 @@ public void FilterGetExpOfSpecificDayMonth()
}

[RelayCommand]
public async void GoToAddExpenditurePage()
public async void ShowAddExpenditurePopUp()
{
if (ActiveUser is null)
{
Debug.WriteLine("Can't go");
Debug.WriteLine("Can't Open PopUp");
await Shell.Current.DisplayAlert("Wait", "Cannot go", "Ok");
}
else
{
Dictionary<string, object> navParam = new()
{
{ "SingleExpenditureDetails", new ExpendituresModel { DateSpent = DateTime.Now } },
{ "PageTitle", new string("Add New Flow Out") },
{ "IsAdd", true },
{ "ActiveUser", ActiveUser }
};
var newExpenditure = new ExpendituresModel() { DateSpent = DateTime.Now };
string pageTitle = "Add New Flow Out";
bool isAdd = true;

NavFunction.FromManageExpToUpsertExpenditures(navParam);
await AddEditExpediture(newExpenditure, pageTitle, isAdd);
}
}


[RelayCommand]
public void GoToEditExpenditurePage(ExpendituresModel expenditure)
public async void ShowEditExpenditurePopUp(ExpendituresModel expenditure)
{
var navParam = new Dictionary<string, object>
{
{ "SingleExpenditureDetails", expenditure },
{ "PageTitle", new string("Edit Flow Out") },
{ "IsAdd", false },
{ "ActiveUser", ActiveUser }
};
await AddEditExpediture(expenditure, "Edit Flow Out", false);
}
private async Task AddEditExpediture(ExpendituresModel newExpenditure, string pageTitle, bool isAdd)
{
ExpendituresModel nExp = newExpenditure;
var NewUpSertVM = new UpSertExpenditureVM(expendituresService, userService, nExp, pageTitle, isAdd, ActiveUser);
var UpSertResult = (PopUpCloseResult)await Shell.Current.ShowPopupAsync(new UpSertExpendituresPopUp(NewUpSertVM));

NavFunction.FromManageExpToUpsertExpenditures(navParam);
if (UpSertResult.Result == PopupResult.OK)
{
ExpendituresModel exp = (ExpendituresModel)UpSertResult.Data;
ExpendituresList.Add(exp);
expendituresService.OfflineExpendituresList.Add(exp);
TotalAmount += exp.AmountSpent;
TotalExpenditures++;
}
}

[RelayCommand]
Expand Down Expand Up @@ -439,7 +444,7 @@ public async void DeleteExpenditureBtn(ExpendituresModel expenditure)
const ToastDuration duration = ToastDuration.Short;
const double fontSize = 14;
string text;
bool response = (bool)(await Shell.Current.ShowPopupAsync(new AcceptCancelPopUpAlert("Do You want to delete?")))!;
bool response = (bool)(await Shell.Current.ShowPopupAsync(new AcceptCancelPopUpAlert("Do You want to DELETE?")))!;
if (response)
{
IsBusy = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public UpSertMonthlyPlannedExpVM(IPlannedExpendituresRepository monthlyPlannedEx
private UsersModel activeUser;

[ObservableProperty]
bool hasComment = false;
bool hasComment;

[ObservableProperty]
private bool addAnotherExp;

int expCounter;

double InitialSingleMonthlyPlannedExp = 0;
double InitialExpenditureAmount = 0;
double InitialSingleMonthlyPlannedExp;
double InitialExpenditureAmount;

[RelayCommand]
public void PageLoaded()
Expand Down
Loading

0 comments on commit 51b4dad

Please sign in to comment.