Skip to content

Commit

Permalink
Maintenance and font adjustments (#86)
Browse files Browse the repository at this point in the history
#84 adjust font sizes
fix height on properties page
add fallback for user logged in status
fix typo in readme
cricketthomas authored Aug 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a7ed341 commit b537e1b
Showing 23 changed files with 674 additions and 584 deletions.
Binary file removed KeyVaultExplorer/Assets/kv-icon.ico
Binary file not shown.
Binary file removed KeyVaultExplorer/Assets/kv-icon.png
Binary file not shown.
3 changes: 3 additions & 0 deletions KeyVaultExplorer/KeyVaultExplorer.csproj
Original file line number Diff line number Diff line change
@@ -102,6 +102,9 @@
</ItemGroup>

<ItemGroup>
<Compile Update="Views\CustomControls\UserStatusTag.axaml.cs">
<DependentUpon>UserStatusTag.axaml</DependentUpon>
</Compile>
<Compile Update="Views\Pages\PropertiesDialogs\CreateNewSecretVersion.axaml.cs">
<DependentUpon>CreateNewSecretVersion.axaml</DependentUpon>
</Compile>
3 changes: 2 additions & 1 deletion KeyVaultExplorer/Resources/PercentageConverter.cs
Original file line number Diff line number Diff line change
@@ -11,7 +11,8 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
if (value is double width)
{
var calculatedWidth = width * 0.25;
return calculatedWidth < 310 ? 310 : calculatedWidth;
var minWidth = calculatedWidth < 310 ? 310 : calculatedWidth;
return minWidth > 550 ? 550 : minWidth;
}
return value;
}
6 changes: 5 additions & 1 deletion KeyVaultExplorer/Resources/Resources.axaml
Original file line number Diff line number Diff line change
@@ -28,6 +28,9 @@
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="TabViewBorderBrush" ResourceKey="AccentFillColorTertiaryBrush" />

<StaticResource x:Key="IconForegroundColor" ResourceKey="IconForegroundColorBrush" />
<SolidColorBrush x:Key="IconForegroundColorBrush" Color="Transparent" />

<SolidColorBrush
x:Key="AccentFillColorTertiaryBrush"
Opacity="0.15"
@@ -41,7 +44,8 @@
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<StaticResource x:Key="TabViewBorderBrush" ResourceKey="AccentFillColorTertiaryBrush" />

<StaticResource x:Key="IconForegroundColor" ResourceKey="IconForegroundColorBrush" />
<SolidColorBrush x:Key="IconForegroundColorBrush" Color="#9a2e00" />
<SolidColorBrush
x:Key="AccentFillColorTertiaryBrush"
Opacity="0.15"
29 changes: 16 additions & 13 deletions KeyVaultExplorer/Resources/Styles.axaml
Original file line number Diff line number Diff line change
@@ -113,35 +113,38 @@
<!-- Datagrid styles -->

<Style Selector="DataGridColumnHeader">
<Setter Property="MinHeight" Value="25" />
<Setter Property="Height" Value="25" />
<Setter Property="MinHeight" Value="27" />
<Setter Property="Height" Value="27" />
</Style>
<Style Selector="DataGridRowGroupHeader">
<Setter Property="MinHeight" Value="25" />
<Setter Property="Height" Value="25" />
</Style>
<Style Selector="DataGrid DataGridRow:nth-child(2n)">
<Setter Property="Background" Value="rgba(148, 148, 148, 0.04)" />
<Setter Property="MinHeight" Value="27" />
<Setter Property="Height" Value="27" />
</Style>

<Style Selector="DataGridRow">
<Setter Property="Height" Value="25" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="Height" Value="27" />
<Setter Property="FontSize" Value="14" />
</Style>
<Style Selector="DataGridCell">
<Setter Property="Height" Value="22" />
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<Setter Property="Height" Value="27" />
<Setter Property="FontSize" Value="14" />
</Style>

<Style Selector="DataGridRow">
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />
<!--<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" />-->
<Setter Property="FontSize" Value="14" />
<Setter Property="Focusable" Value="False" />
</Style>

<Style Selector="DataGridCell/template/ Grid#PART_CellRoot">
<Setter Property="Height" Value="25" />
<Setter Property="Height" Value="27" />
</Style>


<Style Selector="DataGrid DataGridRow:nth-child(2n)">
<Setter Property="Background" Value="rgba(148, 148, 148, 0.04)" />
</Style>

<Style Selector="DataGrid:focus DataGridCell:current /template/ Grid#FocusVisual">
<Setter Property="IsVisible" Value="False" />
<Setter Property="Background" Value="Transparent" />
2 changes: 1 addition & 1 deletion KeyVaultExplorer/Services/ServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ public static void AddCommonServices(this IServiceCollection collection)
collection.AddSingleton<AuthService>();
collection.AddSingleton<VaultService>();
collection.AddSingleton<TabViewPageViewModel>();
collection.AddSingleton<ToolBarViewModel>();
//collection.AddSingleton<ToolBarViewModel>();
collection.AddSingleton<KeyVaultTreeListViewModel>();
collection.AddSingleton<SettingsPageViewModel>();
collection.AddSingleton<MainViewModel>();
54 changes: 0 additions & 54 deletions KeyVaultExplorer/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -68,57 +68,3 @@ private async Task SignOut()
AuthenticatedUserClaims = null;
}
}

public class NavigationFactory : INavigationPageFactory
{
// Do this to avoid needing Activator.CreateInstance to create from type info
// and to avoid a ridiculous amount of 'ifs'
private readonly Control[] _pages =
{
new MainPage(),
new SubscriptionsPage(),
new SettingsPage(),
};

private readonly Dictionary<string, Func<Control>> CorePages = new Dictionary<string, Func<Control>>
{
{ "MainPage", () => new MainPage() },
{ "SubscriptionsPage", () => new SubscriptionsPage() },
{ "SettingsPage", () => new SettingsPage() },
};

public NavigationFactory()
{
Instance = this;
}

private static NavigationFactory? Instance { get; set; }

public static Control[] GetPages()
{
return Instance!._pages;
}

// Create a page based on a Type, but you can create it however you want
public Control? GetPage(Type srcType)
{
// Return null here because we won't use this method at all
CorePages.TryGetValue(srcType.FullName, out var func);
Control page = null;
page = func();
return page;
}

// Create a page based on an object, such as a view model
public Control? GetPageFromObject(object target)
{
return target switch
{
MainPage => _pages[0],
SubscriptionsPage => _pages[1],
SettingsPage => _pages[2],

_ => throw new Exception()
};
}
}
61 changes: 61 additions & 0 deletions KeyVaultExplorer/ViewModels/NavigationFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Avalonia.Controls;
using FluentAvalonia.UI.Controls;
using KeyVaultExplorer.Views.Pages;
using System;
using System.Collections.Generic;

namespace KeyVaultExplorer.ViewModels;

public class NavigationFactory : INavigationPageFactory
{
// Do this to avoid needing Activator.CreateInstance to create from type info
// and to avoid a ridiculous amount of 'ifs'
private readonly Control[] _pages =
{
new MainPage(),
new SubscriptionsPage(),
new SettingsPage(),
};

private readonly Dictionary<string, Func<Control>> CorePages = new Dictionary<string, Func<Control>>
{
{ "MainPage", () => new MainPage() },
{ "SubscriptionsPage", () => new SubscriptionsPage() },
{ "SettingsPage", () => new SettingsPage() },
};

public NavigationFactory()
{
Instance = this;
}

private static NavigationFactory? Instance { get; set; }

public static Control[] GetPages()
{
return Instance!._pages;
}

// Create a page based on a Type, but you can create it however you want
public Control? GetPage(Type srcType)
{
// Return null here because we won't use this method at all
CorePages.TryGetValue(srcType.FullName, out var func);
Control page = null;
page = func();
return page;
}

// Create a page based on an object, such as a view model
public Control? GetPageFromObject(object target)
{
return target switch
{
MainPage => _pages[0],
SubscriptionsPage => _pages[1],
SettingsPage => _pages[2],

_ => throw new Exception()
};
}
}
3 changes: 3 additions & 0 deletions KeyVaultExplorer/ViewModels/VaultPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ public partial class VaultPageViewModel : ViewModelBase
private NotificationViewModel _notificationViewModel;

private SettingsPageViewModel _settingsPageViewModel;
public string VaultTotalString => VaultContents.Count == 0 || VaultContents.Count > 1 ? $"{VaultContents.Count} items" : "1 item";

[ObservableProperty]
private string authorizationMessage;
@@ -47,6 +48,7 @@ public partial class VaultPageViewModel : ViewModelBase
private bool hasAuthorizationError = false;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(VaultTotalString))]
private bool isBusy = false;

[ObservableProperty]
@@ -59,6 +61,7 @@ public partial class VaultPageViewModel : ViewModelBase
private TabStripItem selectedTab;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(VaultTotalString))]
private ObservableCollection<KeyVaultContentsAmalgamation> vaultContents;

[ObservableProperty]
2 changes: 2 additions & 0 deletions KeyVaultExplorer/Views/CustomControls/KeyVaultTreeList.axaml
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@
HorizontalAlignment="Stretch"
VerticalContentAlignment="Center"
AcceptsReturn="False"
Background="{DynamicResource LayerFillColorAltBrush}"
Classes.IsSmall="True"
Classes.clearButton="True"
FontSize="{StaticResource FontSizeSmall}"
@@ -274,6 +275,7 @@
<ui:BitmapIcon
Width="16"
Height="16"
Foreground="{DynamicResource IconForegroundColor}"
RenderOptions.BitmapInterpolationMode="HighQuality"
ShowAsMonochrome="True"
UriSource="avares://KeyVaultExplorer/Assets/KeyVault.png" />
2 changes: 1 addition & 1 deletion KeyVaultExplorer/Views/CustomControls/ToolBar.axaml.cs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ public partial class ToolBar : UserControl
public ToolBar()
{
InitializeComponent();
DataContext = Defaults.Locator.GetRequiredService<ToolBarViewModel>();
//DataContext = Defaults.Locator.GetRequiredService<ToolBarViewModel>();
}

private void SettingsButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
67 changes: 67 additions & 0 deletions KeyVaultExplorer/Views/CustomControls/UserStatusTag.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<UserControl
x:Class="KeyVaultExplorer.Views.CustomControls.UserStatusTag"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:KeyVaultExplorer.Models;assembly=KeyVaultExplorer"
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:vm="using:KeyVaultExplorer.ViewModels"
d:DesignHeight="150"
d:DesignWidth="925"
x:DataType="vm:MainViewModel"
mc:Ignorable="d">

<Design.DataContext>
<vm:MainViewModel />
</Design.DataContext>


<StackPanel
Grid.Row="1"
HorizontalAlignment="Stretch"
Background="{DynamicResource SolidBackgroundFillColorTertiaryBrush}"
IsHitTestVisible="False">

<StackPanel
HorizontalAlignment="Right"
IsVisible="{Binding !IsAuthenticated}"
Orientation="Horizontal">
<ui:BitmapIcon
Width="16"
Height="16"
VerticalAlignment="Bottom"
RenderOptions.BitmapInterpolationMode="HighQuality"
UriSource="avares://KeyVaultExplorer/Assets/StatusErrorOutline.png" />
<TextBlock
Margin="4,0"
Background="{x:Null}"
FontSize="{StaticResource FontSizeSmall}"
Text="You are currently signed out"
Theme="{StaticResource CaptionTextBlockStyle}" />
</StackPanel>


<StackPanel
HorizontalAlignment="Right"
IsVisible="{Binding IsAuthenticated}"
Orientation="Horizontal">
<ui:BitmapIcon
Width="16"
Height="16"
Margin="0,2,0,0"
VerticalAlignment="Bottom"
IsVisible="{Binding AuthenticatedUserClaims.TenantId}"
RenderOptions.BitmapInterpolationMode="HighQuality"
ShowAsMonochrome="True"
UriSource="avares://KeyVaultExplorer/Assets/Cloud.png" />
<TextBlock
Margin="5,0"
Background="{x:Null}"
FontSize="{StaticResource FontSizeSmall}"
Text="{Binding AuthenticatedUserClaims.Email}"
Theme="{StaticResource CaptionTextBlockStyle}" />
</StackPanel>
</StackPanel>

</UserControl>
19 changes: 19 additions & 0 deletions KeyVaultExplorer/Views/CustomControls/UserStatusTag.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Threading;
using KeyVaultExplorer.ViewModels;
using KeyVaultExplorer.Services;
using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;

namespace KeyVaultExplorer.Views.CustomControls;

public partial class UserStatusTag : UserControl
{
public UserStatusTag()
{
InitializeComponent();
DataContext = Defaults.Locator.GetRequiredService<MainViewModel>();
}
}
Loading

0 comments on commit b537e1b

Please sign in to comment.