Select previous/next item

This commit is contained in:
2022-04-12 23:57:58 +02:00
parent 465e20dbf2
commit 20f6bb6b97
10 changed files with 60 additions and 17 deletions

View File

@@ -17,5 +17,6 @@ namespace FileTime.Core.Models
bool CanRename { get; }
IContentProvider Provider { get; }
string? Attributes { get; }
AbsolutePathType Type { get; }
}
}

View File

@@ -22,5 +22,6 @@ namespace FileTime.Core.Models
{
BehaviorSubject<bool> IsLoading { get; } = new BehaviorSubject<bool>(false);
IObservable<bool> IContainer.IsLoading => IsLoading.AsObservable();
public AbsolutePathType Type => AbsolutePathType.Container;
}
}

View File

@@ -15,5 +15,8 @@ namespace FileTime.Core.Models
SupportsDelete CanDelete,
bool CanRename,
string? Attributes,
IContentProvider Provider) : IElement;
IContentProvider Provider) : IElement
{
public AbsolutePathType Type => AbsolutePathType.Element;
}
}

View File

@@ -39,6 +39,8 @@ namespace FileTime.Core.Services
IObservable<bool> IContainer.IsLoading => IsLoading.AsObservable();
public AbsolutePathType Type => AbsolutePathType.Container;
protected ContentProviderBase(string name)
{
DisplayName = Name = name;

View File

@@ -40,11 +40,7 @@ namespace FileTime.Core.Services
.Publish(null)
.RefCount();
CurrentSelectedItem.Subscribe(s =>
{
_currentSelectedItemCached = s;
_currentSelectedItem.OnNext(s);
});
CurrentSelectedItem.Subscribe(s => _currentSelectedItemCached = s);
}
private async Task<IEnumerable<IItem>> MapItems(IReadOnlyList<IAbsolutePath> items)
@@ -83,7 +79,7 @@ namespace FileTime.Core.Services
private IObservable<IAbsolutePath?> GetSelectedItemByLocation(IContainer? currentLocation)
{
//TODO:
return currentLocation?.Items?.Select(i => i.FirstOrDefault()) ?? Observable.Never((IAbsolutePath?)null);
return currentLocation?.Items?.Select(i => i.Count == 0 ? null : i[0]) ?? Observable.Return((IAbsolutePath?)null);
}
public void SetCurrentLocation(IContainer newLocation) => _currentLocation.OnNext(newLocation);