Skip to content

Commit

Permalink
Merge pull request MoneyFox#3203 from NPadrutt/budget-overview-page
Browse files Browse the repository at this point in the history
order payments on budget overview and simplify some xaml
  • Loading branch information
NPadrutt authored Jan 22, 2024
2 parents a50637d + ce2a0ae commit 04077c5
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static void RegisterPayments(this AppDbContext db, params TestData.IPayme
{
foreach (var testPayment in payments)
{
RegisterPayment(db, testPayment);
RegisterPayment(db: db, testPayment: testPayment);
}

db.SaveChanges();
Expand Down Expand Up @@ -44,7 +44,6 @@ public static Payment RegisterPayment(this AppDbContext db, TestData.IPayment te
testPayment.Id = dbPayment.Id;
testPayment.ChargedAccount.Id = dbPayment.ChargedAccount.Id;
testPayment.Category!.Id = category.Id;

if (testPayment.TargetAccount is not null && dbPayment.TargetAccount is not null)
{
testPayment.TargetAccount.Id = dbPayment.TargetAccount.Id;
Expand Down
6 changes: 3 additions & 3 deletions Src/MoneyFox.Ui/MoneyFox.Ui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Budget\BudgetOverview\BudgetOverviewPage.xaml.cs">
<DependentUpon>BudgetOverviewPage.xaml</DependentUpon>
<SubType>Code</SubType>
<DependentUpon>BudgetOverviewPage.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>

Expand Down Expand Up @@ -282,7 +282,7 @@
<SubType>Designer</SubType>
</MauiXaml>
<MauiXaml Update="Views\Budget\BudgetOverview\BudgetOverviewPage.xaml">
<SubType>Designer</SubType>
<SubType>Designer</SubType>
</MauiXaml>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class AccountViewModel : ObservableObject
{
private DateTime created;
private decimal currentBalance;
private int id;
private readonly int id;
private bool isExcluded;
private DateTime? lastModified;
private string name = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ScrollView Padding="15,0,15,0">
<StackLayout Spacing="6">
<accountModification:ModifyAccountContentView />
<Button Command="{Binding SaveCommand}"
<Button Command="{Binding SaveCommand}"
CommandParameter="{Binding SelectedAccountVm.IsValid}"
Text="{x:Static resources:Translations.SaveLabel}" />
</StackLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public EditAccountViewModel(IMediator mediator, IDialogService dialogService, IN
this.mediator = mediator;
this.dialogService = dialogService;
this.navigationService = navigationService;

IsEdit = true;
}

Expand Down
6 changes: 3 additions & 3 deletions Src/MoneyFox.Ui/Views/Budget/BudgetListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<converter:AmountFormatConverter x:Key="AmountFormatConverter" />
</ContentPage.Resources>

<Grid IsClippedToBounds="False" RowDefinitions="40, Auto, *">
<Grid RowDefinitions="40, *" RowSpacing="6">
<Button
Grid.Row="0"
Margin="0,0,16,0"
Expand All @@ -27,7 +27,7 @@
VerticalOptions="Center"
Command="{Binding GoToAddBudgetCommand}" />

<CollectionView Grid.Row="2"
<CollectionView Grid.Row="1"
BackgroundColor="Transparent"
ItemsSource="{Binding Budgets}"
SelectionMode="None">
Expand Down Expand Up @@ -76,7 +76,7 @@
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>

<CollectionView.EmptyView>
<Grid>
<Label Style="{StaticResource TextSubheadSecondary}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
<converter:AmountFormatConverter x:Key="AmountFormatConverter" />
</ContentPage.Resources>

<Grid RowDefinitions="60, Auto, *">
<Grid RowDefinitions="50, *" RowSpacing="6">
<Button
Grid.Row="0"
Margin="0,0,16,0"
HorizontalOptions="End"
VerticalOptions="Center"
CornerRadius="22"
WidthRequest="60"
Padding="6"
Expand All @@ -40,7 +38,7 @@
Header="{x:Static resources:Translations.PaymentsInBudgetHeader}"
ItemsSource="{Binding PaymentsGroups}"
SelectionMode="Single">

<CollectionView.GroupHeaderTemplate>
<DataTemplate x:DataType="budgetOverview:PaymentDayGroup">
<Grid Padding="18, 0, 18, 0">
Expand All @@ -50,14 +48,14 @@
</DataTemplate>
</CollectionView.GroupHeaderTemplate>


<CollectionView.ItemTemplate>
<DataTemplate x:DataType="budgetOverview:BudgetPaymentViewModel">
<Grid ColumnDefinitions="80, *, 18" >
<Grid ColumnDefinitions="80, *, 18">
<controls:Card Grid.Column="1"
HeightRequest="80"
Padding="12"
Margin="0,6,0,0" >
Padding="12"
Margin="0,6,0,0">
<Border.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding ViewModel.GoToEditPaymentCommand, Source={x:Reference This}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class BudgetOverviewViewModel(ISender sender, ISettingsFacade sett
private ObservableCollection<PaymentDayGroup> paymentsGroups = [];

public AsyncRelayCommand GoToEditCommand => new(() => navigationService.GoTo<EditBudgetViewModel>(budgetId));
public AsyncRelayCommand<BudgetPaymentViewModel> GoToEditPaymentCommand => new((vm) => navigationService.GoTo<EditPaymentViewModel>(vm!.Id));
public AsyncRelayCommand<BudgetPaymentViewModel> GoToEditPaymentCommand => new(vm => navigationService.GoTo<EditPaymentViewModel>(vm!.Id));

public ObservableCollection<PaymentDayGroup> PaymentsGroups
{
Expand Down Expand Up @@ -48,18 +48,19 @@ private async Task LoadData()
BudgetName = await sender.Send(new GetBudgetNameById.Query(new(budgetId)));
var currency = settingsFacade.DefaultCurrency;
var paymentData = await sender.Send(new GetPaymentsInBudget.Query(new(budgetId)));
var viewModels = paymentData.Select(
p => new BudgetPaymentViewModel
{
Id = p.PaymentId,
Account = p.Account,
Date = DateOnly.FromDateTime(p.Date),
Amount = new(amount: p.Amount, currencyAlphaIsoCode: currency),
Category = p.Category,
IsCleared = p.IsCleared,
IsRecurring = p.IsRecurring,
Note = p.Note
});
var viewModels = paymentData.OrderByDescending(d => d.Date)
.Select(
p => new BudgetPaymentViewModel
{
Id = p.PaymentId,
Account = p.Account,
Date = DateOnly.FromDateTime(p.Date),
Amount = new(amount: p.Amount, currencyAlphaIsoCode: currency),
Category = p.Category,
IsCleared = p.IsCleared,
IsRecurring = p.IsRecurring,
Note = p.Note
});

PaymentsGroups = new(viewModels.GroupBy(pd => pd.Date).Select(g => new PaymentDayGroup(date: g.Key, payments: g.ToList())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public class BudgetPaymentViewModel : ObservableObject
private string account = string.Empty;
private Money amount = Money.Zero("USD");
private string category = string.Empty;
private string note = string.Empty;
private DateOnly date;
private bool isCleared;
private bool isRecurring;
private string note = string.Empty;

public int Id { get; init; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace MoneyFox.Ui.Views.Categories.ModifyCategory;
public class CategoryViewModel : ObservableObject
{
private DateTime created;
private int id;
private readonly int id;
private DateTime? lastModified;
private string name = "";
private string? note;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public abstract class ModifyCategoryViewModel(IMediator mediator, IDialogService
{
private CategoryViewModel selectedCategory = null!;

public AsyncRelayCommand SaveCommand => new(async () => await SaveCategoryBaseAsync(), canExecute: () => SelectedCategory.IsValid);
public AsyncRelayCommand SaveCommand => new(execute: async () => await SaveCategoryBaseAsync(), canExecute: () => SelectedCategory.IsValid);

public CategoryViewModel SelectedCategory
{
Expand Down
23 changes: 5 additions & 18 deletions Src/MoneyFox.Ui/Views/Payments/PaymentList/PaymentListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@
<paymentList:DateGroupCardOpacityConverter x:Key="DateGroupCardOpacityConverter" />
</ContentPage.Resources>

<Grid IsClippedToBounds="False"
RowDefinitions="50, *">
<Grid ColumnDefinitions="*,Auto ,66 ,6 ,66">
<ImageButton Grid.Column="2"
Command="{Binding ShowFilterCommand}"
Margin="0,0,5,0"
Padding="0"
BorderWidth="0"
<Grid RowDefinitions="50, *" RowSpacing="6">
<HorizontalStackLayout HorizontalOptions="End" Spacing="6" Margin="0,0, 16,0">
<ImageButton Command="{Binding ShowFilterCommand}"
HeightRequest="44"
HorizontalOptions="End"
VerticalOptions="Start"
WidthRequest="66">
<ImageButton.Source>
<FontImageSource FontFamily="MaterialIcons"
Expand All @@ -39,14 +32,8 @@
</ImageButton.Source>
</ImageButton>

<ImageButton Margin="0,0,5,0"
Grid.Column="4"
Padding="0"
BorderWidth="0"
Command="{Binding GoToAddPaymentCommand}"
<ImageButton Command="{Binding GoToAddPaymentCommand}"
HeightRequest="44"
HorizontalOptions="End"
VerticalOptions="Start"
WidthRequest="66"
Style="{StaticResource PrimaryImageButton}">
<ImageButton.Source>
Expand All @@ -55,7 +42,7 @@
Color="White" />
</ImageButton.Source>
</ImageButton>
</Grid>
</HorizontalStackLayout>

<CollectionView Grid.Row="1"
ItemsSource="{Binding PaymentDayGroups}"
Expand Down

0 comments on commit 04077c5

Please sign in to comment.