<?xml version="1.0"
      encoding="utf-8"?>

<Page x:Class="Marechai.App.Presentation.Views.MainPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:utu="using:Uno.Toolkit.UI"
      xmlns:uen="using:Uno.Extensions.Navigation.UI"
      xmlns:components="clr-namespace:Marechai.App.Presentation.Components"
      NavigationCacheMode="Required"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid utu:SafeArea.Insets="VisibleBounds">
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="SidebarColumn"
                              Width="280" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" /> <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Sidebar -->
        <Grid x:Name="SidebarWrapper"
              Grid.Row="0"
              Grid.RowSpan="2"
              Grid.Column="0"
              Width="280"
              HorizontalAlignment="Left">
            <components:Sidebar x:Name="SidebarPanel"
                                DataContext="{Binding}"
                                VerticalAlignment="Stretch" />
        </Grid>

        <!-- Header -->
        <utu:NavigationBar Grid.Row="0"
                           Grid.Column="1"
                           Content="{Binding Title}">
            <utu:NavigationBar.MainCommand>
                <AppBarButton Icon="GlobalNavigationButton"
                              Command="{Binding ToggleSidebarCommand}"
                              Label="Toggle Sidebar"
                              AutomationProperties.Name="Toggle sidebar visibility" />
            </utu:NavigationBar.MainCommand>
        </utu:NavigationBar>

        <!-- Content Region for Navigation -->
        <ContentControl Grid.Row="1"
                        Grid.Column="1"
                        HorizontalContentAlignment="Stretch"
                        VerticalContentAlignment="Stretch"
                        uen:Region.Attached="True"
                        uen:Region.Name="Main" />
    </Grid>
</Page>