History screen refactoring
This commit is contained in:
parent
1c5d97b8a1
commit
8b87d916d9
@ -22,7 +22,7 @@ public partial class App : Application
|
|||||||
services.AddSingleton<IApiService, ApiService>();
|
services.AddSingleton<IApiService, ApiService>();
|
||||||
|
|
||||||
// ViewModels
|
// ViewModels
|
||||||
services.AddTransient<HistoryListViewModel>();
|
services.AddTransient<HistoryViewModel>();
|
||||||
services.AddTransient<AuthWindowViewModel>();
|
services.AddTransient<AuthWindowViewModel>();
|
||||||
services.AddTransient<MainWindowViewModel>();
|
services.AddTransient<MainWindowViewModel>();
|
||||||
|
|
||||||
|
|||||||
@ -1,52 +0,0 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
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:utils="using:AutoCat.Utils"
|
|
||||||
xmlns:vm="using:AutoCat.ViewModels"
|
|
||||||
xmlns:mocks="using:AutoCat.Mocks"
|
|
||||||
xmlns:views="using:AutoCat.Views"
|
|
||||||
xmlns:ext="using:AutoCat.Extensions"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="350" d:DesignHeight="550"
|
|
||||||
x:Class="AutoCat.Pages.HistoryListPage"
|
|
||||||
x:DataType="vm:HistoryListViewModel"
|
|
||||||
x:CompileBindings="True"
|
|
||||||
DataContext="{utils:ViewModelProvider vm:HistoryListViewModel}"
|
|
||||||
Design.DataContext="mocks:HistoryListViewModelMock">
|
|
||||||
|
|
||||||
<UserControl.Resources>
|
|
||||||
<ext:DateConverter x:Key="DateConverter"/>
|
|
||||||
</UserControl.Resources>
|
|
||||||
|
|
||||||
<ListBox ItemsSource="{Binding Vehicles}">
|
|
||||||
<ListBox.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<StackPanel Orientation="Vertical" Margin="0,4">
|
|
||||||
<Grid ColumnDefinitions="*">
|
|
||||||
<TextBlock Text="{Binding Brand.Name.Original}"/>
|
|
||||||
</Grid>
|
|
||||||
<Grid ColumnDefinitions="* Auto" RowDefinitions="*,*">
|
|
||||||
<views:PlateView Grid.RowSpan="2" Number="{Binding Number}"/>
|
|
||||||
<TextBlock
|
|
||||||
Grid.Column="1"
|
|
||||||
Grid.Row="0"
|
|
||||||
Margin="16,0,0,0"
|
|
||||||
FontSize="11"
|
|
||||||
Foreground="{DynamicResource SecondaryText}"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Text="{Binding UpdatedDate, Converter={StaticResource DateConverter}}"/>
|
|
||||||
<TextBlock
|
|
||||||
Grid.Column="1"
|
|
||||||
Grid.Row="1"
|
|
||||||
Margin="16,0,0,0"
|
|
||||||
FontSize="11"
|
|
||||||
Foreground="{DynamicResource TertiaryText}"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Text="{Binding AddedDate, Converter={StaticResource DateConverter}}"/>
|
|
||||||
</Grid>
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListBox.ItemTemplate>
|
|
||||||
</ListBox>
|
|
||||||
|
|
||||||
</UserControl>
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
|
|
||||||
namespace AutoCat.Pages;
|
|
||||||
|
|
||||||
public partial class HistoryListPage : UserControl
|
|
||||||
{
|
|
||||||
public HistoryListPage()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,10 +3,26 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:pages="clr-namespace:AutoCat.Pages"
|
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"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="AutoCat.Pages.HistoryPage">
|
x:Class="AutoCat.Pages.HistoryPage"
|
||||||
|
x:DataType="vm:HistoryViewModel"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
DataContext="{utils:ViewModelProvider vm:HistoryViewModel}">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceInclude Source="../Templates/VehicleCell.axaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="300, Auto, *">
|
<Grid ColumnDefinitions="300, Auto, *">
|
||||||
<pages:HistoryListPage/>
|
<ListBox ItemsSource="{Binding Vehicles}"
|
||||||
|
ItemTemplate="{StaticResource VehicleCell}"/>
|
||||||
<GridSplitter Grid.Column="1" ResizeDirection="Columns"/>
|
<GridSplitter Grid.Column="1" ResizeDirection="Columns"/>
|
||||||
<pages:ReportPage Grid.Column="2"/>
|
<pages:ReportPage Grid.Column="2"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
36
AutoCat/Templates/VehicleCell.axaml
Normal file
36
AutoCat/Templates/VehicleCell.axaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:models="using:AutoCatCore.Model"
|
||||||
|
xmlns:views="using:AutoCat.Views"
|
||||||
|
xmlns:ext="using:AutoCat.Extensions">
|
||||||
|
|
||||||
|
<ext:DateConverter x:Key="DateConverter"/>
|
||||||
|
|
||||||
|
<DataTemplate DataType="{x:Type models:Vehicle}" x:Key="VehicleCell">
|
||||||
|
<StackPanel Orientation="Vertical" Margin="0,4">
|
||||||
|
<Grid ColumnDefinitions="*">
|
||||||
|
<TextBlock Text="{Binding Brand.Name.Original}"/>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="* Auto" RowDefinitions="*,*">
|
||||||
|
<views:PlateView Grid.RowSpan="2" Number="{Binding Number}"/>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.Row="0"
|
||||||
|
Margin="16,0,0,0"
|
||||||
|
FontSize="11"
|
||||||
|
Foreground="{DynamicResource SecondaryText}"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Text="{Binding UpdatedDate, Converter={StaticResource DateConverter}}"/>
|
||||||
|
<TextBlock
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="16,0,0,0"
|
||||||
|
FontSize="11"
|
||||||
|
Foreground="{DynamicResource TertiaryText}"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Text="{Binding AddedDate, Converter={StaticResource DateConverter}}"/>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@ -7,7 +7,7 @@ using DynamicData;
|
|||||||
|
|
||||||
namespace AutoCat.ViewModels;
|
namespace AutoCat.ViewModels;
|
||||||
|
|
||||||
public class HistoryListViewModel: ViewModelBase
|
public class HistoryViewModel: ViewModelBase
|
||||||
{
|
{
|
||||||
#region Dependencies
|
#region Dependencies
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ public class HistoryListViewModel: ViewModelBase
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public HistoryListViewModel(IApiService apiService)
|
public HistoryViewModel(IApiService apiService)
|
||||||
{
|
{
|
||||||
_apiService = apiService;
|
_apiService = apiService;
|
||||||
Vehicles = new ObservableCollection<Vehicle>();
|
Vehicles = new ObservableCollection<Vehicle>();
|
||||||
@ -35,8 +35,6 @@ public class HistoryListViewModel: ViewModelBase
|
|||||||
var pagedResponse = await _apiService.GetVehicles();
|
var pagedResponse = await _apiService.GetVehicles();
|
||||||
Vehicles.Clear();
|
Vehicles.Clear();
|
||||||
Vehicles.AddRange(pagedResponse.Items);
|
Vehicles.AddRange(pagedResponse.Items);
|
||||||
|
|
||||||
Console.WriteLine($"Loaded vehicles: {Vehicles.Count}");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -51,7 +51,7 @@ public partial class PlateView : UserControl
|
|||||||
{
|
{
|
||||||
if (Bounds.Height > 0)
|
if (Bounds.Height > 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"=== new height: {Bounds.Height}");
|
//Console.WriteLine($"=== new height: {Bounds.Height}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user