<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:dd="clr-namespace:DataDisplay.Controls;assembly=DataDisplay"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vm="clr-namespace:Navigator.ViewModels"            
             ControlTemplate="{StaticResource ActivityIndicatorTemplate}"
             mc:Ignorable="d"
             Title="{Binding Title}"             
             x:Class="Navigator.Views.GainLossSeriesPage">
  <ContentPage.BindingContext>
    <vm:GainLossSeriesViewModel />
  </ContentPage.BindingContext>

  <ContentPage.Resources>
    <ResourceDictionary>
      <Style x:Key="FrameCardViewStyle" TargetType="Frame">
        <Setter Property="CornerRadius" Value="5" />
        <Setter Property="Margin" Value="5" />
        <Setter Property="Padding" Value="5" />
        <Setter Property="HorizontalOptions" Value="FillAndExpand" />
        <Setter Property="OutlineColor" Value="LightGray" />
        <Setter Property="BorderColor" Value="LightGray" />
        <Setter Property="HasShadow" Value="True" />
      </Style>

      <Style x:Key="CenteredLabelStyle" TargetType="Label">
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="FontAttributes" Value="Bold" />
        <Setter Property="TextColor" Value="Black" />
        <Setter Property="HorizontalTextAlignment" Value="Center" />
      </Style>

    </ResourceDictionary>
  </ContentPage.Resources>

  <ContentPage.Content>
    <Grid BackgroundColor="White" Margin="2">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="30*" />
        <RowDefinition Height="70*" />
      </Grid.RowDefinitions>


      <Frame Grid.Row="0" Style="{StaticResource FrameCardViewStyle}">
        <StackLayout Orientation="Horizontal">

          <StackLayout Orientation="Vertical" >
            <Label Text="Horizon" HorizontalTextAlignment="Left" FontSize="15">
            </Label>
            <ListView x:Name="listView" SeparatorVisibility="Default" ItemsSource="{Binding AvailableDays}" SelectedItem="{Binding SelectedDays}" >
              <ListView.ItemTemplate>
                <DataTemplate>
                  <TextCell Text="{Binding .}"/>
                </DataTemplate>
              </ListView.ItemTemplate>
            </ListView>
          </StackLayout>
        </StackLayout>
      </Frame>

      <Frame Grid.Row="1" Style="{StaticResource FrameCardViewStyle}">
        <Grid Margin="1">
          <Grid.RowDefinitions>
            <RowDefinition Height="4*" />
            <RowDefinition Height="4*" />
            <RowDefinition Height="80*" />
          </Grid.RowDefinitions>
          <Label Grid.Row="0" Text="{Binding CompanyName}" Style="{StaticResource CenteredLabelStyle}"></Label>
          <Label Grid.Row="1" Text="{Binding ChartTitle}" Style="{StaticResource CenteredLabelStyle}"></Label>
          <RefreshView Grid.Row="2" IsRefreshing="{Binding IsRefreshing, Mode=TwoWay}" Command="{Binding RefreshCommand}">
            <ScrollView>
              <dd:CanvasView x:Name="GainLossSeriesCanvas" Renderer="{Binding Renderer}"/>
            </ScrollView>
          </RefreshView>
        </Grid>
      </Frame>

    </Grid>
  </ContentPage.Content>
</ContentPage>