using Avalonia.Layout; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace InABox.Avalonia.Components; public partial class OptionSelectorViewModel : BasePopupViewModel, IAlignedPopup { [ObservableProperty] private string _title = "Select Option"; [ObservableProperty] private ObservableCollection _options = new(); public HorizontalAlignment HorizontalAlignment => HorizontalAlignment.Stretch; public VerticalAlignment VerticalAlignment => VerticalAlignment.Center; [RelayCommand] private void Cancel() { Close(null); } [RelayCommand] private void Select(string option) { Close(option); } } public static class OptionSelector { public static async Task Execute(string title, params string[] options) { return await Navigation.Popup(model => { model.Title = title; model.Options = new(options); }); } }