added button to refresh the buttons on the left in the menuview, to show new entries that were just made

This commit is contained in:
taarly 2025-06-30 19:58:43 +02:00
parent 6329e63310
commit cd3822aaf8
2 changed files with 33 additions and 13 deletions

View File

@ -9,7 +9,8 @@
<Style Selector="TextBlock"> <Style Selector="TextBlock">
<Setter Property="FontSize" Value="16" /> <Setter Property="FontSize" Value="16" />
<Setter Property="Foreground" Value= "Gray" /> <Setter Property="Foreground" Value= "Gray" />
<Setter Property="Margin" Value="0,10" /> <Setter Property="Margin" Value="0,5" />
<Setter Property="Padding" Value="0,8"/>
</Style> </Style>
<Style Selector="TextBox"> <Style Selector="TextBox">
<Setter Property="Height" Value="35" /> <Setter Property="Height" Value="35" />
@ -18,8 +19,8 @@
<Setter Property="TextWrapping" Value="Wrap" /> <Setter Property="TextWrapping" Value="Wrap" />
</Style> </Style>
<Style Selector="Button.icon"> <Style Selector="Button.icon">
<Setter Property="Width" Value="35" /> <Setter Property="Width" Value="25" />
<Setter Property="Height" Value="35" /> <Setter Property="Height" Value="25" />
<Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="CornerRadius" Value="4" /> <Setter Property="CornerRadius" Value="4" />
@ -40,18 +41,32 @@
<StackPanel Margin="10" x:Name="entriesContainer" /> <StackPanel Margin="10" x:Name="entriesContainer" />
</ScrollViewer> </ScrollViewer>
<Button
Background="Yellow"
Content="↻"
CornerRadius="22"
FontSize="24"
Foreground="White"
Height="35"
HorizontalAlignment="Left"
IsEnabled="True"
Margin="0,0,-50,20"
VerticalAlignment="Bottom"
Width="35"
x:Name="RefreshButton"
Click="RefreshButton_OnClick"/>
<Button <Button
Background="Red" Background="Red"
Content="-" Content="-"
CornerRadius="22" CornerRadius="22"
FontSize="24" FontSize="24"
Foreground="White" Foreground="White"
Height="45" Height="35"
HorizontalAlignment="Center" HorizontalAlignment="Center"
IsEnabled="False" IsEnabled="False"
Margin="0,0,-50,20" Margin="0,0,-50,20"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Width="45" Width="35"
x:Name="DeleteButton" /> x:Name="DeleteButton" />
<Button <Button
Background="#4CAF50" Background="#4CAF50"
@ -60,11 +75,11 @@
CornerRadius="22" CornerRadius="22"
FontSize="24" FontSize="24"
Foreground="White" Foreground="White"
Height="45" Height="35"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0,0,20,20" Margin="0,0,20,20"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Width="45" Width="35"
x:Name="NewEntryButton" /> x:Name="NewEntryButton" />
</Grid> </Grid>
</Border> </Border>

View File

@ -28,6 +28,10 @@ public partial class MenuView : Window
_controller = controller; _controller = controller;
} }
private async void RefreshButton_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
CreateEntryButtons();
}
//opens the window to create a new entry //opens the window to create a new entry
private async void NewEntryButton_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e) private async void NewEntryButton_OnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
@ -67,7 +71,6 @@ public partial class MenuView : Window
//shows the details for the selected entry //shows the details for the selected entry
public void EntryDetails(SavedEntries entry) public void EntryDetails(SavedEntries entry)
{ {
// ... vorheriger Code bleibt gleich bis zur PasswordBox ...
ShowEntryDetailsL.Children.Clear(); ShowEntryDetailsL.Children.Clear();
ShowEntryDetailsR.Children.Clear(); ShowEntryDetailsR.Children.Clear();
@ -171,17 +174,15 @@ public partial class MenuView : Window
{ {
await clipboard.SetTextAsync(Crypto.DecryptPassword(entry.Pass)); await clipboard.SetTextAsync(Crypto.DecryptPassword(entry.Pass));
// Visuelle Bestätigung // visual feedback
copyPasswordButton.Content = "✓"; copyPasswordButton.Content = "✓";
await Task.Delay(1000); await Task.Delay(1000);
copyPasswordButton.Content = "📋"; copyPasswordButton.Content = "📋";
} }
}; };
buttonContainer.Children.Add(showPasswordButton);
buttonContainer.Children.Add(copyPasswordButton); //show note if it exists
ShowEntryDetailsR.Children.Add(buttonContainer);
if (!string.IsNullOrEmpty(entry.Note)) if (!string.IsNullOrEmpty(entry.Note))
{ {
ShowEntryDetailsR.Children.Add(new TextBox() ShowEntryDetailsR.Children.Add(new TextBox()
@ -190,6 +191,10 @@ public partial class MenuView : Window
Margin = new Thickness(0, 0, 0, 5) Margin = new Thickness(0, 0, 0, 5)
}); });
} }
//add buttons
buttonContainer.Children.Add(showPasswordButton);
buttonContainer.Children.Add(copyPasswordButton);
ShowEntryDetailsR.Children.Add(buttonContainer);