<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Northwind.Maui.Client.CustomersPage"
             Title="Klienci">

  <VerticalStackLayout Spacing="15" Padding="20">

    <HorizontalStackLayout Spacing="10">
      <Label Text="Klienci" FontSize="Title" />
      <Button Text="Dodaj" Clicked="Add_Clicked" HorizontalOptions="End" />
    </HorizontalStackLayout>
    <Label x:Name="InfoLabel" />
    <Label x:Name="ErrorLabel" IsVisible="false" />
    <ListView ItemsSource="{Binding .}" 
            VerticalOptions="Start" 
            HorizontalOptions="Start" 
            IsPullToRefreshEnabled="True" 
            ItemTapped="Customer_Tapped" 
            Refreshing="Customers_Refreshing">
      <ListView.ItemTemplate>
        <DataTemplate>
          <TextCell Text="{Binding CompanyName}" 
                  Detail="{Binding Location}"
                  TextColor="{DynamicResource PrimaryTextColor}"
                  DetailColor="{DynamicResource PrimaryTextColor}" >
            <TextCell.ContextActions>
              <MenuItem Clicked="Customer_Phoned" Text="Zadzwoń" />
              <MenuItem Clicked="Customer_Deleted" Text="Usuń" 
                      IsDestructive="True" />
            </TextCell.ContextActions>
          </TextCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>

  </VerticalStackLayout>
</ContentPage>