<?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:converters="clr-namespace:PlantBox.Client.Converters"
             xmlns:statusbar="clr-namespace:PlantBox.Client.Forms.Controls.StatusBar"
             xmlns:models="clr-namespace:PlantBox.Client.Models"
             xmlns:viewmodels="clr-namespace:PlantBox.Client.ViewModels"
             xmlns:extensions="clr-namespace:PlantBox.Client.Extensions"
             x:Class="PlantBox.Client.Forms.Plant.CaptorsPage">
    <ContentPage.Resources>
        <FlexBasis x:Key="BarWidth">17%</FlexBasis>
        <converters:CaptorValueToDoubleConverter x:Key="CaptorConverter" />
    </ContentPage.Resources>
    <ContentPage.Content>
        <FlexLayout Direction="Row"
                    JustifyContent="SpaceAround"
                    VerticalOptions="FillAndExpand"
                    HorizontalOptions="FillAndExpand"
                    Margin="20">
            <statusbar:StatusBar Progress="{Binding HumidityCaptor.Value, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Humidity}}"
                                 Label="{Binding HumidityCaptor.Value, StringFormat='\{0:F1} %'}"
                                 ForegroundColor="{StaticResource HumidityColor}"
                                 HintColor="{StaticResource HumidityColorSecondary}"
                                 BoundColor="DarkSlateGray"
                                 BoundHeight="2"
                                 LowerBound="{Binding HumidityCaptor.Min, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Humidity}}"
                                 UpperBound="{Binding HumidityCaptor.Max, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Humidity}}"
                                 Image="{extensions:ImageResource Humidity_Icon.png}"
                                 FlexLayout.Basis="{StaticResource BarWidth}" />
            <statusbar:StatusBar Progress="{Binding LuminosityCaptor.Value, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Luminosity}}"
                                 Label="{Binding LuminosityCaptor.Value, StringFormat='\{0:F0} lux'}"
                                 ForegroundColor="{StaticResource LuminosityColor}"
                                 HintColor="{StaticResource LuminosityColorSecondary}"
                                 BoundColor="DarkSlateGray"
                                 BoundHeight="2"
                                 LowerBound="{Binding LuminosityCaptor.Min, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Luminosity}}"
                                 UpperBound="{Binding LuminosityCaptor.Max, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Luminosity}}"
                                 Image="{extensions:ImageResource Luminosity_Icon.png}"
                                 FlexLayout.Basis="{StaticResource BarWidth}" />
            <statusbar:StatusBar Progress="{Binding TemperatureCaptor.Value, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Temperature}}"
                                 Label="{Binding TemperatureCaptor.Value, StringFormat='\{0:F1} °C'}"
                                 ForegroundColor="{StaticResource TemperatureColor}"
                                 HintColor="{StaticResource TemperatureColorSecondary}"
                                 BoundColor="DarkSlateGray"
                                 BoundHeight="2"
                                 LowerBound="{Binding TemperatureCaptor.Min, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Temperature}}"
                                 UpperBound="{Binding TemperatureCaptor.Max, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Temperature}}"
                                 Image="{extensions:ImageResource Temperature_Icon.png}"
                                 FlexLayout.Basis="{StaticResource BarWidth}" />
            <statusbar:StatusBar Progress="{Binding TankValue, Converter={x:StaticResource CaptorConverter}, ConverterParameter={x:Static models:CaptorType.Tank}}"
                                 Label="{Binding TankValue, StringFormat='\{0:F0} %'}"
                                 ForegroundColor="{StaticResource HumidityColor}"
                                 HintColor="{StaticResource HumidityColorSecondary}"
                                 BoundColor="DarkSlateGray"
                                 BoundHeight="2"
                                 LowerBound="-1"
                                 UpperBound="-1"
                                 Image="{extensions:ImageResource Tank_Icon.png}"
                                 FlexLayout.Basis="{StaticResource BarWidth}" />

        </FlexLayout>
    </ContentPage.Content>
</ContentPage>