| 1 | using Avalonia.Controls; |
| 2 | using CascadeIDE.Cockpit.Composition.EnvironmentReadiness; |
| 3 | |
| 4 | namespace CascadeIDE.Views; |
| 5 | |
| 6 | /// <summary> |
| 7 | /// Готовность окружения: ADR 0063/0068 — одна коллекция payload; проекция «компактный список карточек» vs «тот же список, крупнее» |
| 8 | /// (<see cref="EnvironmentReadinessPresentationResolver"/>). |
| 9 | /// </summary> |
| 10 | public partial class EnvironmentReadinessMfdPageView : UserControl |
| 11 | { |
| 12 | /// <summary>Минимальная ширина контрола для режима «таблица» (px); синхрон с <see cref="EnvironmentReadinessPresentationResolver.DefaultWideLayoutMinWidthPx"/>.</summary> |
| 13 | public const double WideLayoutMinWidth = EnvironmentReadinessPresentationResolver.DefaultWideLayoutMinWidthPx; |
| 14 | |
| 15 | public EnvironmentReadinessMfdPageView() |
| 16 | { |
| 17 | InitializeComponent(); |
| 18 | SizeChanged += OnSizeChanged; |
| 19 | AttachedToVisualTree += OnAttachedToVisualTree; |
| 20 | } |
| 21 | |
| 22 | private void OnAttachedToVisualTree(object? sender, Avalonia.VisualTreeAttachmentEventArgs e) |
| 23 | { |
| 24 | ApplyLayoutForWidth(Bounds.Width); |
| 25 | } |
| 26 | |
| 27 | private void OnSizeChanged(object? sender, SizeChangedEventArgs e) |
| 28 | { |
| 29 | ApplyLayoutForWidth(e.NewSize.Width); |
| 30 | } |
| 31 | |
| 32 | private void ApplyLayoutForWidth(double width) |
| 33 | { |
| 34 | if (WideLayoutRoot is null || CompactLayoutRoot is null) |
| 35 | return; |
| 36 | |
| 37 | // Пока нет измерения — оставляем компакт (типично узкий MFD). |
| 38 | if (width <= 0) |
| 39 | return; |
| 40 | |
| 41 | var kind = EnvironmentReadinessPresentationResolver.Resolve(width); |
| 42 | WideLayoutRoot.IsVisible = kind == EnvironmentReadinessPresentationKind.WideTable; |
| 43 | CompactLayoutRoot.IsVisible = kind == EnvironmentReadinessPresentationKind.CompactCards; |
| 44 | } |
| 45 | } |
| 46 | |