feat: Implement Playlists and Programs Management
- Added PlaylistsGroupViewModel to manage playlists and selection. - Introduced ProgramsGroupViewModel for handling program groups and subscriptions. - Created ProgramsListViewModel to manage individual program listings. - Developed SettingsViewModel for user settings including playlist management. - Implemented TVPlayerViewModel as the main view model coordinating screens and data. - Added PlayerView for video playback with LibVLC integration. - Created XAML views for PlaylistsGroup, ProgramsGroup, ProgramsList, and Settings. - Added sample M3U playlist for testing. - Documented WPF build instructions and project structure in WPF-BUILD.md. - Configured global.json for .NET SDK versioning.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Windows.Input;
|
||||
using TV_Player.ViewModels;
|
||||
|
||||
namespace TV_Player.AvaloniaApp.ViewModels;
|
||||
|
||||
public class ProgramsGroupViewModel : TV_Player.ObservableViewModelBase, IDisposable
|
||||
{
|
||||
private List<GroupInfo> _programs = new();
|
||||
private readonly IDisposable _groupInformationSubscriber;
|
||||
|
||||
public List<GroupInfo> Programs
|
||||
{
|
||||
get => _programs;
|
||||
set => SetProperty(ref _programs, value);
|
||||
}
|
||||
|
||||
public ICommand SelectGroupCommand { get; }
|
||||
|
||||
public ProgramsGroupViewModel()
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[ProgramsGroupViewModel] Initializing...");
|
||||
SelectGroupCommand = new RelayCommand<GroupInfo>(OnItemSelected);
|
||||
if (TVPlayerViewModel.Instance.CurrentProgramsData == null)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("[ProgramsGroupViewModel] ERROR: CurrentProgramsData is null!");
|
||||
Programs = new List<GroupInfo>();
|
||||
return;
|
||||
}
|
||||
|
||||
_groupInformationSubscriber = TVPlayerViewModel.Instance.CurrentProgramsData
|
||||
.GroupsInformation
|
||||
.Subscribe(groups =>
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"[ProgramsGroupViewModel.Subscribe] Received {groups.Count} groups from observable");
|
||||
// Filter hidden groups but keep all others (including "undefined")
|
||||
var filteredGroups = SettingsModel.HiddenGroups == null
|
||||
? groups
|
||||
: groups.Where(g => !SettingsModel.HiddenGroups.Contains(g.Name.ToLowerInvariant())).ToList();
|
||||
|
||||
System.Diagnostics.Debug.WriteLine($"[ProgramsGroupViewModel] Groups after filter: {string.Join(", ", filteredGroups.Select(g => $"{g.Name}({g.Count})"))}");
|
||||
Programs = filteredGroups;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnItemSelected(GroupInfo? group)
|
||||
{
|
||||
if (group == null)
|
||||
return;
|
||||
|
||||
TVPlayerViewModel.Instance.ShowProgramsListScreen(group);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_groupInformationSubscriber.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user