using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using HC_APTBS.Services; namespace HC_APTBS.ViewModels { /// /// A single row in the Tests-page preconditions checklist. /// Labels and remediation hints are localised strings resolved by the parent /// and refreshed whenever /// fires. The item itself only /// carries the currently-resolved text plus a navigation hook so the view can offer /// a "fix-it" link when the check fails. /// public sealed partial class PreconditionItemViewModel : ObservableObject { /// Stable identifier used by the parent VM to look items up when refreshing. public string Id { get; } /// Localised human-readable check label (e.g. "Oil pump ON"). [ObservableProperty] private string _label = string.Empty; /// True when the associated runtime check currently passes. [ObservableProperty] private bool _isSatisfied; /// When false, this check is advisory only and does not block Start. [ObservableProperty] private bool _isRequired = true; /// Localised fix-it hint shown when the check fails (e.g. "Go to Bench → start oil pump"). [ObservableProperty] private string _remediationText = string.Empty; /// When non-null, the remediation button navigates to this page. public AppPage? RemediationTargetPage { get; } /// True when the remediation action should be offered (failing + has a target page). public bool HasRemediation => !IsSatisfied && RemediationTargetPage.HasValue; private readonly MainViewModel _root; /// Stable identifier (used by the parent VM to patch state). /// Root view-model used to drive page navigation. /// Destination page when the fix-it link is clicked, or null when no page applies. /// When false this item is advisory only. public PreconditionItemViewModel( string id, MainViewModel root, AppPage? remediationTargetPage = null, bool isRequired = true) { Id = id; _root = root; RemediationTargetPage = remediationTargetPage; _isRequired = isRequired; } /// Navigates the shell to the remediation target page. [RelayCommand] private void NavigateToFix() { if (RemediationTargetPage.HasValue) _root.SelectedPage = RemediationTargetPage.Value; } partial void OnIsSatisfiedChanged(bool value) => OnPropertyChanged(nameof(HasRemediation)); } }