Skip to content

Commit

Permalink
adding not implemented alerts, starting order types
Browse files Browse the repository at this point in the history
  • Loading branch information
davidortinau committed Aug 14, 2022
1 parent facec07 commit 8c50fca
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 7 deletions.
31 changes: 31 additions & 0 deletions 6.0/Apps/PointOfSale/src/PointOfSale/Models/EnumExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.ComponentModel;
using System.Reflection;

public static class EnumExtensions
{
public static string GetDescription<T>(this T enumerationValue)
where T : struct
{
Type type = enumerationValue.GetType();
if (!type.IsEnum)
{
throw new ArgumentException("EnumerationValue must be of Enum type", "enumerationValue");
}

//Tries to find a DescriptionAttribute for a potential friendly name
//for the enum
MemberInfo[] memberInfo = type.GetMember(enumerationValue.ToString());
if (memberInfo != null && memberInfo.Length > 0)
{
object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);

if (attrs != null && attrs.Length > 0)
{
//Pull out the description value
return ((DescriptionAttribute)attrs[0]).Description;
}
}
//If we have no description attribute, just return the ToString of the enum
return enumerationValue.ToString();
}
}
3 changes: 3 additions & 0 deletions 6.0/Apps/PointOfSale/src/PointOfSale/Models/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public string Total

[ObservableProperty]
private string status;

[ObservableProperty]
private OrderType orderType = OrderType.DineIn;

private static readonly Random _random = new Random();

Expand Down
17 changes: 17 additions & 0 deletions 6.0/Apps/PointOfSale/src/PointOfSale/Models/OrderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.ComponentModel;
using System.Reflection;

namespace PointOfSale.Models
{
public enum OrderType
{
[Description("Dine In")]
DineIn,
[Description("Carry Out")]
CarryOut,
[Description("Delivery")]
Delivery
}
}

17 changes: 15 additions & 2 deletions 6.0/Apps/PointOfSale/src/PointOfSale/Pages/DashboardPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:a="clr-namespace:PointOfSale"
xmlns:system="clr-namespace:System;assembly=netstandard"
xmlns:mct="clr-namespace:CommunityToolkit.Maui;assembly=CommunityToolkit.Maui" xmlns:views="clr-namespace:PointOfSale.Pages.Views"
xmlns:views="clr-namespace:PointOfSale.Pages.Views"
xmlns:pages="clr-namespace:PointOfSale.Pages"
x:Class="PointOfSale.Pages.DashboardPage"
x:DataType="pages:DashboardViewModel"
Title="DashboardPage"
Shell.NavBarIsVisible="False">

<ContentPage.BindingContext>
<pages:DashboardViewModel/>
</ContentPage.BindingContext>

<Grid RowDefinitions="100,*" RowSpacing="24"
ColumnDefinitions="*,400"
Margin="24,0,0,0">
Expand Down Expand Up @@ -130,7 +136,7 @@
</HorizontalStackLayout>

<Border.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
<TapGestureRecognizer Command="{Binding ViewAllCommand}"/>
</Border.GestureRecognizers>
</Border>

Expand Down Expand Up @@ -198,6 +204,9 @@
<Border.StrokeShape>
<RoundRectangle CornerRadius="8"/>
</Border.StrokeShape>
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ViewAllCommand}"/>
</Border.GestureRecognizers>
<HorizontalStackLayout Margin="14,12" Spacing="12">
<Label Text="{x:Static a:IconFont.ChevronDown}" FontFamily="FontAwesome" VerticalOptions="Center"/>
<Label Text="Today" VerticalOptions="Center"/>
Expand Down Expand Up @@ -235,6 +244,7 @@
</VerticalStackLayout>
<Button Text="View All" HorizontalOptions="Fill" Margin="0,24,0,0"
Style="{StaticResource PrimaryButtonOutline}"
Command="{Binding ViewAllCommand}"
Grid.Row="3" />
</Grid>
</Border>
Expand All @@ -252,6 +262,9 @@
<Border.StrokeShape>
<RoundRectangle CornerRadius="8"/>
</Border.StrokeShape>
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ViewAllCommand}"/>
</Border.GestureRecognizers>
<HorizontalStackLayout Margin="14,12" Spacing="12">
<Label Text="{x:Static a:IconFont.ChevronDown}" FontFamily="FontAwesome" VerticalOptions="Center"/>
<Label Text="Today" VerticalOptions="Center"/>
Expand Down
12 changes: 12 additions & 0 deletions 6.0/Apps/PointOfSale/src/PointOfSale/Pages/DashboardViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace PointOfSale.Pages;

[INotifyPropertyChanged]
public partial class DashboardViewModel
{
[RelayCommand]
async Task ViewAll()
{
await App.Current.MainPage.DisplayAlert("Not Implemented", "Wouldn't it be nice tho?", "Okay");
}
}

3 changes: 2 additions & 1 deletion 6.0/Apps/PointOfSale/src/PointOfSale/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
<VerticalStackLayout Spacing="8">
<Grid Margin="24" >
<Label Text="Products Management" VerticalOptions="Center"/>
<Button Text="Manage Categories" HorizontalOptions="End" VerticalOptions="Center"/>
<Button Text="Manage Categories" HorizontalOptions="End" VerticalOptions="Center"
Command="{Binding NotImplementedCommand}"/>
</Grid>

<Label Margin="24,8" Text="All Products" Style="{StaticResource Headline}" TextColor="{StaticResource Primary}"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
namespace PointOfSale.Pages;
namespace PointOfSale.Pages;

[INotifyPropertyChanged]
public partial class SettingsViewModel
Expand All @@ -13,5 +12,11 @@ public SettingsViewModel()
AppData.Items
);
}

[RelayCommand]
async Task NotImplemented()
{
await App.Current.MainPage.DisplayAlert("Not Implemented", "Wouldn't it be nice tho?", "Okay");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class ChartView : SKCanvasView
public event EventHandler<SKPaintSurfaceEventArgs> ChartPainted;

public static readonly BindableProperty ChartProperty = BindableProperty.Create(nameof(Chart), typeof(Chart), typeof(ChartView), null, propertyChanged: OnChartChanged);

public Chart Chart
{
get { return (Chart)GetValue(ChartProperty); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
</VerticalStackLayout>
</VerticalStackLayout>
</ScrollView>
<Button Text="Place Order" HorizontalOptions="Fill" Margin="24" Grid.Row="1" />
<Button Text="Place Order" HorizontalOptions="Fill" Margin="24" Grid.Row="1"
Command="{Binding PlaceOrderCommand}"/>

</Grid>
</ContentView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ public OrderCartViewModel()
{
Order = AppData.Orders.First();
}

[RelayCommand]
async Task PlaceOrder()
{
await App.Current.MainPage.DisplayAlert("Not Implemented", "Wouldn't it be cool tho?", "Okay");
}
}

0 comments on commit 8c50fca

Please sign in to comment.