<?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" xmlns:prism="http://prismlibrary.com"
             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:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
            <converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
            <converters:ListNotEmptyConverter x:Key="ListNotEmptyConverter"/>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.Content>
        <StackLayout Padding="20">
            <views:ConnectionStateView/>
            <StackLayout>
                <StackLayout.IsVisible>
                    <MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
                        <Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
                        <Binding Path="IsConnected" />
                    </MultiBinding>
                </StackLayout.IsVisible>
                <Button Text="{x:Static resource_text:TextResource.UserListPage_AddUser}" Command="{Binding AddUserCommand}" Style="{StaticResource Style_Button_Primary}"/>
                <SearchBar Text="{Binding SearchUsername}" SearchCommand="{Binding SearchUserCommand}">
                    <SearchBar.Behaviors>
                        <prism:EventToCommandBehavior EventName="TextChanged" Command="{Binding SearchUserCommand}"/>
                    </SearchBar.Behaviors>
                </SearchBar>
                <ListView ItemsSource="{Binding FilteredUserListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <views:UserListItemView />
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
