<?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.UserListPage"
             xmlns:converters="clr-namespace:Borepin.Converter"
             xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
             Title="{x:Static resource_text:TextResource.TITLE_Users}">
    <NavigationPage.TitleView>
        <Button Text="Refresh" HorizontalOptions="End" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" Command="{Binding RefreshCommand}"/>
    </NavigationPage.TitleView>
    <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}}">
                <StackLayout IsVisible="{Binding IsConnected}">
                    <Button Text="{x:Static resource_text:TextResource.UserListPage_AddUser}" Command="{Binding AddUserCommand}" Style="{StaticResource Style_Button_Primary}"/>
                    <ListView ItemsSource="{Binding UserListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <views:UserListItemView />
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
                <StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
                    <Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
                </StackLayout>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
