<?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"
             xmlns:controls="clr-namespace:AsReaderSDK4MAUIDemo.CustomControls"
             x:Class="AsReaderSDK4MAUIDemo.MainPage">

    <ContentPage.ToolbarItems>
        <ToolbarItem x:Name="Settings" Clicked="OnSettingsClicked" />
    </ContentPage.ToolbarItems>

    <StackLayout>
        <Label Text=""  Background="Gray" HorizontalOptions="Fill" HeightRequest="5" Margin="0, 0, 0, 0"/>
        <StackLayout Orientation="Horizontal">
            <Label x:Name="TagLabel" Text="0 tags" TextColor="Black" FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="Start" WidthRequest="100" Margin="40, 10, 0, 5"/>
            <Label x:Name="StatusLabel" Text="UnPlugged"  TextColor="Red" VerticalOptions="Center" HorizontalOptions="CenterAndExpand" Margin="-140, 10, 0, 5"/>
        </StackLayout>
        <Label Text="" Background="Gray" HorizontalOptions="Fill" HeightRequest="1" Margin="0, 5, 0, 5"/>
        <Grid BackgroundColor="White" >
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="70"/>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="70"/>
            </Grid.ColumnDefinitions>
            <Image Grid.Row="0" Grid.Column="0"
                x:Name="BatteryImage"
                Source="battery.png"
                WidthRequest="50"
                HeightRequest="30"
                HorizontalOptions="Start"
                Margin="20, 5, 0, 5" />
            <StackLayout Grid.Row="0" Grid.Column="1" x:Name="connectTypeStackLayout" Orientation="Horizontal" HorizontalOptions="Center">
                <Button x:Name="USBButton" Text="USB"  TextColor="blue" BackgroundColor="White" BorderColor="blue" BorderWidth="1" Clicked="OnUSBClicked" Margin="0, 5, 0, 5"/>
                <Button x:Name="BLEButton" Text="BLE"  TextColor="Black" BackgroundColor="White" BorderColor="Black" BorderWidth="1" Clicked="OnBLEClicked" Margin="0, 5, 0, 5"/>
            </StackLayout>
            <ImageButton  Grid.Row="0" Grid.Column="2"  x:Name="BLEScanButton" Source = "bledis.png" Aspect="AspectFit" Clicked="OnBLEScanClicked" HorizontalOptions="EndAndExpand" WidthRequest="35" HeightRequest="35" Margin="0, 5, 10, 5"/>
        </Grid >
        <StackLayout Orientation="Horizontal">
            <Button x:Name="BarcodeButton" Text="BAR"  TextColor="LightGray" BackgroundColor="White" BorderColor="LightGray" BorderWidth="1" Clicked="OnBarcodeClicked" HorizontalOptions="CenterAndExpand" Margin="10, 5, 0, 5"/>
            <Button x:Name="RfidButton" Text="RFID"  TextColor="LightGray" BackgroundColor="White" BorderColor="LightGray" BorderWidth="1" Clicked="OnRfidClicked" HorizontalOptions="CenterAndExpand"  Margin="0, 5, 0, 5"/>
            <Button x:Name="NfcButton" Text="NFC"  TextColor="LightGray" BackgroundColor="White" BorderColor="LightGray" BorderWidth="1" Clicked="OnNfcClicked" HorizontalOptions="CenterAndExpand" Margin="0, 5, 0, 5"/>
            <Button x:Name="DualButton" Text="DUAL"  TextColor="LightGray" BackgroundColor="White" BorderColor="LightGray" BorderWidth="1" Clicked="OnDualClicked" HorizontalOptions="CenterAndExpand" Margin="0, 5, 0, 5"/>
            <Button x:Name="LfButton" Text="LF"  TextColor="LightGray" BackgroundColor="White" BorderColor="LightGray" BorderWidth="1" Clicked="OnLFClicked" HorizontalOptions="CenterAndExpand" Margin="0, 5, 10, 5"/>
        </StackLayout>
        <Label Text=""  Background="Gray" HorizontalOptions="Fill" HeightRequest="5" Margin="0, 5, 0, 5"/>
        <ListView x:Name="ListView"
                  ItemTapped="OnListViewItemTapped"
                  SelectionMode="None"
                  CachingStrategy="RecycleElement">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <controls:ListCell Type="{Binding Type}" Pc="{Binding Pc}" Epc="{Binding Epc}" Count="{Binding Count}" />
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <Label Text=""  Background="Gray" HorizontalOptions="Fill" HeightRequest="5" Margin="0, 5, 0, 5"/>
        <StackLayout Orientation="Horizontal" HeightRequest="50">
            <Switch x:Name="ConnectSwitch" IsToggled="False" Toggled="OnToggledConnect" Margin="20, 8, 0, 5"/>
            <Button x:Name="StartScanButton" Text="Read"  TextColor="Blue" BackgroundColor="White" Clicked="OnScanClicked" HorizontalOptions="EndAndExpand" Margin="0, 0, 0, 0"/>
            <Button x:Name="ClearButton" Text="Clear"  TextColor="Blue" BackgroundColor="White" Clicked="OnClearClicked" HorizontalOptions="EndAndExpand" Margin="0, 0, 0, 0"/>
            <Button x:Name="StopButton" Text="Stop"  TextColor="Blue" BackgroundColor="White" Clicked="OnStopClicked" HorizontalOptions="EndAndExpand" Margin="0, 0, 0, 0"/>
        </StackLayout>
    </StackLayout>

</ContentPage>