Skip to content

Commit

Permalink
Merge pull request #47 from YBTopaz8/6-search-exp-by-text
Browse files Browse the repository at this point in the history
- Added categories for Expenditures in code
  • Loading branch information
YBTopaz8 authored Jun 18, 2023
2 parents 51b4dad + 1f092a8 commit 8bb207a
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 23 deletions.
19 changes: 19 additions & 0 deletions FlowHub.Main/Utilities/EnumHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace FlowHub.Main.Utilities;

public class EnumHelper
{
public static string GetEnumDescription(Enum value)
{
FieldInfo field = value.GetType().GetField(value.ToString())!;
DescriptionAttribute? attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
return attribute == null ? value.ToString() : attribute.Description;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void PageLoaded()
{
IsAddTaxesChecked = true;
}

ResultingBalance = ActiveUser.PocketMoney;
TotalAmountSpent = SingleExpenditureDetails.AmountSpent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
xmlns:material="clr-namespace:UraniumUI.Material.Controls;assembly=UraniumUI.Material"
xmlns:models="clr-namespace:FlowHub.Models;assembly=FlowHub.Models"
xmlns:viewModels="clr-namespace:FlowHub.Main.ViewModels.Expenditures"
xmlns:utilities="clr-namespace:FlowHub.Main.Utilities"
x:DataType="viewModels:ManageExpendituresVM"
x:Name="page"
Title="Manage Expenditures">

<toolkit:DockLayout>
<toolkit:DockLayout.Resources>
<ResourceDictionary>
<utilities:EnumHelper x:Key="EnumHelper"/>
</ResourceDictionary>
</toolkit:DockLayout.Resources>

<Label FontSize="21" HorizontalOptions="Center"
Margin="8"
toolkit:DockLayout.DockPosition="Top">
Expand Down Expand Up @@ -118,6 +125,8 @@
</material:DataGridColumn>

<material:DataGridColumn Binding="{Binding Reason}" Title="Reason"/>
<material:DataGridColumn Binding="{Binding Category, Converter={StaticResource EnumHelper}}" Title="Reason"/>


<material:DataGridColumn Title="Amount Spent">
<material:DataGridColumn.CellItemTemplate>
Expand Down
4 changes: 1 addition & 3 deletions FlowHub.Main/Views/Desktop/Settings/UserSettingsPageD.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
<Button Text="Security"/>
<Button Text="Data Export"/>
</VerticalStackLayout>
<VerticalStackLayout Margin="25,20,20,0" >

<VerticalStackLayout Margin="25,20,20,0">
<Image Source="{AppThemeBinding Dark=user_icon_d.png, Light=user_icon_l.png}" HeightRequest="80"/>
<Label Text="{Binding UserName}" FontSize="38" FontAttributes="Bold" HorizontalTextAlignment="Center"/>

Expand All @@ -33,7 +32,6 @@
<toolkit:DockLayout Margin="10,10" >
<Label Text="Finances" FontAttributes="Bold" FontSize="22" />
<HorizontalStackLayout Spacing="80" HorizontalOptions="CenterAndExpand">

<VerticalStackLayout HorizontalOptions="Start">
<Label FontAttributes="Bold" FontSize="20" >
<Label.Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
<Label toolkit:DockLayout.DockPosition="Left" Text="Left" WidthRequest="80" />
<Label toolkit:DockLayout.DockPosition="Right" Text="Right" WidthRequest="90" />
<Label Text="Center" />-->
<Label Text="Yvan"/>
<Label Text="FlowHub - v0.0.8 Made With Love :D " HorizontalOptions="Center" Margin="2" FontSize="24"/>
<Label Text="By Yvan Brunel" HorizontalOptions="Center" Margin="2" FontSize="24"/>
<Label Text="Tap Here to view GitHub Repo" HorizontalTextAlignment="Center" VerticalOptions="Start" HeightRequest="30"
FontSize="21">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</Label.GestureRecognizers>
</Label>
</toolkit:DockLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ public ApplicationSettingsPageM()
{
InitializeComponent();
}

private async void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
{
var uri = new Uri("https://github.com/YBTopaz8/FlowHub-MAUI");
await Browser.Default.OpenAsync(uri, BrowserLaunchMode.SystemPreferred);
await Clipboard.SetTextAsync(uri.ToString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<Label Text="{Binding SelectCountryCurrency}" Grid.Column="1" VerticalOptions="Center" FontSize="16" FontAttributes="Bold"/>
</Grid>

<ListView ItemsSource="{Binding Taxes}" Header="Taxes" SeparatorVisibility="None" VerticalScrollBarVisibility="Never">
<ListView ItemsSource="{Binding Taxes}" Header="Taxes" IsVisible="false" SeparatorVisibility="None" VerticalScrollBarVisibility="Never">
<ListView.ItemTemplate>
<DataTemplate x:DataType="models:TaxModel">
<ViewCell>
Expand Down
4 changes: 2 additions & 2 deletions FlowHub.Main/Views/Mobile/Settings/UserSettingsPageM.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@
<Label Text="{Binding UserCurrency}" FontSize="15" FontAttributes="Bold"/>
</VerticalStackLayout>
<Rectangle />

<VerticalStackLayout Margin="5,15" Spacing="10">
<VerticalStackLayout Margin="5,15" Spacing="10" IsVisible="false">
<Label Text="Taxes" FontSize="13"/>
<ListView ItemsSource="{Binding ActiveUser.Taxes}" SelectionMode="None" SeparatorVisibility="None" VerticalScrollBarVisibility="Never">
<ListView.ItemTemplate>
Expand Down
4 changes: 2 additions & 2 deletions FlowHub.Main/Views/UpSertExpendituresPopUp.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
xmlns:viewModels="clr-namespace:FlowHub.Main.ViewModels.Expenditures"
x:DataType="viewModels:UpSertExpenditureVM"
CanBeDismissedByTappingOutsideOfPopup="False"
Size="{OnPlatform Android ='350,400', WinUI='400,400'} "

Color="Transparent"
x:Name="page">


<Border Margin="8,0"
<Border Margin="13,10"
Stroke="{AppThemeBinding Dark={StaticResource BackGroundDark}, Light=White}"
StrokeThickness="0"
StrokeShape="RoundRectangle 12">
Expand Down
39 changes: 26 additions & 13 deletions FlowHub.Main/Views/UpSertExpendituresPopUp.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,32 @@ public UpSertExpendituresPopUp(UpSertExpenditureVM vm)
this.BindingContext = vm;
viewModel.PageLoadedCommand.Execute(null);

#if ANDROID
var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
var orientation = mainDisplayInfo.Orientation;
var width = mainDisplayInfo.Width;
var height = mainDisplayInfo.Height;
var density = mainDisplayInfo.Density;
var smallestWidth = Math.Min(width, height) * density;
var popupWidth = smallestWidth * 0.115;

var popupHeight = (smallestWidth * 0.13) > 401 ? 350 : smallestWidth * 0.13;
Size = new Size(popupWidth, popupHeight);
#elif WINDOWS
//#if ANDROID
// var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
// var orientation = mainDisplayInfo.Orientation;
// var width = mainDisplayInfo.Width;
// var height = mainDisplayInfo.Height;
// var density = mainDisplayInfo.Density;
// var smallestWidth = Math.Min(width, height) / density;
// var popupWidth = smallestWidth * 0.9;

// double popupHeight = 0;
// if (smallestWidth < 415)
// {
// if ((smallestWidth * 0.13) > 401)
// {
// popupHeight = 350;
// }
// else
// {
// popupHeight = (double)(smallestWidth * 0.92);
// }

// }
// //else if(smallestWidth)

// Size = new Size(popupWidth, popupHeight);
#if WINDOWS
this.Size = new Size(400, 400);
#endif
viewModel.PropertyChanged += ViewModel_PropertyChanged;
Expand All @@ -46,7 +60,6 @@ private void ViewModel_PropertyChanged(object sender, System.ComponentModel.Prop
}
}



private void UnitPrice_TextChanged(object sender, TextChangedEventArgs e)
{
Expand Down
39 changes: 39 additions & 0 deletions FlowHub.Models/ExpendituresModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LiteDB;
using System.ComponentModel;

namespace FlowHub.Models;

Expand All @@ -18,7 +19,45 @@ public class ExpendituresModel
public DateTime UpdatedDateTime { get; set; } = DateTime.UtcNow;
public string? Comment { get; set; }
public string Currency { get; set; } = string.Empty;
public ExpenditureCategory Category { get; set; }
public string? PlatformModel { get; set; }
public bool UpdateOnSync { get; set; } = false;
public string UserId { get; set; }
}

public enum ExpenditureCategory
{
[Description("Transportation")]
Transportation,
[Description("Food and Dining")]
FoodAndDining,
[Description("Entertainment")]
Entertainment,
[Description("Shopping")]
Shopping,
[Description("Utilities")]
Utilities,
[Description("Rent")]
Rent,
[Description("Health and Fitness")]
HealthAndFitness,
[Description("Travel")]
Travel,
[Description("Education")]
Education,
[Description("Gifts and Transfers")]
GiftsAndDonations,
[Description("Other")]
Other
//[Description("Taxes")]
//Taxes,
//[Description("Insurance")]
//Insurance,
//[Description("Fees and Charges")]
//FeesAndCharges,
//[Description("Personal Care")]
//PersonalCare,
//[Description("Mortgage")]
//Mortgage,

}

0 comments on commit 8bb207a

Please sign in to comment.