<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:ClaudeDo.Ui.ViewModels.Islands"
             xmlns:ctl="using:ClaudeDo.Ui.Views.Controls"
             xmlns:loc="using:ClaudeDo.Ui.Localization"
             x:Class="ClaudeDo.Ui.Views.Islands.NotesEditorView"
             x:DataType="vm:NotesEditorViewModel">
  <DockPanel Margin="16">
    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Spacing="8">
      <Button Classes="btn" Content="&#x2039;" Command="{Binding PrevDayCommand}"/>
      <ctl:ThemedDatePicker SelectedDate="{Binding CurrentDate, Mode=TwoWay}"/>
      <Button Classes="btn" Content="&#x203A;" Command="{Binding NextDayCommand}"/>
      <Button Classes="btn" Content="{loc:Tr notes.today}" Command="{Binding TodayCommand}"/>
      <TextBlock Classes="meta" VerticalAlignment="Center" Text="{Binding CurrentDayLabel}"/>
    </StackPanel>

    <DockPanel DockPanel.Dock="Top" Margin="0,12,0,8">
      <Button DockPanel.Dock="Right" Classes="btn" Content="{loc:Tr notes.add}" Margin="8,0,0,0"
              Command="{Binding AddBulletCommand}"/>
      <TextBox PlaceholderText="{loc:Tr notes.newNotePlaceholder}" Text="{Binding NewBulletText}">
        <TextBox.KeyBindings>
          <KeyBinding Gesture="Enter" Command="{Binding AddBulletCommand}"/>
        </TextBox.KeyBindings>
      </TextBox>
    </DockPanel>

    <ScrollViewer>
      <ItemsControl ItemsSource="{Binding Bullets}">
        <ItemsControl.ItemTemplate>
          <DataTemplate x:DataType="vm:NoteBulletViewModel">
            <TextBox Text="{Binding Text}" Margin="0,2"
                     LostFocus="OnBulletLostFocus"/>
          </DataTemplate>
        </ItemsControl.ItemTemplate>
      </ItemsControl>
    </ScrollViewer>
  </DockPanel>
</UserControl>
