New Breadcrumb user control

New Breadcrumb service
WIP icons and back button behavior
This commit is contained in:
Geoffroy BONNEVILLE
2020-06-09 20:18:17 +02:00
parent d6b17fe696
commit c62ed584dc
17 changed files with 308 additions and 45 deletions

View File

@@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Linq;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Views;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Common.Models;
using ModernKeePass.Common;
using ModernKeePass.Models;
namespace ModernKeePass.ViewModels
{
public class BreadcrumbControlVm
{
public IEnumerable<BreadcrumbItem> BreadcrumbItems { get; }
public string ParentGroupName => BreadcrumbItems.Last()?.Name;
public RelayCommand GoBackCommand { get; }
public RelayCommand<int> GoToCommand { get; }
private readonly INavigationService _navigation;
private readonly IBreadcrumbService _breadcrumb;
public BreadcrumbControlVm(INavigationService navigation, IBreadcrumbService breadcrumb)
{
_navigation = navigation;
_breadcrumb = breadcrumb;
BreadcrumbItems = _breadcrumb.GetItems().Reverse();
GoBackCommand = new RelayCommand(GoBack);
GoToCommand = new RelayCommand<int>(GoTo);
}
private void GoTo(int index)
{
var breadcrumb = _breadcrumb.Pop(BreadcrumbItems.Count() - index);
_navigation.NavigateTo(Constants.Navigation.GroupPage, new NavigationItem { Id = breadcrumb.Path });
}
private void GoBack()
{
_breadcrumb.Pop();
_navigation.GoBack();
}
}
}