@ -0,0 +1,38 @@ | |||
using System; | |||
using Xamarin.Forms; | |||
namespace eShopOnContainers.Core.Behaviors.Base | |||
{ | |||
public class BindableBehavior<T> : Behavior<T> where T : BindableObject | |||
{ | |||
public T AssociatedObject { get; private set; } | |||
protected override void OnAttachedTo(T visualElement) | |||
{ | |||
base.OnAttachedTo(visualElement); | |||
AssociatedObject = visualElement; | |||
if (visualElement.BindingContext != null) | |||
BindingContext = visualElement.BindingContext; | |||
visualElement.BindingContextChanged += OnBindingContextChanged; | |||
} | |||
private void OnBindingContextChanged(object sender, EventArgs e) | |||
{ | |||
OnBindingContextChanged(); | |||
} | |||
protected override void OnDetachingFrom(T view) | |||
{ | |||
view.BindingContextChanged -= OnBindingContextChanged; | |||
} | |||
protected override void OnBindingContextChanged() | |||
{ | |||
base.OnBindingContextChanged(); | |||
BindingContext = AssociatedObject.BindingContext; | |||
} | |||
} | |||
} |
@ -0,0 +1,134 @@ | |||
using eShopOnContainers.Core.Behaviors.Base; | |||
using System; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Linq.Expressions; | |||
using System.Reflection; | |||
using System.Windows.Input; | |||
using Xamarin.Forms; | |||
namespace eShopOnContainers.Core.Behaviors | |||
{ | |||
public class EventToCommandBehavior : BindableBehavior<View> | |||
{ | |||
public static BindableProperty EventNameProperty = | |||
BindableProperty.CreateAttached("EventName", typeof(string), typeof(EventToCommandBehavior), null, | |||
BindingMode.OneWay); | |||
public static BindableProperty CommandProperty = | |||
BindableProperty.CreateAttached("Command", typeof(ICommand), typeof(EventToCommandBehavior), null, | |||
BindingMode.OneWay); | |||
public static BindableProperty CommandParameterProperty = | |||
BindableProperty.CreateAttached("CommandParameter", typeof(object), typeof(EventToCommandBehavior), null, | |||
BindingMode.OneWay); | |||
public static BindableProperty EventArgsConverterProperty = | |||
BindableProperty.CreateAttached("EventArgsConverter", typeof(IValueConverter), typeof(EventToCommandBehavior), null, | |||
BindingMode.OneWay); | |||
public static BindableProperty EventArgsConverterParameterProperty = | |||
BindableProperty.CreateAttached("EventArgsConverterParameter", typeof(object), typeof(EventToCommandBehavior), null, | |||
BindingMode.OneWay); | |||
private Delegate _handler; | |||
private EventInfo _eventInfo; | |||
public string EventName | |||
{ | |||
get { return (string)GetValue(EventNameProperty); } | |||
set { SetValue(EventNameProperty, value); } | |||
} | |||
public ICommand Command | |||
{ | |||
get { return (ICommand)GetValue(CommandProperty); } | |||
set { SetValue(CommandProperty, value); } | |||
} | |||
public object CommandParameter | |||
{ | |||
get { return GetValue(CommandParameterProperty); } | |||
set { SetValue(CommandParameterProperty, value); } | |||
} | |||
public IValueConverter EventArgsConverter | |||
{ | |||
get { return (IValueConverter)GetValue(EventArgsConverterProperty); } | |||
set { SetValue(EventArgsConverterProperty, value); } | |||
} | |||
public object EventArgsConverterParameter | |||
{ | |||
get { return GetValue(EventArgsConverterParameterProperty); } | |||
set { SetValue(EventArgsConverterParameterProperty, value); } | |||
} | |||
protected override void OnAttachedTo(View visualElement) | |||
{ | |||
base.OnAttachedTo(visualElement); | |||
var events = AssociatedObject.GetType().GetRuntimeEvents().ToArray(); | |||
if (events.Any()) | |||
{ | |||
_eventInfo = events.FirstOrDefault(e => e.Name == EventName); | |||
if (_eventInfo == null) | |||
throw new ArgumentException(String.Format("EventToCommand: Can't find any event named '{0}' on attached type", EventName)); | |||
AddEventHandler(_eventInfo, AssociatedObject, OnFired); | |||
} | |||
} | |||
protected override void OnDetachingFrom(View view) | |||
{ | |||
if (_handler != null) | |||
_eventInfo.RemoveEventHandler(AssociatedObject, _handler); | |||
base.OnDetachingFrom(view); | |||
} | |||
private void AddEventHandler(EventInfo eventInfo, object item, Action<object, EventArgs> action) | |||
{ | |||
var eventParameters = eventInfo.EventHandlerType | |||
.GetRuntimeMethods().First(m => m.Name == "Invoke") | |||
.GetParameters() | |||
.Select(p => Expression.Parameter(p.ParameterType)) | |||
.ToArray(); | |||
var actionInvoke = action.GetType() | |||
.GetRuntimeMethods().First(m => m.Name == "Invoke"); | |||
_handler = Expression.Lambda( | |||
eventInfo.EventHandlerType, | |||
Expression.Call(Expression.Constant(action), actionInvoke, eventParameters[0], eventParameters[1]), | |||
eventParameters | |||
) | |||
.Compile(); | |||
eventInfo.AddEventHandler(item, _handler); | |||
} | |||
private void OnFired(object sender, EventArgs eventArgs) | |||
{ | |||
if (Command == null) | |||
return; | |||
var parameter = CommandParameter; | |||
if (eventArgs != null && eventArgs != EventArgs.Empty) | |||
{ | |||
parameter = eventArgs; | |||
if (EventArgsConverter != null) | |||
{ | |||
parameter = EventArgsConverter.Convert(eventArgs, typeof(object), EventArgsConverterParameter, CultureInfo.CurrentUICulture); | |||
} | |||
} | |||
if (Command.CanExecute(parameter)) | |||
{ | |||
Command.Execute(parameter); | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,23 @@ | |||
using System; | |||
using System.Globalization; | |||
using Xamarin.Forms; | |||
namespace eShopOnContainers.Core.Converters | |||
{ | |||
public class ItemTappedEventArgsConverter : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
var eventArgs = value as ItemTappedEventArgs; | |||
if (eventArgs == null) | |||
throw new ArgumentException("Expected TappedEventArgs as value", "value"); | |||
return eventArgs.Item; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@ -0,0 +1,13 @@ | |||
using System; | |||
namespace eShopOnContainers.Core.Models.Catalog | |||
{ | |||
public class CatalogItem | |||
{ | |||
public int Id { get; set; } | |||
public string Name { get; set; } | |||
public string Description { get; set; } | |||
public decimal Price { get; set; } | |||
public string Image { get; set; } | |||
} | |||
} |
@ -1,12 +1,21 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
namespace eShopOnContainers.Core.Models.Orders | |||
{ | |||
public class Order | |||
{ | |||
public long OrderNumber { get; set; } | |||
public int SequenceNumber { get; set; } | |||
public double Total { get; set; } | |||
public DateTime Date { get; set; } | |||
public DateTime OrderDate { get; set; } | |||
public OrderStatus Status { get; set; } | |||
public User.User ShippingAddress { get; set; } | |||
public int BuyerId { get; set; } | |||
public List<OrderItem> OrderItems { get; set; } | |||
public string OrderNumber | |||
{ | |||
get { return string.Format("{0}/{1}-{2}", OrderDate.Year, OrderDate.Month, SequenceNumber); } | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,20 @@ | |||
using System; | |||
namespace eShopOnContainers.Core.Models.Orders | |||
{ | |||
public class OrderItem | |||
{ | |||
public int ProductId { get; set; } | |||
public Guid OrderId { get; set; } | |||
public string ProductName { get; set; } | |||
public decimal UnitPrice { get; set; } | |||
public int Quantity { get; set; } | |||
public decimal Discount { get; set; } | |||
public decimal Total { get { return Quantity * UnitPrice; } } | |||
public override string ToString() | |||
{ | |||
return String.Format("Product Id: {0}, Quantity: {1}", ProductId, Quantity); | |||
} | |||
} | |||
} |
@ -1,9 +0,0 @@ | |||
namespace eShopOnContainers.Core.Models.Products | |||
{ | |||
public class Product | |||
{ | |||
public string Name { get; set; } | |||
public string Image { get; set; } | |||
public double Price { get; set; } | |||
} | |||
} |
@ -0,0 +1,22 @@ | |||
namespace eShopOnContainers.Core.Models.User | |||
{ | |||
public class User | |||
{ | |||
public string Name { get; set; } | |||
public string LastName { get; set; } | |||
public string CardNumber { get; set; } | |||
public string SecurityNumber { get; set; } | |||
public string Expiration { get; set; } | |||
public string CardHolderName { get; set; } | |||
public int CardType { get; set; } | |||
public string Street { get; set; } | |||
public string City { get; set; } | |||
public string State { get; set; } | |||
public string StateCode { get; set; } | |||
public string Country { get; set; } | |||
public string CountryCode { get; set; } | |||
public string ZipCode { get; set; } | |||
public double Latitude { get; set; } | |||
public double Longitude { get; set; } | |||
} | |||
} |
@ -0,0 +1,23 @@ | |||
using eShopOnContainers.Core.Models.Catalog; | |||
using System; | |||
using System.Collections.ObjectModel; | |||
using System.Threading.Tasks; | |||
using Xamarin.Forms; | |||
namespace eShopOnContainers.Core.Services.Catalog | |||
{ | |||
public class CatalogMockService : ICatalogService | |||
{ | |||
public async Task<ObservableCollection<CatalogItem>> GetProductsAsync() | |||
{ | |||
await Task.Delay(500); | |||
return new ObservableCollection<CatalogItem> | |||
{ | |||
new CatalogItem { Id = 1, Image = Device.OS != TargetPlatform.Windows ? "fake_product_01" : "Assets/fake_product_01.png", Name = ".NET Bot Blue Sweatshirt (M)", Price = 19.50M }, | |||
new CatalogItem { Id = 2, Image = Device.OS != TargetPlatform.Windows ? "fake_product_02": "Assets/fake_product_02.png", Name = ".NET Bot Purple Sweatshirt (M)", Price = 19.50M }, | |||
new CatalogItem { Id = 3, Image = Device.OS != TargetPlatform.Windows ? "fake_product_03": "Assets/fake_product_03.png", Name = ".NET Bot Black Sweatshirt (M)", Price = 19.95M } | |||
}; | |||
} | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
using eShopOnContainers.Core.Models.Catalog; | |||
using System.Collections.ObjectModel; | |||
using System.Threading.Tasks; | |||
namespace eShopOnContainers.Core.Services.Catalog | |||
{ | |||
public interface ICatalogService | |||
{ | |||
Task<ObservableCollection<CatalogItem>> GetProductsAsync(); | |||
} | |||
} |
@ -1,29 +0,0 @@ | |||
using eShopOnContainers.Core.Models.Orders; | |||
using System; | |||
using System.Collections.ObjectModel; | |||
using System.Threading.Tasks; | |||
namespace eShopOnContainers.Core.Services.Orders | |||
{ | |||
public class FakeOrdersService : IOrdersService | |||
{ | |||
public async Task<ObservableCollection<Order>> GetOrdersAsync() | |||
{ | |||
await Task.Delay(500); | |||
return new ObservableCollection<Order> | |||
{ | |||
new Order { OrderNumber = 0123456789, Total = 45.30, Date = DateTime.Now, Status = OrderStatus.Delivered }, | |||
new Order { OrderNumber = 9123456780, Total = 39.95, Date = DateTime.Now, Status = OrderStatus.Delivered }, | |||
new Order { OrderNumber = 8765432190, Total = 15.00, Date = DateTime.Now, Status = OrderStatus.Delivered }, | |||
}; | |||
} | |||
public async Task<Order> GetCartAsync() | |||
{ | |||
await Task.Delay(500); | |||
return new Order { OrderNumber = 0123456789, Total = 45.99, Date = DateTime.Now, Status = OrderStatus.Pending }; | |||
} | |||
} | |||
} |
@ -0,0 +1,39 @@ | |||
using eShopOnContainers.Core.Models.Orders; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Threading.Tasks; | |||
namespace eShopOnContainers.Core.Services.Orders | |||
{ | |||
public class OrdersMockService : IOrdersService | |||
{ | |||
public async Task<ObservableCollection<Order>> GetOrdersAsync() | |||
{ | |||
await Task.Delay(500); | |||
return new ObservableCollection<Order> | |||
{ | |||
new Order { SequenceNumber = 123, Total = 56.40, OrderDate = DateTime.Now, Status = OrderStatus.Delivered, OrderItems = GetOrderItems() }, | |||
new Order { SequenceNumber = 132, Total = 56.40, OrderDate = DateTime.Now, Status = OrderStatus.Delivered, OrderItems = GetOrderItems() }, | |||
new Order { SequenceNumber = 231, Total = 56.40, OrderDate = DateTime.Now, Status = OrderStatus.Delivered, OrderItems = GetOrderItems() }, | |||
}; | |||
} | |||
public async Task<Order> GetCartAsync() | |||
{ | |||
await Task.Delay(500); | |||
return new Order { SequenceNumber = 0123456789, Total = 56.40, OrderDate = DateTime.Now, Status = OrderStatus.Pending, OrderItems = GetOrderItems() }; | |||
} | |||
private List<OrderItem> GetOrderItems() | |||
{ | |||
return new List<OrderItem> | |||
{ | |||
new OrderItem { OrderId = Guid.NewGuid(), ProductId = 1, Discount = 15, ProductName = ".NET Bot Blue Sweatshirt (M)", Quantity = 1, UnitPrice = 16.50M }, | |||
new OrderItem { OrderId = Guid.NewGuid(), ProductId = 3, Discount = 0, ProductName = ".NET Bot Black Sweatshirt (M)", Quantity = 2, UnitPrice = 19.95M } | |||
}; | |||
} | |||
} | |||
} |
@ -1,22 +0,0 @@ | |||
using eShopOnContainers.Core.Models.Products; | |||
using System.Collections.ObjectModel; | |||
using System.Threading.Tasks; | |||
using Xamarin.Forms; | |||
namespace eShopOnContainers.Core.Services.Products | |||
{ | |||
public class FakeProductsService : IProductsService | |||
{ | |||
public async Task<ObservableCollection<Product>> GetProductsAsync() | |||
{ | |||
await Task.Delay(500); | |||
return new ObservableCollection<Product> | |||
{ | |||
new Product { Image = Device.OS != TargetPlatform.Windows ? "fake_product_01" : "Assets/fake_product_01.png", Name = ".NET Bot Blue Sweatshirt (M)", Price = 19.50 }, | |||
new Product { Image = Device.OS != TargetPlatform.Windows ? "fake_product_02": "Assets/fake_product_02.png", Name = ".NET Bot Purple Sweatshirt (M)", Price = 19.50 }, | |||
new Product { Image = Device.OS != TargetPlatform.Windows ? "fake_product_03": "Assets/fake_product_03.png", Name = ".NET Bot Black Sweatshirt (M)", Price = 19.95 } | |||
}; | |||
} | |||
} | |||
} |
@ -1,11 +0,0 @@ | |||
using eShopOnContainers.Core.Models.Products; | |||
using System.Collections.ObjectModel; | |||
using System.Threading.Tasks; | |||
namespace eShopOnContainers.Core.Services.Products | |||
{ | |||
public interface IProductsService | |||
{ | |||
Task<ObservableCollection<Product>> GetProductsAsync(); | |||
} | |||
} |
@ -1,8 +1,31 @@ | |||
using eShopOnContainers.ViewModels.Base; | |||
using System.Threading.Tasks; | |||
using eShopOnContainers.Core.Models.Orders; | |||
using eShopOnContainers.ViewModels.Base; | |||
namespace eShopOnContainers.Core.ViewModels | |||
{ | |||
public class OrderDetailViewModel : ViewModelBase | |||
{ | |||
private Order _order; | |||
public Order Order | |||
{ | |||
get { return _order; } | |||
set | |||
{ | |||
_order = value; | |||
RaisePropertyChanged(() => Order); | |||
} | |||
} | |||
public override Task InitializeAsync(object navigationData) | |||
{ | |||
if(navigationData is Order) | |||
{ | |||
Order = navigationData as Order; | |||
} | |||
return base.InitializeAsync(navigationData); | |||
} | |||
} | |||
} | |||
} |
@ -1,8 +0,0 @@ | |||
using eShopOnContainers.ViewModels.Base; | |||
namespace eShopOnContainers.Core.ViewModels | |||
{ | |||
public class OrdersViewModel : ViewModelBase | |||
{ | |||
} | |||
} |
@ -1,6 +1,233 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |||
x:Class="eShopOnContainers.Core.Views.OrderDetailView"> | |||
x:Class="eShopOnContainers.Core.Views.OrderDetailView" | |||
xmlns:templates="clr-namespace:eShopOnContainers.Core.Views.Templates;assembly=eShopOnContainers.Core" | |||
xmlns:animations="clr-namespace:eShopOnContainers.Core.Animations;assembly=eShopOnContainers.Core" | |||
xmlns:triggers="clr-namespace:eShopOnContainers.Core.Triggers;assembly=eShopOnContainers.Core" | |||
Title="{Binding Order.SequenceNumber}"> | |||
<ContentPage.Resources> | |||
<ResourceDictionary> | |||
<Style x:Key="OrderTitleStyle" | |||
TargetType="{x:Type Label}"> | |||
<Setter Property="FontFamily" | |||
Value="{StaticResource MontserratRegular}" /> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource MediumSize}" /> | |||
<Setter Property="TextColor" | |||
Value="Gray" /> | |||
</Style> | |||
<Style x:Key="OrderContentStyle" | |||
TargetType="{x:Type Label}" | |||
BasedOn="{StaticResource OrderTitleStyle}"> | |||
<Setter Property="TextColor" | |||
Value="Black" /> | |||
</Style> | |||
<Style x:Key="ShippingAddressStyle" | |||
TargetType="{x:Type Label}" | |||
BasedOn="{StaticResource OrderTitleStyle}"> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource LargeSize}" /> | |||
<Setter Property="TextColor" | |||
Value="Black" /> | |||
</Style> | |||
<Style x:Key="AddressStyle" | |||
TargetType="{x:Type Label}" | |||
BasedOn="{StaticResource OrderTitleStyle}"> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource LittleSize}" /> | |||
<Setter Property="TextColor" | |||
Value="Black" /> | |||
</Style> | |||
<Style x:Key="OrderTotalStyle" | |||
TargetType="{x:Type Label}"> | |||
<Setter Property="FontFamily" | |||
Value="{StaticResource MontserratRegular}" /> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource LargerSize}" /> | |||
<Setter Property="HorizontalOptions" | |||
Value="End" /> | |||
</Style> | |||
<animations:StoryBoard | |||
x:Key="OrderInfoAnimation" | |||
Target="{x:Reference OrderInfo}"> | |||
<animations:FadeToAnimation | |||
Opacity="1" | |||
Duration="500" | |||
Delay="100"/> | |||
</animations:StoryBoard> | |||
<animations:StoryBoard | |||
x:Key="ShippingAddressAnimation" | |||
Target="{x:Reference ShippingAddress}"> | |||
<animations:FadeToAnimation | |||
Opacity="1" | |||
Duration="1000" | |||
Delay="200"/> | |||
</animations:StoryBoard> | |||
<animations:StoryBoard | |||
x:Key="OrderItemsAnimation" | |||
Target="{x:Reference OrderItems}"> | |||
<animations:FadeToAnimation | |||
Opacity="1" | |||
Duration="1500" | |||
Delay="300"/> | |||
</animations:StoryBoard> | |||
</ResourceDictionary> | |||
</ContentPage.Resources> | |||
<ContentPage.Triggers> | |||
<EventTrigger | |||
Event="Appearing"> | |||
<triggers:BeginAnimation | |||
Animation="{StaticResource OrderInfoAnimation}" /> | |||
<triggers:BeginAnimation | |||
Animation="{StaticResource ShippingAddressAnimation}" /> | |||
<triggers:BeginAnimation | |||
Animation="{StaticResource OrderItemsAnimation}" /> | |||
</EventTrigger> | |||
</ContentPage.Triggers> | |||
<ScrollView> | |||
<Grid | |||
BackgroundColor="{StaticResource BackgroundColor}"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="Auto" /> | |||
<RowDefinition Height="Auto" /> | |||
<RowDefinition Height="Auto" /> | |||
</Grid.RowDefinitions> | |||
<!-- ORDER INFO --> | |||
<Grid | |||
x:Name="OrderInfo" | |||
Opacity="0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackLayout | |||
Grid.Column="0" | |||
Grid.Row="0" | |||
Margin="12"> | |||
<Label | |||
Text="ORDER NUMBER" | |||
Style="{StaticResource OrderTitleStyle}"/> | |||
<Label | |||
Text="{Binding Order.OrderNumber, Converter={StaticResource ToUpperConverter}}" | |||
Style="{StaticResource OrderContentStyle}"/> | |||
</StackLayout> | |||
<StackLayout | |||
Grid.Column="0" | |||
Grid.Row="1" | |||
Margin="12"> | |||
<Label | |||
Text="TOTAL" | |||
Style="{StaticResource OrderTitleStyle}"/> | |||
<Label | |||
Text="{Binding Order.Total, StringFormat='${0:N}', Converter={StaticResource ToUpperConverter}}" | |||
Style="{StaticResource OrderContentStyle}"/> | |||
</StackLayout> | |||
<StackLayout | |||
Grid.Column="1" | |||
Grid.Row="0" | |||
Margin="12"> | |||
<Label | |||
Text="DATE" | |||
Style="{StaticResource OrderTitleStyle}"/> | |||
<Label | |||
Text="{Binding Order.OrderDate, Converter={StaticResource DatetimeConverter}}" | |||
Style="{StaticResource OrderContentStyle}"/> | |||
</StackLayout> | |||
<StackLayout | |||
Grid.Column="1" | |||
Grid.Row="1" | |||
Margin="12"> | |||
<Label | |||
Text="STATUS" | |||
Style="{StaticResource OrderTitleStyle}"/> | |||
<Label | |||
Text="{Binding Order.Status, Converter={StaticResource ToUpperConverter}}" | |||
Style="{StaticResource OrderContentStyle}"/> | |||
</StackLayout> | |||
</Grid> | |||
<!-- SHIPPING ADDRESS --> | |||
<Grid | |||
x:Name="ShippingAddress" | |||
Grid.Row="1" | |||
Margin="12" | |||
Opacity="0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="Auto" /> | |||
<RowDefinition Height="*" /> | |||
</Grid.RowDefinitions> | |||
<Label | |||
Grid.Row="0" | |||
Text="SHIPPING ADDRESS" | |||
Style="{StaticResource ShippingAddressStyle}"/> | |||
<StackLayout | |||
Grid.Row="1"> | |||
<Label | |||
Text="120 E 87th Street" | |||
Style="{StaticResource AddressStyle}"/> | |||
<Label | |||
Text="Seattle, WA" | |||
Style="{StaticResource AddressStyle}"/> | |||
<Label | |||
Text="98122" | |||
Style="{StaticResource AddressStyle}"/> | |||
<Label | |||
Text="United States" | |||
Style="{StaticResource AddressStyle}"/> | |||
</StackLayout> | |||
</Grid> | |||
<!-- ORDER ITEMS --> | |||
<Grid | |||
x:Name="OrderItems" | |||
Grid.Row="2" | |||
Opacity="0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*" /> | |||
<RowDefinition Height="Auto" /> | |||
</Grid.RowDefinitions> | |||
<ListView | |||
Grid.Row="0" | |||
ItemsSource="{Binding Order.OrderItems}" | |||
HasUnevenRows="True" | |||
SeparatorVisibility="None" | |||
VerticalOptions="FillAndExpand" | |||
CachingStrategy="RecycleElement"> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<ViewCell> | |||
<templates:OrderItemTemplate /> | |||
</ViewCell> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
<StackLayout | |||
Grid.Row="1" | |||
Margin="0,0,0,24"> | |||
<Label | |||
Grid.Row="0" | |||
Text="TOTAL" | |||
TextColor="{StaticResource BlackColor}" | |||
Style="{StaticResource OrderTotalStyle}"/> | |||
<Label | |||
Grid.Row="1" | |||
Text="{Binding Order.Total, StringFormat='${0:N}'}" | |||
TextColor="{StaticResource GreenColor}" | |||
Style="{StaticResource OrderTotalStyle}"/> | |||
</StackLayout> | |||
</Grid> | |||
</Grid> | |||
</ScrollView> | |||
</ContentPage> |
@ -1,6 +0,0 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |||
x:Class="eShopOnContainers.Core.Views.OrdersView"> | |||
</ContentPage> |
@ -1,12 +0,0 @@ | |||
using Xamarin.Forms; | |||
namespace eShopOnContainers.Core.Views | |||
{ | |||
public partial class OrdersView : ContentPage | |||
{ | |||
public OrdersView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@ -0,0 +1,110 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<ContentView | |||
xmlns="http://xamarin.com/schemas/2014/forms" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |||
x:Class="eShopOnContainers.Core.Views.Templates.OrderItemTemplate"> | |||
<ContentView.Resources> | |||
<ResourceDictionary> | |||
<Style x:Key="OrderItemTitleStyle" | |||
TargetType="{x:Type Label}"> | |||
<Setter Property="FontFamily" | |||
Value="{StaticResource MontserratRegular}" /> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource MediumSize}" /> | |||
<Setter Property="TextColor" | |||
Value="{StaticResource BlackColor}" /> | |||
</Style> | |||
<Style x:Key="OrderItemUnitPriceStyle" | |||
TargetType="{x:Type Label}"> | |||
<Setter Property="FontFamily" | |||
Value="{StaticResource MontserratRegular}" /> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource MidMediumSize}" /> | |||
<Setter Property="TextColor" | |||
Value="{StaticResource BlackColor}" /> | |||
<Setter Property="HorizontalOptions" | |||
Value="Start" /> | |||
</Style> | |||
<Style x:Key="OrderItemQuantityStyle" | |||
TargetType="{x:Type Label}"> | |||
<Setter Property="FontFamily" | |||
Value="{StaticResource MontserratRegular}" /> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource MidMediumSize}" /> | |||
<Setter Property="TextColor" | |||
Value="{StaticResource BlackColor}" /> | |||
<Setter Property="HorizontalOptions" | |||
Value="End" /> | |||
</Style> | |||
<Style x:Key="OrderTotalStyle" | |||
TargetType="{x:Type Label}"> | |||
<Setter Property="FontFamily" | |||
Value="{StaticResource MontserratRegular}" /> | |||
<Setter Property="FontSize" | |||
Value="{StaticResource LargerSize}" /> | |||
<Setter Property="TextColor" | |||
Value="{StaticResource GreenColor}" /> | |||
<Setter Property="HorizontalOptions" | |||
Value="End" /> | |||
</Style> | |||
</ResourceDictionary> | |||
</ContentView.Resources> | |||
<ContentView.Content> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="Auto" /> | |||
<ColumnDefinition Width="*" /> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*" /> | |||
<RowDefinition Height="1" /> | |||
</Grid.RowDefinitions> | |||
<Image | |||
Grid.Column="0" | |||
Grid.Row="0" | |||
Source="{Binding Image}"/> | |||
<Grid | |||
Grid.Column="1" | |||
Grid.Row="0" | |||
Margin="6"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Label | |||
Grid.Row="0" | |||
Text="{Binding ProductName, Converter={StaticResource ToUpperConverter}}"/> | |||
<Grid | |||
Grid.Row="1"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<Label | |||
Grid.Column="0" | |||
Text="{Binding UnitPrice, StringFormat='${0:N}'}" | |||
Style="{StaticResource OrderItemUnitPriceStyle}"/> | |||
<Label | |||
Grid.Column="1" | |||
Text="{Binding Quantity}" | |||
Style="{StaticResource OrderItemQuantityStyle}"/> | |||
</Grid> | |||
<Label | |||
Grid.Row="2" | |||
Text="{Binding Total, StringFormat='${0:N}'}" | |||
Style="{StaticResource OrderTotalStyle}"/> | |||
</Grid> | |||
<Grid | |||
Grid.Column="0" | |||
Grid.ColumnSpan="2" | |||
Grid.Row="1" | |||
BackgroundColor="Gray"/> | |||
</Grid> | |||
</ContentView.Content> | |||
</ContentView> |
@ -0,0 +1,12 @@ | |||
using Xamarin.Forms; | |||
namespace eShopOnContainers.Core.Views.Templates | |||
{ | |||
public partial class OrderItemTemplate : ContentView | |||
{ | |||
public OrderItemTemplate() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |