<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Borepin.Page.UserPage"
             xmlns:converters="clr-namespace:Borepin.Converter" 
             xmlns:views="clr-namespace:Borepin.View"
             xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
             Title="{x:Static resource_text:TextResource.TITLE_User}">
    <ContentPage.Resources>
        <ResourceDictionary>
            <converters:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
            <converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
            <converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/>
            <converters:MachineStateStringConverter x:Key="MachineStateStringConverter"/>
            <converters:IsNotNullBoolConverter x:Key="IsNotNullBoolConverter"/>
        </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>
                <Label Text="{Binding UserItem.Username}" Style="{StaticResource LabelStyle_Title}"/>
                <ListView ItemsSource="{Binding PermissionSelectViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <views:PermissionSelectView />
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <StackLayout IsVisible="{Binding CanAdmin}">
                    <Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
                    <Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/>
                    <Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
                </StackLayout>
                <Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>