Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account copy #8

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build_avalonia_on_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build Avalonia on Pull Request

on:
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'

- name: Install dependencies
run: |
cd PWManager.Avalonia
dotnet restore

- name: Build
run: |
cd PWManager.Avalonia
dotnet build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build on Pull Request
name: Build CLI on Pull Request

on:
pull_request:
Expand All @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_on_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'

- name: Install dependencies
run: |
Expand Down
21 changes: 16 additions & 5 deletions PWManager.Avalonia/Controls/AccountsControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@

<SplitView x:Name="splitPane" PanePlacement="Right" DisplayMode="Inline" IsPaneOpen="false">
<SplitView.Pane>
<!-- <StackPanel FlowDirection="RightToLeft" Orientation="Horizontal" Background="green" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
</StackPanel> -->
<Border Background="{DynamicResource SystemBaseLowColor}" Padding="10 0">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Vertical" Spacing="5">
<DockPanel>
<Button Command="{Binding CloseSidePanel}" DockPanel.Dock="Left" Content="&#xf013e;" Classes="iconfont" FontSize="25"/>
<Button Command="{Binding CloseSidePanel}" DockPanel.Dock="Left" Content="&#xf101;" Classes="iconfont" FontSize="25"/>
</DockPanel>
<TextBlock Text="{Binding CurrentlyOpenedAccount.AccountName}" />
<StackPanel Orientation="Vertical" Margin="10 0">
<TextBlock Text="{Binding CurrentlyOpenedAccount.AccountName}" Foreground="{DynamicResource SystemControlBackgroundAccentBrush}" FontSize="16"/>

<TextBlock Text="Loginname" Opacity="0.6" FontSize="12" Margin="0 10 0 2" />
<StackPanel Orientation="Horizontal" Spacing="10">
<TextBlock MaxWidth="150" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding CurrentlyOpenedAccount.LoginName}" TextTrimming="CharacterEllipsis"/>
<Button Command="{Binding CopyActiveLoginName}" Classes="iconfont" Content="&#xf0c5;" FontSize="16" VerticalAlignment="Center"/>
</StackPanel>
<TextBlock Text="Password" Opacity="0.6" FontSize="12" Margin="0 10 0 2" />
<StackPanel Orientation="Horizontal" Spacing="10">
<TextBlock MaxWidth="150" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding CurrentlyOpenedAccount.HiddenPassword}"/>
<Button Command="{Binding CopyActivePassword}" Classes="iconfont" Content="&#xf0c5;" FontSize="16" VerticalAlignment="Center"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</SplitView.Pane>
Expand Down
24 changes: 24 additions & 0 deletions PWManager.Avalonia/Controls/AccountsControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;

namespace PWManager.Avalonia.Controls;

Expand All @@ -13,6 +14,8 @@ public partial class AccountsControl : CustomControl {

public AccountDisplayModel? CurrentlyOpenedAccount {get;set;}

private TopLevel _window = null!;

public AccountsControl() {
InitializeComponent();
this.DataContext = this;
Expand All @@ -26,8 +29,15 @@ public AccountsControl() {
});

OnPropertyChanged(nameof(Accounts));

this.Initialized += OnInit;
}

private void OnInit(object? sender, EventArgs e) {
Console.WriteLine("Here");
_window = TopLevel.GetTopLevel(this) ?? throw new ApplicationException("Window not found");
Console.WriteLine("Here!");
}

private void UpdateSize(object? sender, SizeChangedEventArgs e) {
// splitPane.OpenPaneLength = Max
Expand All @@ -46,4 +56,18 @@ public void CloseSidePanel() {

OnPropertyChanged(nameof(CurrentlyOpenedAccount));
}

public async Task CopyActiveLoginName() {
if(_window.Clipboard is null || CurrentlyOpenedAccount is null) {
return;
}
await _window.Clipboard.SetTextAsync(CurrentlyOpenedAccount.LoginName);
}

public async Task CopyActivePassword() {
if(_window.Clipboard is null || CurrentlyOpenedAccount is null) {
return;
}
await _window.Clipboard.SetTextAsync(CurrentlyOpenedAccount.Password);
}
}
2 changes: 2 additions & 0 deletions PWManager.Avalonia/Models/AccountDisplayModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

public class AccountDisplayModel {

public string AccountName {get;set;}

Check warning on line 7 in PWManager.Avalonia/Models/AccountDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'AccountName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public string LoginName {get;set;}

Check warning on line 9 in PWManager.Avalonia/Models/AccountDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'LoginName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public string Password {get;set;}

Check warning on line 11 in PWManager.Avalonia/Models/AccountDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Password' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public string HiddenPassword {get => new('*', Password.Length);}

}
Loading