<?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="MauiApi.MainPage"
             Title="REST API">
    <Grid Padding="20" RowDefinitions="Auto,Auto,Auto,*" RowSpacing="12">
        <Label Text="REST API Demo" FontSize="26"
               FontAttributes="Bold" />
        <Button Grid.Row="1" x:Name="LoadButton"
                Text="Load posts" Clicked="OnLoadClicked" />
        <Label Grid.Row="2" x:Name="StatusLabel"
               Text="Tap Load posts to begin." />
        <CollectionView Grid.Row="3" x:Name="PostsView"
                        EmptyView="No posts loaded.">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <VerticalStackLayout Padding="8" Spacing="4">
                        <Label Text="{Binding Title}" FontAttributes="Bold" />
                        <Label Text="{Binding Body}" FontSize="13" />
                    </VerticalStackLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </Grid>
</ContentPage>
