make timer transparent instead of invisible to avoid disturbing layout

This commit is contained in:
2026-05-03 15:41:27 +03:00
parent 1cb50c5b04
commit 003dbc264c
3 changed files with 23 additions and 4 deletions

View File

@@ -0,0 +1,18 @@
using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace KeyKeeper.Views.Converters;
public class StringPresenceToOpacityConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return string.IsNullOrEmpty(value as string) ? 0.0 : 1.0;
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}

View File

@@ -5,7 +5,7 @@ using Avalonia.Data.Converters;
using KeyKeeper.PasswordStore;
using KeyKeeper.ViewModels;
namespace KeyKeeper.Views;
namespace KeyKeeper.Views.Converters;
public class TotpCodeConverter : IMultiValueConverter
{

View File

@@ -3,6 +3,7 @@
xmlns:vm="using:KeyKeeper.ViewModels"
xmlns:i="using:Avalonia.Interactivity"
xmlns:kkp="using:KeyKeeper.Views"
xmlns:converters="using:KeyKeeper.Views.Converters"
x:Class="KeyKeeper.Views.RepositoryWindow"
Closing="RepositoryWindow_Closing"
Title="KeyKeeper - Password store"
@@ -13,7 +14,8 @@
x:DataType="vm:RepositoryWindowViewModel">
<Window.Resources>
<kkp:TotpCodeConverter x:Key="TotpCodeConverter" />
<converters:TotpCodeConverter x:Key="TotpCodeConverter" />
<converters:StringPresenceToOpacityConverter x:Key="StringPresenceToOpacityConverter" />
</Window.Resources>
<Window.DataTemplates>
@@ -36,8 +38,7 @@
Padding="8,4"
HorizontalAlignment="Left"
Margin="0,12,0,12"
IsVisible="{Binding $parent[Window].DataContext.LockTimerDisplay,
Converter={x:Static StringConverters.IsNotNullOrEmpty}}">
Opacity="{Binding $parent[Window].DataContext.LockTimerDisplay, Converter={StaticResource StringPresenceToOpacityConverter}}">
<StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">