Vehicle detail page, more models

This commit is contained in:
Selim Mustafaev 2021-03-15 21:48:25 +03:00
parent a622c84467
commit ccb5254171
22 changed files with 622 additions and 34 deletions

Binary file not shown.

View File

@ -119,7 +119,13 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ButtonCell.xaml.cs">
<DependentUpon>ButtonCell.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\PlateNumber.cs" />
<Compile Include="Controls\TextCell.xaml.cs">
<DependentUpon>TextCell.xaml</DependentUpon>
</Compile>
<Compile Include="DialogService.cs" />
<Compile Include="Pages\AuthPage.xaml.cs">
<DependentUpon>AuthPage.xaml</DependentUpon>
@ -159,6 +165,14 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Controls\ButtonCell.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\TextCell.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\AuthPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,22 @@
<UserControl
x:Class="AutoCat.Controls.ButtonCell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AutoCat.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="80"
d:DesignWidth="500">
<Grid ColumnSpacing="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TitleBox" Grid.Column="0" Text="Name" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="18"/>
<Button x:Name="ValueButton" Grid.Column="1" Content="Value" HorizontalAlignment="Right" VerticalAlignment="Stretch"
MinWidth="60" FontSize="18" Foreground="{StaticResource SystemBaseMediumColor}" Style="{ThemeResource ButtonRevealStyle}"/>
</Grid>
</UserControl>

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace AutoCat.Controls
{
public sealed partial class ButtonCell : UserControl
{
#region Dependency properties
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnTitleChanged));
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnValueChanged));
public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnValueChanged));
#endregion
#region Properties
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public string Value
{
get => (string)GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}
#endregion
public ButtonCell()
{
this.InitializeComponent();
}
private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ButtonCell cell && e.NewValue is string title)
{
cell.TitleBox.Text = title ?? "";
}
}
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ButtonCell cell && e.NewValue is string value)
{
cell.ValueButton.Content = value ?? "";
}
}
private static void OnDefaultValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ButtonCell cell && e.NewValue is string value)
{
cell.ValueButton.Content = value ?? "";
}
}
}
}

View File

@ -0,0 +1,21 @@
<UserControl
x:Class="AutoCat.Controls.TextCell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AutoCat.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="80"
d:DesignWidth="500">
<Grid ColumnSpacing="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="TitleBox" Grid.Column="0" Text="Name" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="18"/>
<TextBlock x:Name="ValueBox" Grid.Column="1" Text="Value" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="18" Foreground="{StaticResource SystemBaseMediumColor}"/>
</Grid>
</UserControl>

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace AutoCat.Controls
{
public sealed partial class TextCell : UserControl
{
#region Dependency properties
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnTitleChanged));
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnValueChanged));
#endregion
#region Properties
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public string Value
{
get => (string)GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}
#endregion
public TextCell()
{
this.InitializeComponent();
}
private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if(d is TextCell cell && e.NewValue is string title)
{
cell.TitleBox.Text = title ?? "";
}
}
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TextCell cell && e.NewValue is string value)
{
cell.ValueBox.Text = value ?? "";
}
}
}
}

View File

@ -32,8 +32,6 @@ namespace AutoCat.Pages
this.InitializeComponent();
}
private async void Login_Click(object sender, RoutedEventArgs e)
{
try

View File

@ -7,6 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:model="using:AutoCatCore.Model"
xmlns:converters="using:AutoCatCore.Converters"
xmlns:custom="using:AutoCat.Controls"
mc:Ignorable="d"
d:Width="600"
@ -14,16 +15,77 @@
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<converters:SteeringWheelPositionConverter x:Key="SWToStringConverter"/>
<DataTemplate x:Key="VehicleTemplate" x:DataType="model:Vehicle">
<StackPanel Orientation="Vertical" Margin="0,8" Spacing="4">
<TextBlock Text="{x:Bind Brand.Name.Original}"/>
<custom:PlateView Number="{x:Bind Number}" Height="40"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="VehicleDetailTemplateNew" x:DataType="model:Vehicle">
<Grid Margin="16" RowSpacing="16" ColumnSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.ColumnSpan="2" Orientation="Horizontal" Spacing="8">
<Image Source="{x:Bind Brand.Logo}" Height="50"/>
<TextBlock Text="{x:Bind Brand.Name.Original}" FontSize="24" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Padding="8" Orientation="Vertical" Spacing="8" Background="#222">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="General"/>
<Line Stroke="#444" StrokeThickness="1" Stretch="Fill" X1="0" X2="1"/>
<custom:TextCell Title="Year" Value="{x:Bind Year}"/>
<custom:TextCell Title="Color" Value="{x:Bind Color}"/>
<custom:TextCell Title="Category" Value="{x:Bind Category}"/>
<custom:TextCell Title="Steering wheel position" Value="{x:Bind IsRightWheel, Converter={StaticResource SWToStringConverter}}"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical" Spacing="8" Padding="8" Background="#222">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="Identifiers"/>
<Line Stroke="#444" StrokeThickness="1" Stretch="Fill" X1="0" X2="1"/>
<custom:TextCell Title="Plate number" Value="{x:Bind Number}"/>
<custom:TextCell Title="VIN" Value="{x:Bind Vin1}"/>
<custom:TextCell Title="STS" Value="{x:Bind Sts}"/>
<custom:TextCell Title="PTS" Value="{x:Bind Pts}"/>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="0" Orientation="Vertical" Spacing="8" Padding="8" Background="#222">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="Engine"/>
<Line Stroke="#444" StrokeThickness="1" Stretch="Fill" X1="0" X2="1"/>
<custom:TextCell Title="Number" Value="{x:Bind Engine.Number}"/>
<custom:TextCell Title="Fuel type" Value="{x:Bind Engine.FuelType}"/>
<custom:TextCell Title="Volume (cm3)" Value="{x:Bind Engine.Volume}"/>
<custom:TextCell Title="Power (HP)" Value="{x:Bind Engine.PowerHp}"/>
<custom:TextCell Title="Power (Kw)" Value="{x:Bind Engine.PowerKw}"/>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Vertical" Spacing="8" Padding="8" Background="#222">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="History"/>
<Line Stroke="#444" StrokeThickness="1" Stretch="Fill" X1="0" X2="1"/>
<custom:ButtonCell Title="Events" Value="{x:Bind Events.Count}"/>
<custom:ButtonCell Title="OSAGO" Value="{x:Bind OsagoContracts.Count}"/>
<custom:ButtonCell Title="Owners" Value="{x:Bind OwnershipPeriods.Count}"/>
<custom:ButtonCell Title="Photos" Value="{x:Bind Photos.Count}"/>
<custom:ButtonCell Title="Ads" Value="{x:Bind Ads.Count}"/>
</StackPanel>
</Grid>
</DataTemplate>
</Page.Resources>
<controls:MasterDetailsView Name="MasterDetail" Loaded="MasterDetail_Loaded" ItemsSource="{x:Bind viewModel.Vehicles}"
ItemTemplate="{StaticResource VehicleTemplate}" DetailsTemplate="{StaticResource VehicleDetailTemplate}">
ItemTemplate="{StaticResource VehicleTemplate}" DetailsTemplate="{StaticResource VehicleDetailTemplateNew}">
<controls:MasterDetailsView.MasterHeader>
<Grid>

View File

@ -2,20 +2,38 @@
x:Class="AutoCat.Resources.Templates.ResourceDictStub"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:model="using:AutoCatCore.Model">
xmlns:model="using:AutoCatCore.Model"
xmlns:controls="using:AutoCat.Controls">
<DataTemplate x:Key="VehicleDetailTemplate" x:DataType="model:Vehicle">
<Grid Margin="16" RowSpacing="16">
<Grid Margin="16" RowSpacing="16" ColumnSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Background="Coral" Spacing="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.ColumnSpan="2" Orientation="Horizontal" Spacing="8">
<Image Source="{Binding Brand.Logo}" Height="50"/>
<TextBlock Text="{Binding Brand.Name.Original}" FontSize="24" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="0" Padding="8" Orientation="Vertical" Spacing="8" Background="#222">
<TextBlock FontSize="18" FontWeight="SemiBold" Text="General"/>
<Line Stroke="#444" StrokeThickness="1" Stretch="Fill" X1="0" X2="1"/>
<controls:TextCell Title="Year" Value="qwe"/>
<controls:TextCell Title="Color" Value="{Binding Brand.Name.Original}"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical" Spacing="8" Background="#222">
<TextBlock FontSize="24" Text="Numbers"/>
</StackPanel>
</Grid>
</DataTemplate>

View File

@ -14,4 +14,10 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="Windows.Foundation.UniversalApiContract">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\References\10.0.19041.0\Windows.Foundation.UniversalApiContract\10.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI.Xaml.Data;
namespace AutoCatCore.Converters
{
public class SteeringWheelPositionConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if(value is bool isRightWheel)
{
return isRightWheel ? "Right" : "Left";
}
else
{
return "";
}
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if(value is string wheelPosition)
{
return wheelPosition == "Right";
}
else
{
return false;
}
}
}
}

View File

@ -0,0 +1,40 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoCatCore.Model
{
public class Osago
{
[JsonProperty("date")]
public double Date { get; set; }
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("vin")]
public string Vin { get; set; }
[JsonProperty("plateNumber")]
public string PlateNumber { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("status")]
public string Status { get; set; }
[JsonProperty("restrictions")]
public string Restrictions { get; set; }
[JsonProperty("insurant")]
public string Insurant { get; set; }
[JsonProperty("owner")]
public string Owner { get; set; }
[JsonProperty("usageRegion")]
public string UsageRegion { get; set; }
}
}

View File

@ -1,41 +1,33 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleName
{
[JsonProperty("original")]
public string Original { get; set; }
[JsonProperty("normalized")]
public string Normalized { get; set; }
}
public class VehicleBrand
{
[JsonProperty("name")]
public VehicleName Name { get; set; }
[JsonProperty("logo")]
public string Logo { get; set; }
}
public class VehicleModel
{
[JsonProperty("name")]
public VehicleName Name { get; set; }
}
public class Vehicle
{
[Key]
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("currentNumber")]
public string CurrentNumber { get; set; }
[JsonProperty("vin1")]
public string Vin1 { get; set; }
[JsonProperty("vin2")]
public string Vin2 { get; set; }
[JsonProperty("sts")]
public string Sts { get; set; }
[JsonProperty("pts")]
public string Pts { get; set; }
[JsonProperty("brand")]
public VehicleBrand Brand { get; set; }
@ -50,5 +42,38 @@ namespace AutoCatCore.Model
[JsonProperty("category")]
public string Category { get; set; }
[JsonProperty("isRightWheel")]
public bool? IsRightWheel { get; set; }
[JsonProperty("isJapanese")]
public bool? IsJapanese { get; set; }
[JsonProperty("addedDate")]
public double AddedDate { get; set; }
[JsonProperty("updatedDate")]
public double UpdatedDate { get; set; }
[JsonProperty("addedBy")]
public string AddedBy { get; set; }
[JsonProperty("engine")]
public VehicleEngine Engine { get; set; }
[JsonProperty("photos")]
public List<VehiclePhoto> Photos { get; set; }
[JsonProperty("events")]
public List<VehicleEvent> Events { get; set; }
[JsonProperty("osagoContracts", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<Osago> OsagoContracts { get; set; } = new List<Osago>();
[JsonProperty("ownershipPeriods", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<VehicleOwnershipPeriod> OwnershipPeriods { get; set; } = new List<VehicleOwnershipPeriod>();
[JsonProperty("ads")]
public List<VehicleAd> Ads { get; set; }
}
}

View File

@ -0,0 +1,39 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleAd
{
[Key]
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("price")]
public string Price { get; set; }
[JsonProperty("date")]
public double Date { get; set; }
[JsonProperty("mileage")]
public string Mileage { get; set; }
[JsonProperty("region")]
public string Region { get; set; }
[JsonProperty("city")]
public string City { get; set; }
[JsonProperty("adDescription")]
public string AdDescription { get; set; }
[JsonProperty("photos")]
public List<string> Photos { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleBrand
{
[JsonProperty("name")]
public VehicleName Name { get; set; }
[JsonProperty("logo")]
public string Logo { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleEngine
{
[JsonProperty("number")]
public string Number { get; set; }
[JsonProperty("volume")]
public int? Volume { get; set; }
[JsonProperty("powerKw")]
public double? PowerKw { get; set; }
[JsonProperty("powerHp")]
public double? PowerHp { get; set; }
[JsonProperty("fuelType")]
public string FuelType { get; set; }
}
}

View File

@ -0,0 +1,33 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleEvent
{
[Key]
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("date")]
public double Date { get; set; }
[JsonProperty("latitude")]
public double Latitude { get; set; }
[JsonProperty("longitude")]
public double Longitude { get; set; }
[JsonProperty("speed")]
public double Speed { get; set; }
[JsonProperty("direction")]
public double Direction { get; set; }
[JsonProperty("address")]
public string Address { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleModel
{
[JsonProperty("name")]
public VehicleName Name { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleName
{
[JsonProperty("original")]
public string Original { get; set; }
[JsonProperty("normalized")]
public string Normalized { get; set; }
}
}

View File

@ -0,0 +1,43 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoCatCore.Model
{
public class VehicleOwnershipPeriod
{
[JsonProperty("lastOperation")]
public string LastOperation { get; set; }
[JsonProperty("ownerType")]
public string OwnerType { get; set; }
[JsonProperty("from")]
public Int64 From { get; set; }
[JsonProperty("to")]
public Int64 To { get; set; }
[JsonProperty("region")]
public string Region { get; set; }
[JsonProperty("registrationRegion")]
public string RegistrationRegion { get; set; }
[JsonProperty("locality")]
public string Locality { get; set; }
[JsonProperty("code")]
public string Code { get; set; }
[JsonProperty("street")]
public string Street { get; set; }
[JsonProperty("building")]
public string Building { get; set; }
[JsonProperty("inn")]
public string Inn { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoCatCore.Model
{
public class VehiclePhoto
{
[JsonProperty("brand")]
public string Brand { get; set; }
[JsonProperty("model")]
public string Model { get; set; }
[JsonProperty("date")]
public double Date { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
}
}