|
@@ -1,5 +1,6 @@
|
|
using System;
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.ObjectModel;
|
|
|
|
+using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using Avalonia.Svg.Skia;
|
|
using Avalonia.Svg.Skia;
|
|
@@ -15,13 +16,32 @@ public partial class AvaloniaModuleCollection : ObservableObject
|
|
|
|
|
|
public AvaloniaModule? this[string name] => Items.FirstOrDefault(x => Equals(x.Title, name));
|
|
public AvaloniaModule? this[string name] => Items.FirstOrDefault(x => Equals(x.Title, name));
|
|
|
|
|
|
|
|
+ [ObservableProperty] private AvaloniaModule[] _visibleItems = [];
|
|
|
|
+
|
|
|
|
+ public AvaloniaModuleCollection()
|
|
|
|
+ {
|
|
|
|
+ Items.CollectionChanged += (sender, args) => UpdateVisibleItems();
|
|
|
|
+ }
|
|
|
|
+
|
|
public void Add()
|
|
public void Add()
|
|
{
|
|
{
|
|
var module = new AvaloniaModule();
|
|
var module = new AvaloniaModule();
|
|
|
|
+ module.PropertyChanged += DoPropertyChanged;
|
|
Items.Add(module);
|
|
Items.Add(module);
|
|
}
|
|
}
|
|
|
|
|
|
- public AvaloniaModule Add(string title, string description, SvgImage? image, Action action
|
|
|
|
|
|
+ private void DoPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ if (e.PropertyName == nameof(AvaloniaModule.IsVisible))
|
|
|
|
+ UpdateVisibleItems();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void UpdateVisibleItems()
|
|
|
|
+ {
|
|
|
|
+ VisibleItems = Items.Where(x=>x.IsVisible == true).ToArray();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public AvaloniaModule Add(string title, string description, SvgImage? image, Action action, bool? isVisible = null
|
|
/* Func<PrsModule, Task>? configure = null */)
|
|
/* Func<PrsModule, Task>? configure = null */)
|
|
{
|
|
{
|
|
var module = new AvaloniaModule
|
|
var module = new AvaloniaModule
|
|
@@ -29,15 +49,17 @@ public partial class AvaloniaModuleCollection : ObservableObject
|
|
Title = title,
|
|
Title = title,
|
|
Description = description,
|
|
Description = description,
|
|
Image = image,
|
|
Image = image,
|
|
- TapCommand = new RelayCommand(action)
|
|
|
|
|
|
+ TapCommand = new RelayCommand(action),
|
|
|
|
+ IsVisible = isVisible ?? true
|
|
};
|
|
};
|
|
|
|
+ module.PropertyChanged += DoPropertyChanged;
|
|
Items.Add(module);
|
|
Items.Add(module);
|
|
// _ = configure?.Invoke(module);
|
|
// _ = configure?.Invoke(module);
|
|
return module;
|
|
return module;
|
|
}
|
|
}
|
|
|
|
|
|
public AvaloniaModule Add<TViewModel>(string title, string description, SvgImage? image,
|
|
public AvaloniaModule Add<TViewModel>(string title, string description, SvgImage? image,
|
|
- /* Func<PrsModule, Task>? configure = null */ Action<TViewModel>? configure = null)
|
|
|
|
|
|
+ /* Func<PrsModule, Task>? configure = null */ Action<TViewModel>? configure = null, bool? isVisible = null)
|
|
where TViewModel : IViewModelBase
|
|
where TViewModel : IViewModelBase
|
|
{
|
|
{
|
|
var module = new AvaloniaModule
|
|
var module = new AvaloniaModule
|
|
@@ -45,20 +67,22 @@ public partial class AvaloniaModuleCollection : ObservableObject
|
|
Title = title,
|
|
Title = title,
|
|
Description = description,
|
|
Description = description,
|
|
Image = image,
|
|
Image = image,
|
|
- TapCommand = new RelayCommand(() => Navigation.Navigate<TViewModel>(configure))
|
|
|
|
|
|
+ TapCommand = new RelayCommand(() => Navigation.Navigate<TViewModel>(configure)),
|
|
|
|
+ IsVisible = isVisible ?? true
|
|
};
|
|
};
|
|
|
|
+ module.PropertyChanged += DoPropertyChanged;
|
|
Items.Add(module);
|
|
Items.Add(module);
|
|
// _ = configure?.Invoke(module);
|
|
// _ = configure?.Invoke(module);
|
|
return module;
|
|
return module;
|
|
}
|
|
}
|
|
|
|
|
|
public AvaloniaModule? Add<TToken, TViewModel>(string title, string description, SvgImage? image,
|
|
public AvaloniaModule? Add<TToken, TViewModel>(string title, string description, SvgImage? image,
|
|
- /* Func<PrsModule, Task>? configure = null */ Action<TViewModel>? configure = null)
|
|
|
|
|
|
+ /* Func<PrsModule, Task>? configure = null */ Action<TViewModel>? configure = null, bool? isVisible = null)
|
|
where TToken : ISecurityDescriptor, new()
|
|
where TToken : ISecurityDescriptor, new()
|
|
where TViewModel : IViewModelBase
|
|
where TViewModel : IViewModelBase
|
|
{
|
|
{
|
|
if (Security.IsAllowed<TToken>())
|
|
if (Security.IsAllowed<TToken>())
|
|
- return Add<TViewModel>(title, description, image, configure);
|
|
|
|
|
|
+ return Add<TViewModel>(title, description, image, configure, isVisible);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|