<?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:views="clr-namespace:Borepin.View"
             x:Class="Borepin.Page.ServerListPage"
             xmlns:converters="clr-namespace:Borepin.Converter"
             xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
             Title="{x:Static resource_text:TextResource.TITLE_Servers}">
    <ContentPage.Resources>
        <ResourceDictionary>
            <converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
            <converters:ListNotEmptyConverter x:Key="ListNotEmptyConverter"/>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.Content>
        <StackLayout Padding="20">
            <StackLayout IsVisible="{Binding IsBusy}">
                <ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
            </StackLayout>
            <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}" VerticalOptions="FillAndExpand">
                <Label Text="{x:Static resource_text:TextResource.ServerListPage_ActiveConnection}" IsVisible="{Binding HasActiveConnection}"/>
                <StackLayout IsVisible="{Binding HasActiveConnection}">
                    <views:ServerListItemView BindingContext="{Binding ActiveConnection}" MinimumHeightRequest="50"/>
                </StackLayout>
                <Label Text="{x:Static resource_text:TextResource.ServerListPage_LastConnection}" IsVisible="{Binding ServerListItemViewModel_List, Converter={StaticResource ListNotEmptyConverter}}"/>
                <ListView ItemsSource="{Binding ServerListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent" VerticalOptions="StartAndExpand">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <views:ServerListItemView/>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <Button Text="{x:Static resource_text:TextResource.ServerListPage_ConnectToNewServer}" Command="{Binding AddInstancesCommand}" Style="{StaticResource Style_Button_Primary}" VerticalOptions="End"/>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>