Skip to content

Commit

Permalink
chore: add custom time span to grooming services
Browse files Browse the repository at this point in the history
Signed-off-by: Russell Camo <[email protected]>
  • Loading branch information
russkyc committed Sep 1, 2023
1 parent 2c6d541 commit 7620d78
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 16 deletions.
15 changes: 14 additions & 1 deletion GroomWise.Application/Observables/ObservableGroomingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ public partial class ObservableGroomingService
private string? _type;

[Property(PropertyChangeType = PropertyChangeType.PropertyChanged)]
private TimeSpan? _timeSpan;
private double _hourSpan;

[Property(PropertyChangeType = PropertyChangeType.PropertyChanged)]
private double _minuteSpan;

public TimeSpan TimeSpan
{
get
{
return new TimeSpan()
.Add(TimeSpan.FromHours(HourSpan))
.Add(TimeSpan.FromMinutes(MinuteSpan));
}
}

[Property(PropertyChangeType = PropertyChangeType.PropertyChanged)]
private string? _description;
Expand Down
3 changes: 2 additions & 1 deletion GroomWise.Domain/Entities/GroomingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class GroomingService : IEntity
[BsonId]
public Guid Id { get; set; }
public string? Type { get; set; }
public TimeSpan? TimeSpan { get; set; }
public int? HourSpan { get; set; }
public int? MinuteSpan { get; set; }
public string? Description { get; set; }
}
35 changes: 35 additions & 0 deletions GroomWise.WPF/Converters/StringToVisibilityConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (C) 2023 Russell Camo (Russkyc).- All Rights Reserved
//
// Unauthorized copying or redistribution of all files, in source and binary forms via any medium
// without written, signed consent from the author is strictly prohibited.

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace GroomWise.Converters;

[ValueConversion(typeof(string), typeof(Visibility))]
public class StringToVisibilityConverter : IValueConverter
{
public static StringToVisibilityConverter Instance = new();

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string str)
{
if (string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str))
{
return Visibility.Collapsed;
}
return Visibility.Visible;
}
return Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
43 changes: 39 additions & 4 deletions GroomWise.WPF/Views/Dialogs/AddServicesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="350" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<russkyc:ModernTextBox
Name="ServiceNameBox"
Expand All @@ -49,13 +50,47 @@
HelperText="Max Length (200)"
Placeholder="Service Name"
Text="{Binding ActiveGroomingService.Type, UpdateSourceTrigger=PropertyChanged}" />
<russkyc:ModernTextBox
<russkyc:ModernComboBox
Grid.Column="1"
Margin="12,0,0,0"
VerticalAlignment="Top"
CornerRadius="5"
HelperText="Max Length (200)"
Placeholder="Service Info"
Text="{Binding ActiveCustomer.ContactNumber, UpdateSourceTrigger=PropertyChanged}" />
IsEditable="True"
IsSynchronizedWithCurrentItem="True"
Placeholder="Hours"
SelectedValue="{Binding ActiveGroomingService.HourSpan, UpdateSourceTrigger=PropertyChanged}">
<ComboBoxItem>0</ComboBoxItem>
<ComboBoxItem>1</ComboBoxItem>
<ComboBoxItem>2</ComboBoxItem>
<ComboBoxItem>3</ComboBoxItem>
<ComboBoxItem>4</ComboBoxItem>
<ComboBoxItem>5</ComboBoxItem>
<ComboBoxItem>6</ComboBoxItem>
<ComboBoxItem>7</ComboBoxItem>
<ComboBoxItem>8</ComboBoxItem>
</russkyc:ModernComboBox>
<russkyc:ModernComboBox
Grid.Column="2"
Margin="12,0,0,0"
VerticalAlignment="Top"
CornerRadius="5"
IsEditable="True"
IsSynchronizedWithCurrentItem="True"
Placeholder="Minutes"
SelectedValue="{Binding ActiveGroomingService.MinuteSpan, UpdateSourceTrigger=PropertyChanged}">
<ComboBoxItem>0</ComboBoxItem>
<ComboBoxItem>5</ComboBoxItem>
<ComboBoxItem>10</ComboBoxItem>
<ComboBoxItem>15</ComboBoxItem>
<ComboBoxItem>20</ComboBoxItem>
<ComboBoxItem>25</ComboBoxItem>
<ComboBoxItem>30</ComboBoxItem>
<ComboBoxItem>35</ComboBoxItem>
<ComboBoxItem>40</ComboBoxItem>
<ComboBoxItem>45</ComboBoxItem>
<ComboBoxItem>50</ComboBoxItem>
<ComboBoxItem>55</ComboBoxItem>
</russkyc:ModernComboBox>

</Grid>
<Grid Margin="0,12,0,0">
Expand Down
30 changes: 28 additions & 2 deletions GroomWise.WPF/Views/Templates/AppointmentServiceCardTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
x:Class="GroomWise.Views.Templates.AppointmentServiceCardTemplate"
xmlns="http:https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:GroomWise.Converters"
xmlns:d="http:https://schemas.microsoft.com/expression/blend/2008"
xmlns:dialogs="clr-namespace:GroomWise.Views.Dialogs"
xmlns:mc="http:https://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -27,6 +28,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<russkyc:ModernComboBox
Grid.Column="0"
Expand All @@ -40,13 +42,37 @@
Placeholder="Select Service"
SelectedIndex="0"
SelectedValue="{Binding GroomingService, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<russkyc:ModernButton
<Border
Grid.Column="1"
Margin="8,0,0,0"
Padding="8,3"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="{DynamicResource primary-default}"
CornerRadius="10"
IsHitTestVisible="False"
Visibility="{Binding GroomingService.Type, Converter={x:Static converters:StringToVisibilityConverter.Instance}}">
<TextBlock
HorizontalAlignment="Stretch"
FontSize="10"
Foreground="#ffffff"
Text="{Binding GroomingService.TimeSpan, StringFormat={}{0:hh':'mm}, UpdateSourceTrigger=PropertyChanged}"
TextTrimming="CharacterEllipsis" />
</Border>
<russkyc:ModernButton
Grid.Column="2"
Margin="14"
Padding="5"
HorizontalAlignment="Right"
Command="{Binding Path=DataContext.RemoveGroomingServiceCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=dialogs:AddAppointmentsView}}"
CommandParameter="{Binding}"
Content="{wpf:MaterialIconExt Kind=Close}" />
Content="{wpf:MaterialIconExt Kind=TrashCan}"
DefaultBackground="Transparent"
DefaultForeground="{DynamicResource fg-000}"
HoverBackground="{DynamicResource bg-300}"
HoverForeground="{DynamicResource fg-000}"
PressedBackground="{DynamicResource danger}"
PressedForeground="#ffffff" />
</Grid>
</Grid>
</UserControl>
32 changes: 24 additions & 8 deletions GroomWise.WPF/Views/Templates/ServiceListCardTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,30 @@
<wpf:MaterialIconExt Kind="BubbleChart" />
</TextBlock>
</Border>
<TextBlock
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
FontWeight="Medium"
IsHitTestVisible="False"
Text="{Binding Type, UpdateSourceTrigger=PropertyChanged}" />
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock
HorizontalAlignment="Left"
FontSize="14"
FontWeight="Medium"
IsHitTestVisible="False"
Text="{Binding Type, UpdateSourceTrigger=PropertyChanged}" />
<Border
Margin="0,8,10,0"
Padding="8,3"
HorizontalAlignment="Left"
Background="{DynamicResource primary-default}"
CornerRadius="10"
IsHitTestVisible="False"
Visibility="{Binding Type}">
<TextBlock
HorizontalAlignment="Stretch"
FontSize="10"
Foreground="#ffffff"
Text="{Binding TimeSpan, StringFormat={}{0:hh':'mm}, UpdateSourceTrigger=PropertyChanged}"
TextTrimming="CharacterEllipsis" />
</Border>
</StackPanel>

<TextBlock
Grid.Column="2"
Margin="20,0,0,0"
Expand Down

0 comments on commit 7620d78

Please sign in to comment.