<?xml version="1.0" encoding="utf-8"?>

<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:material="clr-namespace:XF.Material.Forms.UI;assembly=XF.Material"
             xmlns:local="clr-namespace:InABox.Mobile"
             x:Class="InABox.Mobile.MobileTimeButton">

    <ContentView.Resources>
        <local:TimeSpanFormatter x:Key="TimeSpanFormatter" x:Name="_timespanFormatter" Prompt="Select Time"/>
    </ContentView.Resources>
    
    <ContentView.ControlTemplate>
        
        <ControlTemplate>
            
            <local:MobileCard 
                x:Name="_frame"
                Padding = "{TemplateBinding Padding}"
                IsEnabled="True"
                BackgroundColor="{TemplateBinding ButtonColor}"
                BorderColor="{TemplateBinding BorderColor}"
                IsClickable="True"
                Clicked="_frame_OnClicked">
                <local:MobileCard.Triggers>
                    <DataTrigger TargetType="local:MobileCard" Binding="{TemplateBinding IsEnabled}" Value="False">
                        <Setter Property="BackgroundColor" Value="Silver" />
                    </DataTrigger>
                    <DataTrigger TargetType="local:MobileCard" Binding="{TemplateBinding IsEnabled}" Value="False">
                        <Setter Property="BorderColor" Value="Gray" />
                    </DataTrigger>
                </local:MobileCard.Triggers>
                
                <material:MaterialLabel 
                        x:Name="_label" 
                        Text="{TemplateBinding Time, Converter={StaticResource TimeSpanFormatter}}" 
                        VerticalOptions="CenterAndExpand" 
                        HorizontalOptions="CenterAndExpand"
                        TypeScale = "{TemplateBinding TypeScale}"
                        HorizontalTextAlignment = "Center"
                        TextColor="{TemplateBinding TextColor}"
                    />
                    
            </local:MobileCard>
            
        </ControlTemplate>
        
    </ContentView.ControlTemplate>

</ContentView>