WIP: RapidTravel, ModalService
This commit is contained in:
@@ -11,6 +11,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MvvmGen" Version="1.1.5" />
|
||||
<PackageReference Include="PropertyChanged.SourceGenerator" Version="1.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using DynamicData;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.App.Core.Models;
|
||||
|
||||
public class BindedCollection<T> : IDisposable
|
||||
public partial class BindedCollection<T> : IDisposable, INotifyPropertyChanged
|
||||
{
|
||||
private readonly IDisposable _disposable;
|
||||
public ReadOnlyObservableCollection<T> Collection { get; }
|
||||
private IDisposable? _innerDisposable;
|
||||
|
||||
[Notify] private ReadOnlyObservableCollection<T>? _collection;
|
||||
|
||||
public BindedCollection(IObservable<IChangeSet<T>> dynamicList)
|
||||
{
|
||||
_disposable = dynamicList
|
||||
@@ -14,12 +19,34 @@ public class BindedCollection<T> : IDisposable
|
||||
.DisposeMany()
|
||||
.Subscribe();
|
||||
|
||||
Collection = collection;
|
||||
_collection = collection;
|
||||
}
|
||||
|
||||
public BindedCollection(IObservable<IObservable<IChangeSet<T>>?> dynamicListSource)
|
||||
{
|
||||
_disposable = dynamicListSource.Subscribe(dynamicList =>
|
||||
{
|
||||
_innerDisposable?.Dispose();
|
||||
if (dynamicList is not null)
|
||||
{
|
||||
_innerDisposable = dynamicList
|
||||
.Bind(out var collection)
|
||||
.DisposeMany()
|
||||
.Subscribe();
|
||||
|
||||
Collection = collection;
|
||||
}
|
||||
else
|
||||
{
|
||||
Collection = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_disposable.Dispose();
|
||||
_innerDisposable?.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
|
||||
namespace FileTime.App.Core.Services;
|
||||
|
||||
public interface IModalService
|
||||
{
|
||||
IObservable<IChangeSet<IModalViewModelBase>> OpenModals { get; }
|
||||
|
||||
void OpenModal(IModalViewModelBase modalToOpen);
|
||||
void CloseModal(IModalViewModelBase modalToClose);
|
||||
}
|
||||
@@ -8,9 +8,11 @@ public interface IAppState
|
||||
ObservableCollection<ITabViewModel> Tabs { get; }
|
||||
IObservable<ITabViewModel?> SelectedTab { get; }
|
||||
IObservable<string?> SearchText { get; }
|
||||
ViewMode ViewMode { get; }
|
||||
IObservable<ViewMode> ViewMode { get; }
|
||||
string RapidTravelText { get; set; }
|
||||
|
||||
void AddTab(ITabViewModel tabViewModel);
|
||||
void RemoveTab(ITabViewModel tabViewModel);
|
||||
void SetSearchText(string? searchText);
|
||||
void SwitchViewMode(ViewMode newViewMode);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
public interface IModalViewModelBase
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user