using Avalonia; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Media; using Project.Controller; using Project.Persistence; namespace Project.View; public partial class MenuView : Window { readonly AppController? _controller; public MenuView() { InitializeComponent(); CreateEntryButtons(); } public MenuView(AppController controller) { InitializeComponent(); _controller = controller; } private async void NewEntryButton_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e) { var newEntryWindow = new NewEntry(); newEntryWindow.Show(); } private void CreateEntryButtons() { // dynamically creating buttons for each entry entriesContainer.Children.Clear(); // Clear existing buttons var entries = SQLite.GetEntries(AppController._currentUser); foreach (var entry in entries) { var button = new Button { Content = entry.Name, // Display the entry name on the button Margin = new Thickness(5), Padding = new Thickness(10), Width = 200 }; // Add click handler for the button //button.Click += (sender, args) => ShowEntryDetails(entry); // Add the button to your container entriesContainer.Children.Add(button); } } public void AfterSavingNewEntry() { CreateEntryButtons(); // Refresh the buttons } }