mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-05-04 05:46:29 +03:00
create viewmodels for RepositoryWindow that can be swapped when locking/unlocking
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:KeyKeeper.ViewModels"
|
||||||
x:Class="KeyKeeper.RepositoryWindow"
|
x:Class="KeyKeeper.RepositoryWindow"
|
||||||
Title="KeyKeeper - Хранилище паролей"
|
Title="KeyKeeper - Хранилище паролей"
|
||||||
Width="800"
|
Width="800"
|
||||||
Height="600"
|
Height="600"
|
||||||
Background="White">
|
Background="White"
|
||||||
|
x:DataType="vm:RepositoryWindowViewModel">
|
||||||
|
|
||||||
|
<Window.DataTemplates>
|
||||||
|
<DataTemplate DataType="{x:Type vm:UnlockedRepositoryViewModel}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- Синий левый край -->
|
<!-- Синий левый край -->
|
||||||
<Border Width="200"
|
<Border Width="200"
|
||||||
@@ -46,4 +50,11 @@
|
|||||||
Margin="0,20,0,0"/>
|
Margin="0,20,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type vm:LockedRepositoryViewModel}">
|
||||||
|
|
||||||
|
</DataTemplate>
|
||||||
|
</Window.DataTemplates>
|
||||||
|
|
||||||
|
<ContentControl Content="{Binding CurrentPage}"/>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using KeyKeeper.PasswordStore;
|
using KeyKeeper.PasswordStore;
|
||||||
using KeyKeeper.PasswordStore.Crypto;
|
using KeyKeeper.PasswordStore.Crypto;
|
||||||
|
|
||||||
|
|||||||
5
src/KeyKeeper/ViewModels/LockedRepositoryViewModel.cs
Normal file
5
src/KeyKeeper/ViewModels/LockedRepositoryViewModel.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace KeyKeeper.ViewModels;
|
||||||
|
|
||||||
|
public class LockedRepositoryViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
}
|
||||||
11
src/KeyKeeper/ViewModels/RepositoryWindowViewModel.cs
Normal file
11
src/KeyKeeper/ViewModels/RepositoryWindowViewModel.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace KeyKeeper.ViewModels;
|
||||||
|
|
||||||
|
public class RepositoryWindowViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private object currentPage = new LockedRepositoryViewModel();
|
||||||
|
public object CurrentPage
|
||||||
|
{
|
||||||
|
get => currentPage;
|
||||||
|
set { currentPage = value; OnPropertyChanged(nameof(CurrentPage)); }
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/KeyKeeper/ViewModels/UnlockedRepositoryViewModel.cs
Normal file
5
src/KeyKeeper/ViewModels/UnlockedRepositoryViewModel.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace KeyKeeper.ViewModels;
|
||||||
|
|
||||||
|
public class UnlockedRepositoryViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -84,7 +84,7 @@ namespace KeyKeeper.Views
|
|||||||
{
|
{
|
||||||
var repositoryWindow = new RepositoryWindow()
|
var repositoryWindow = new RepositoryWindow()
|
||||||
{
|
{
|
||||||
DataContext = this.DataContext,
|
DataContext = new RepositoryWindowViewModel(),
|
||||||
PassStore = store,
|
PassStore = store,
|
||||||
WindowStartupLocation = WindowStartupLocation.CenterScreen
|
WindowStartupLocation = WindowStartupLocation.CenterScreen
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user