RapidTravel display name
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using DeclarativeProperty;
|
||||||
using FileTime.App.Core.Models.Enums;
|
using FileTime.App.Core.Models.Enums;
|
||||||
using FileTime.App.Core.ViewModels.Timeline;
|
using FileTime.App.Core.ViewModels.Timeline;
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ public interface IAppState
|
|||||||
IObservable<ITabViewModel?> SelectedTab { get; }
|
IObservable<ITabViewModel?> SelectedTab { get; }
|
||||||
IObservable<string?> SearchText { get; }
|
IObservable<string?> SearchText { get; }
|
||||||
IObservable<ViewMode> ViewMode { get; }
|
IObservable<ViewMode> ViewMode { get; }
|
||||||
string RapidTravelText { get; set; }
|
DeclarativeProperty<string?> RapidTravelText { get; }
|
||||||
ITabViewModel? CurrentSelectedTab { get; }
|
ITabViewModel? CurrentSelectedTab { get; }
|
||||||
ITimelineViewModel TimelineViewModel { get; }
|
ITimelineViewModel TimelineViewModel { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace FileTime.App.Core.ViewModels;
|
|||||||
public interface IItemViewModel : IInitable<IItem, ITabViewModel, ItemViewModelType>
|
public interface IItemViewModel : IInitable<IItem, ITabViewModel, ItemViewModelType>
|
||||||
{
|
{
|
||||||
IItem? BaseItem { get; set; }
|
IItem? BaseItem { get; set; }
|
||||||
IObservable<IReadOnlyList<ItemNamePart>>? DisplayName { get; set; }
|
IDeclarativeProperty<IReadOnlyList<ItemNamePart>>? DisplayName { get; }
|
||||||
string? DisplayNameText { get; set; }
|
string? DisplayNameText { get; set; }
|
||||||
IDeclarativeProperty<bool> IsSelected { get; set; }
|
IDeclarativeProperty<bool> IsSelected { get; set; }
|
||||||
IObservable<bool>? IsMarked { get; set; }
|
IObservable<bool>? IsMarked { get; set; }
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
|||||||
if (_currentSelectedItem?.Value is not IContainerViewModel containerViewModel || containerViewModel.Container is null)
|
if (_currentSelectedItem?.Value is not IContainerViewModel containerViewModel || containerViewModel.Container is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_appState.RapidTravelText = "";
|
await _appState.RapidTravelText.SetValue("");
|
||||||
if (_selectedTab?.Tab is { } tab)
|
if (_selectedTab?.Tab is { } tab)
|
||||||
{
|
{
|
||||||
await tab.SetCurrentLocation(containerViewModel.Container);
|
await tab.SetCurrentLocation(containerViewModel.Container);
|
||||||
@@ -240,7 +240,7 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_appState.RapidTravelText = "";
|
await _appState.RapidTravelText.SetValue("");
|
||||||
if (_selectedTab?.Tab is { } tab)
|
if (_selectedTab?.Tab is { } tab)
|
||||||
{
|
{
|
||||||
await tab.SetCurrentLocation(newContainer);
|
await tab.SetCurrentLocation(newContainer);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Reactive.Subjects;
|
using System.Reactive.Subjects;
|
||||||
|
using DeclarativeProperty;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using FileTime.App.Core.Models.Enums;
|
using FileTime.App.Core.Models.Enums;
|
||||||
using FileTime.App.Core.ViewModels.Timeline;
|
using FileTime.App.Core.ViewModels.Timeline;
|
||||||
@@ -25,11 +26,11 @@ public abstract partial class AppStateBase : IAppState
|
|||||||
|
|
||||||
public IObservable<ITabViewModel?> SelectedTab { get; private set; }
|
public IObservable<ITabViewModel?> SelectedTab { get; private set; }
|
||||||
public ITabViewModel? CurrentSelectedTab { get; private set; }
|
public ITabViewModel? CurrentSelectedTab { get; private set; }
|
||||||
|
public DeclarativeProperty<string?> RapidTravelText { get; private set; }
|
||||||
[Property] private string _rapidTravelText = "";
|
|
||||||
|
|
||||||
partial void OnInitialize()
|
partial void OnInitialize()
|
||||||
{
|
{
|
||||||
|
RapidTravelText = new("");
|
||||||
ViewMode = _viewMode.AsObservable();
|
ViewMode = _viewMode.AsObservable();
|
||||||
|
|
||||||
var tabsObservable = _tabs.Connect();
|
var tabsObservable = _tabs.Connect();
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
|
|
||||||
[Property] private IItem? _baseItem;
|
[Property] private IItem? _baseItem;
|
||||||
|
|
||||||
[Property] private IObservable<IReadOnlyList<ItemNamePart>>? _displayName;
|
|
||||||
|
|
||||||
[Property] private string? _displayNameText;
|
[Property] private string? _displayNameText;
|
||||||
|
|
||||||
[Property] private IDeclarativeProperty<bool> _isSelected;
|
[Property] private IDeclarativeProperty<bool> _isSelected;
|
||||||
@@ -37,6 +35,8 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
|
|
||||||
[Property] private IDeclarativeProperty<bool> _isAlternative;
|
[Property] private IDeclarativeProperty<bool> _isAlternative;
|
||||||
|
|
||||||
|
public IDeclarativeProperty<IReadOnlyList<ItemNamePart>>? DisplayName { get; private set; }
|
||||||
|
|
||||||
public void Init(IItem item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
public void Init(IItem item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||||
{
|
{
|
||||||
_parentTab = parentTab;
|
_parentTab = parentTab;
|
||||||
@@ -49,8 +49,14 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
_ => throw new InvalidEnumArgumentException()
|
_ => throw new InvalidEnumArgumentException()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var displayName = itemViewModelType switch
|
||||||
|
{
|
||||||
|
ItemViewModelType.Main => _appState.RapidTravelText.Map(s => (IReadOnlyList<ItemNamePart>) _itemNameConverterService.GetDisplayName(item.DisplayName, s)),
|
||||||
|
_ => new DeclarativeProperty<IReadOnlyList<ItemNamePart>>(new List<ItemNamePart> {new (item.DisplayName)}),
|
||||||
|
};
|
||||||
|
|
||||||
BaseItem = item;
|
BaseItem = item;
|
||||||
DisplayName = _appState.SearchText.Select(s => _itemNameConverterService.GetDisplayName(item.DisplayName, s));
|
DisplayName = displayName;
|
||||||
DisplayNameText = item.DisplayName;
|
DisplayNameText = item.DisplayName;
|
||||||
|
|
||||||
IsMarked = itemViewModelType is ItemViewModelType.Main
|
IsMarked = itemViewModelType is ItemViewModelType.Main
|
||||||
@@ -79,6 +85,7 @@ public abstract partial class ItemViewModel : IItemViewModel
|
|||||||
_ => ItemViewMode.Default
|
_ => ItemViewMode.Default
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public bool EqualsTo(IItemViewModel? itemViewModel)
|
public bool EqualsTo(IItemViewModel? itemViewModel)
|
||||||
{
|
{
|
||||||
return BaseItem?.FullName?.Path is string path && path == itemViewModel?.BaseItem?.FullName?.Path;
|
return BaseItem?.FullName?.Path is string path && path == itemViewModel?.BaseItem?.FullName?.Path;
|
||||||
|
|||||||
@@ -88,19 +88,6 @@ public partial class TabViewModel : ITabViewModel
|
|||||||
(items, ordering) =>
|
(items, ordering) =>
|
||||||
{
|
{
|
||||||
if (items is null) return Task.FromResult<ObservableCollection<IItemViewModel>?>(null);
|
if (items is null) return Task.FromResult<ObservableCollection<IItemViewModel>?>(null);
|
||||||
/*Expression<Func<IItemViewModel, object?>> orderExpression = ordering switch
|
|
||||||
{
|
|
||||||
ItemOrdering.Name or ItemOrdering.NameDesc => i => i.DisplayNameText,
|
|
||||||
ItemOrdering.LastModifyDate or ItemOrdering.LastModifyDateDesc => i => i.CreatedAt,
|
|
||||||
_ => throw new NotImplementedException()
|
|
||||||
};
|
|
||||||
Expression<Func<ListSortDirection>> direction = ordering switch
|
|
||||||
{
|
|
||||||
ItemOrdering.Name or ItemOrdering.LastModifyDate => () => ListSortDirection.Ascending,
|
|
||||||
ItemOrdering.NameDesc or ItemOrdering.LastModifyDateDesc => () => ListSortDirection.Descending,
|
|
||||||
_ => throw new NotImplementedException()
|
|
||||||
};
|
|
||||||
return Task.FromResult((ObservableCollection<IItemViewModel>?) items.Ordering(orderExpression, direction));*/
|
|
||||||
|
|
||||||
ObservableCollection<IItemViewModel>? orderedItems = ordering switch
|
ObservableCollection<IItemViewModel>? orderedItems = ordering switch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,17 +64,21 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
|
|||||||
}
|
}
|
||||||
else if (key == Key.Back)
|
else if (key == Key.Back)
|
||||||
{
|
{
|
||||||
if (_appState.RapidTravelText.Length > 0)
|
if (_appState.RapidTravelText.Value!.Length > 0)
|
||||||
{
|
{
|
||||||
setHandled(true);
|
setHandled(true);
|
||||||
_appState.RapidTravelText = _appState.RapidTravelText.Substring(0, _appState.RapidTravelText.Length - 1);
|
await _appState.RapidTravelText.SetValue(
|
||||||
|
_appState.RapidTravelText.Value![..^1]
|
||||||
|
);
|
||||||
updateRapidTravelFilter = true;
|
updateRapidTravelFilter = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (keyString.Length == 1)
|
else if (keyString.Length == 1)
|
||||||
{
|
{
|
||||||
setHandled(true);
|
setHandled(true);
|
||||||
_appState.RapidTravelText += keyString.ToLower();
|
await _appState.RapidTravelText.SetValue(
|
||||||
|
_appState.RapidTravelText.Value + keyString.ToLower()
|
||||||
|
);
|
||||||
updateRapidTravelFilter = true;
|
updateRapidTravelFilter = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -93,7 +97,7 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
|
|||||||
if (_selectedTab?.Tab is not ITab tab) return;
|
if (_selectedTab?.Tab is not ITab tab) return;
|
||||||
|
|
||||||
tab.RemoveItemFilter(RapidTravelFilterName);
|
tab.RemoveItemFilter(RapidTravelFilterName);
|
||||||
tab.AddItemFilter(new ItemFilter(RapidTravelFilterName, i => i.Name.ToLower().Contains(_appState.RapidTravelText)));
|
tab.AddItemFilter(new ItemFilter(RapidTravelFilterName, i => i.Name.ToLower().Contains(_appState.RapidTravelText.Value!)));
|
||||||
/*var currentLocation = await _appState.SelectedTab.CurrentLocation.Container.WithoutVirtualContainer(MainPageViewModel.RAPIDTRAVEL);
|
/*var currentLocation = await _appState.SelectedTab.CurrentLocation.Container.WithoutVirtualContainer(MainPageViewModel.RAPIDTRAVEL);
|
||||||
var newLocation = new VirtualContainer(
|
var newLocation = new VirtualContainer(
|
||||||
currentLocation,
|
currentLocation,
|
||||||
|
|||||||
@@ -642,7 +642,7 @@
|
|||||||
|
|
||||||
<TextBlock Text="Filter " />
|
<TextBlock Text="Filter " />
|
||||||
|
|
||||||
<TextBlock Text="{Binding AppState.RapidTravelText}" />
|
<TextBlock Text="{Binding AppState.RapidTravelText.Value}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user