WIP: RapidTravel, ModalService

This commit is contained in:
2022-05-10 21:36:39 +02:00
parent 5b9d0667cc
commit 0ac9209676
19 changed files with 247 additions and 88 deletions

View File

@@ -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>

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -0,0 +1,6 @@
namespace FileTime.App.Core.ViewModels;
public interface IModalViewModelBase
{
string Name { get; }
}