From 6259d182e45277bd04a460491e171cb311a4aa63 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Sat, 30 Dec 2023 23:18:14 +0300 Subject: [PATCH] Refactoring history page --- AutoCat/Pages/HistoryPage.axaml | 6 +-- AutoCat/Pages/ReportPage.axaml | 8 +++- AutoCat/Pages/ReportPage.axaml.cs | 21 +++++++++ AutoCat/Views/MasterDetailView.axaml | 30 +++++++++++++ AutoCat/Views/MasterDetailView.axaml.cs | 60 +++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 AutoCat/Views/MasterDetailView.axaml create mode 100644 AutoCat/Views/MasterDetailView.axaml.cs diff --git a/AutoCat/Pages/HistoryPage.axaml b/AutoCat/Pages/HistoryPage.axaml index 8fcb507..2cdae51 100644 --- a/AutoCat/Pages/HistoryPage.axaml +++ b/AutoCat/Pages/HistoryPage.axaml @@ -3,7 +3,6 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:pages="clr-namespace:AutoCat.Pages" - xmlns:utils="using:AutoCat.Utils" xmlns:vm="using:AutoCat.ViewModels" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" @@ -22,8 +21,9 @@ + ItemTemplate="{StaticResource VehicleCell}" + Name="VehiclesList"/> - + diff --git a/AutoCat/Pages/ReportPage.axaml b/AutoCat/Pages/ReportPage.axaml index 60139d8..2dee510 100644 --- a/AutoCat/Pages/ReportPage.axaml +++ b/AutoCat/Pages/ReportPage.axaml @@ -2,7 +2,11 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:pages="clr-namespace:AutoCat.Pages" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="AutoCat.Pages.ReportPage"> - Welcome to Avalonia! + x:Class="AutoCat.Pages.ReportPage" + x:DataType="pages:ReportPage" + x:CompileBindings="True"> + + diff --git a/AutoCat/Pages/ReportPage.axaml.cs b/AutoCat/Pages/ReportPage.axaml.cs index 27b93cd..0011543 100644 --- a/AutoCat/Pages/ReportPage.axaml.cs +++ b/AutoCat/Pages/ReportPage.axaml.cs @@ -1,3 +1,6 @@ +using System; +using System.ComponentModel; +using AutoCatCore.Model; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; @@ -6,8 +9,26 @@ namespace AutoCat.Pages; public partial class ReportPage : UserControl { + #region Dependency properties + + public static readonly StyledProperty VehicleProperty = + AvaloniaProperty.Register(nameof(Vehicle)); + + #endregion + + #region Properties + + public Vehicle Vehicle + { + get => (Vehicle)GetValue(VehicleProperty); + set => SetValue(VehicleProperty, value); + } + + #endregion + public ReportPage() { InitializeComponent(); + DataContext = this; } } \ No newline at end of file diff --git a/AutoCat/Views/MasterDetailView.axaml b/AutoCat/Views/MasterDetailView.axaml new file mode 100644 index 0000000..e1d117f --- /dev/null +++ b/AutoCat/Views/MasterDetailView.axaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/AutoCat/Views/MasterDetailView.axaml.cs b/AutoCat/Views/MasterDetailView.axaml.cs new file mode 100644 index 0000000..966cf97 --- /dev/null +++ b/AutoCat/Views/MasterDetailView.axaml.cs @@ -0,0 +1,60 @@ +using System.Collections; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Avalonia.Markup.Xaml; + +namespace AutoCat.Views; + +public partial class MasterDetailView : UserControl +{ + #region Dependency properties + + public static readonly StyledProperty ItemTemplateProperty = + AvaloniaProperty.Register(nameof(ItemTemplate)); + + public static readonly StyledProperty DetailTemplateProperty = + AvaloniaProperty.Register(nameof(DetailTemplate)); + + public static readonly StyledProperty EmptyDetailTemplateProperty = + AvaloniaProperty.Register(nameof(EmptyDetailTemplate)); + + public static readonly StyledProperty ItemsSourceProperty = + AvaloniaProperty.Register(nameof(ItemsSource)); + + #endregion + + #region Properties + + public IDataTemplate? ItemTemplate + { + get => GetValue(ItemTemplateProperty); + set => SetValue(ItemTemplateProperty, value); + } + + public IDataTemplate? DetailTemplate + { + get => GetValue(DetailTemplateProperty); + set => SetValue(DetailTemplateProperty, value); + } + + public IDataTemplate? EmptyDetailTemplate + { + get => GetValue(EmptyDetailTemplateProperty); + set => SetValue(EmptyDetailTemplateProperty, value); + } + + public IEnumerable? ItemsSource + { + get => GetValue(ItemsSourceProperty); + set => SetValue(ItemsSourceProperty, value); + } + + #endregion + + public MasterDetailView() + { + InitializeComponent(); + DataContext = this; + } +} \ No newline at end of file