<?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:mobile="clr-namespace:InABox.Mobile;assembly=InABox.Mobile.Shared"
             x:Class="InABox.Mobile.MobileAccordion">
    <ContentView.Resources>
        <mobile:BooleanToColorConverter x:Key="BooleanToColorConverter" TrueColor="Gray" FalseColor="Transparent" />
    </ContentView.Resources>
    <ContentView.Content>
        <StackLayout
            x:Name="_stack"
            VerticalOptions="Fill"
            BackgroundColor="Transparent"
            Spacing="5"
            >

            <BindableLayout.ItemTemplate>
                <DataTemplate x:DataType="mobile:MobileAccordionItem">
                    <StackLayout 
                        Orientation="Vertical"
                        Spacing="5"
                        BackgroundColor="Transparent"
                        VerticalOptions="Fill"
                        Margin="0"
                        Padding="0"
                        >
                        
                        <mobile:MobileButton
                            MinimumHeightRequest="50"
                            HeightRequest="50"
                            Margin="0,0,0,0"
                            CornerRadius="5"
                            Text="{Binding Text}"
                            Tag="{Binding .}"
                            Clicked="Header_Clicked"
                            IsVisible="{Binding ButtonVisible}"/>
                        
                        <Frame
                            CornerRadius="5"
                            Margin="0,0,0,0"
                            BorderColor="{Binding FrameVisible, Converter={StaticResource BooleanToColorConverter}}"
                            BackgroundColor="Transparent"
                            Padding="0"
                            VerticalOptions="Fill"
                            HeightRequest="2000"
                            HasShadow="False"
                            IsVisible="{Binding Visible}"
                            IsClippedToBounds="True">
                            <ScrollView>
                                <ContentView Content="{Binding Content}" VerticalOptions="Fill"/>
                            </ScrollView>
                        </Frame>
                        
                    </StackLayout>
                </DataTemplate>
            </BindableLayout.ItemTemplate>
        </StackLayout>
    </ContentView.Content>
</ContentView>