Add CampaignDetail view and model view
This commit is contained in:
parent
9bdfddc496
commit
bfb9eff00a
@ -49,6 +49,7 @@ namespace eShopOnContainers.Core.ViewModels.Base
|
||||
builder.RegisterType<ProfileViewModel>();
|
||||
builder.RegisterType<SettingsViewModel>();
|
||||
builder.RegisterType<CampaignViewModel>();
|
||||
builder.RegisterType<CampaignDetailsViewModel>();
|
||||
|
||||
// Services
|
||||
builder.RegisterType<NavigationService>().As<INavigationService>().SingleInstance();
|
||||
|
@ -0,0 +1,99 @@
|
||||
using System;
|
||||
|
||||
namespace eShopOnContainers.Core.ViewModels
|
||||
{
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using eShopOnContainers.Core.Helpers;
|
||||
using Xamarin.Forms;
|
||||
using Models.Marketing;
|
||||
using Services.Marketing;
|
||||
using Base;
|
||||
|
||||
public class CampaignDetailsViewModel : ViewModelBase
|
||||
{
|
||||
private CampaignItem _campaign;
|
||||
private readonly ICampaignService _campaignService;
|
||||
private string _campaignAvailability;
|
||||
|
||||
|
||||
public CampaignDetailsViewModel(ICampaignService campaignService)
|
||||
{
|
||||
_campaignService = campaignService;
|
||||
}
|
||||
|
||||
public CampaignItem Campaign
|
||||
{
|
||||
get => _campaign;
|
||||
set
|
||||
{
|
||||
_campaign = value;
|
||||
RaisePropertyChanged(() => Campaign);
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _campaign.Name;
|
||||
set
|
||||
{
|
||||
_campaign.Name = value;
|
||||
RaisePropertyChanged(() => Name);
|
||||
}
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get => _campaign.Description;
|
||||
set
|
||||
{
|
||||
_campaign.Description = value;
|
||||
RaisePropertyChanged(() => Description);
|
||||
}
|
||||
}
|
||||
|
||||
public string PictureUri
|
||||
{
|
||||
get => _campaign.PictureUri;
|
||||
set
|
||||
{
|
||||
_campaign.PictureUri = value;
|
||||
RaisePropertyChanged(() => PictureUri);
|
||||
}
|
||||
}
|
||||
|
||||
public string From
|
||||
{
|
||||
get => _campaign.From.ToString("MMMM dd, yyyy");
|
||||
}
|
||||
|
||||
public string To
|
||||
{
|
||||
get => _campaign.To.ToString("MMMM dd, yyyy");
|
||||
}
|
||||
|
||||
//public string CampaignAvailability
|
||||
//{
|
||||
// get => $"{_campaign.From:MMMM dd, yyyy} until {_campaign.To:MMMM dd, yyyy}";
|
||||
// set
|
||||
// {
|
||||
// _campaignAvailability = value;
|
||||
// RaisePropertyChanged(() => CampaignAvailability);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
public override async Task InitializeAsync(object navigationData)
|
||||
{
|
||||
if (navigationData is int)
|
||||
{
|
||||
IsBusy = true;
|
||||
|
||||
// Get campaign by id
|
||||
Campaign = await _campaignService.GetCampaignByIdAsync((int) navigationData, Settings.AuthAccessToken);
|
||||
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
<?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.CampaignDetailsView"
|
||||
xmlns:viewModelBase="clr-namespace:eShopOnContainers.Core.ViewModels.Base;assembly=eShopOnContainers.Core"
|
||||
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"
|
||||
viewModelBase:ViewModelLocator.AutoWireViewModel="true"
|
||||
Title="Campaign Details">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style x:Key="CampaignStyle"
|
||||
TargetType="{x:Type StackLayout}">
|
||||
<Setter Property="VerticalOptions"
|
||||
Value="Center" />
|
||||
<Setter Property="Margin"
|
||||
Value="0" />
|
||||
</Style>
|
||||
<Style x:Key="SettingsTitleStyle"
|
||||
TargetType="{x:Type Label}">
|
||||
<Setter Property="FontFamily"
|
||||
Value="{StaticResource MontserratRegular}" />
|
||||
<Setter Property="FontSize"
|
||||
Value="{StaticResource MediumSize}" />
|
||||
<Setter Property="HorizontalOptions"
|
||||
Value="Start" />
|
||||
<Setter Property="VerticalOptions"
|
||||
Value="Center" />
|
||||
<Setter Property="Margin"
|
||||
Value="12, 0" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SettingsDescriptionStyle"
|
||||
TargetType="{x:Type Label}"
|
||||
BasedOn="{StaticResource SettingsTitleStyle}">
|
||||
<Setter Property="FontSize"
|
||||
Value="{StaticResource LittleSize}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<Grid
|
||||
ColumnSpacing="0"
|
||||
RowSpacing="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- CAMPAIGN DETAILS -->
|
||||
<ScrollView>
|
||||
<StackLayout
|
||||
x:Name="Campaign">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="1" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
BackgroundColor="Gray"/>
|
||||
<StackLayout
|
||||
Style ="{StaticResource CampaignStyle}"
|
||||
Grid.Column="0"
|
||||
Grid.Row="1">
|
||||
<Image
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Source="{Binding Campaign.PictureUri, Converter={StaticResource ImageConverter}}"
|
||||
Aspect="AspectFit"
|
||||
VerticalOptions="Start"
|
||||
Margin="12,0,0,0" />
|
||||
<Label
|
||||
Text="{Binding Campaign.Name}"
|
||||
TextColor="{StaticResource GreenColor}"
|
||||
Style="{StaticResource SettingsTitleStyle}"/>
|
||||
<Label
|
||||
Text="{Binding Campaign.Description}"
|
||||
Style="{StaticResource SettingsDescriptionStyle}"/>
|
||||
<StackLayout
|
||||
Style ="{StaticResource CampaignStyle}"
|
||||
Grid.Row="2"
|
||||
HorizontalOptions="Center"
|
||||
Margin="12,0,0,0" >
|
||||
<Label
|
||||
Text="{Binding Campaign.From, StringFormat='From {0:MMMM dd, yyyy}'}"
|
||||
Style="{StaticResource SettingsDescriptionStyle}"/>
|
||||
<Label
|
||||
Text="{Binding Campaign.To, StringFormat='until {0:MMMM dd, yyyy}'}"
|
||||
Style="{StaticResource SettingsDescriptionStyle}"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
<!-- INDICATOR -->
|
||||
<ActivityIndicator
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Color="{StaticResource LightGreenColor}"
|
||||
IsRunning="{Binding IsBusy}"
|
||||
IsVisible="{Binding IsBusy}"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Center">
|
||||
<ActivityIndicator.WidthRequest>
|
||||
<OnPlatform
|
||||
x:TypeArguments="x:Double"
|
||||
iOS="100"
|
||||
Android="100"
|
||||
WinPhone="400" />
|
||||
</ActivityIndicator.WidthRequest>
|
||||
</ActivityIndicator>
|
||||
</Grid>
|
||||
</ContentPage>
|
@ -0,0 +1,12 @@
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace eShopOnContainers.Core.Views
|
||||
{
|
||||
public partial class CampaignDetailsView : ContentPage
|
||||
{
|
||||
public CampaignDetailsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user