53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.Windows.Input;
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
using Estara.Contracts.Services;
|
|
using Estara.Contracts.ViewModels;
|
|
using Estara.Core.Contracts.Services;
|
|
using Estara.Core.Models;
|
|
|
|
namespace Estara.ViewModels;
|
|
|
|
public partial class ContentGridViewModel : ObservableRecipient, INavigationAware
|
|
{
|
|
private readonly INavigationService _navigationService;
|
|
private readonly ISampleDataService _sampleDataService;
|
|
|
|
public ObservableCollection<SampleOrder> Source { get; } = new ObservableCollection<SampleOrder>();
|
|
|
|
public ContentGridViewModel(INavigationService navigationService, ISampleDataService sampleDataService)
|
|
{
|
|
_navigationService = navigationService;
|
|
_sampleDataService = sampleDataService;
|
|
}
|
|
|
|
public async void OnNavigatedTo(object parameter)
|
|
{
|
|
Source.Clear();
|
|
|
|
// TODO: Replace with real data.
|
|
var data = await _sampleDataService.GetContentGridDataAsync();
|
|
foreach (var item in data)
|
|
{
|
|
Source.Add(item);
|
|
}
|
|
}
|
|
|
|
public void OnNavigatedFrom()
|
|
{
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void OnItemClick(SampleOrder? clickedItem)
|
|
{
|
|
if (clickedItem != null)
|
|
{
|
|
_navigationService.SetListDataItemForNextConnectedAnimation(clickedItem);
|
|
_navigationService.NavigateTo(typeof(ContentGridDetailViewModel).FullName!, clickedItem.OrderID);
|
|
}
|
|
}
|
|
}
|