using Avalonia; using Avalonia.Controls; using Avalonia.Layout; using Avalonia.Media; using Avalonia.Threading; using Avalonia.Styling; using Avalonia.VisualTree; using FinalToken.Core; namespace FinalToken.App; public sealed class PopupWindow : Window { public PopupWindow(string title, string message, Action open, string? installLabel = null, Action? install = null, Action? dismiss = null, IBrush? accent = null) { Width = 380; Height = install is null ? 145 : 180; RequestedThemeVariant = ThemeVariant.Dark; WindowDecorations = WindowDecorations.None; CanResize = false; Topmost = true; ShowInTaskbar = false; ShowActivated = false; var body = Ui.Stack(Ui.Text(title, 19), Ui.Text(message)); if (install is not null) { var actions = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 12 }; actions.Children.Add(Ui.Button(installLabel ?? "Install", () => { install(); Close(); })); actions.Children.Add(Ui.Button("Not now", () => { dismiss?.Invoke(); Close(); })); body.Children.Add(actions); } var card = Ui.Card(body); card.Background = Brush.Parse("#202C40"); body.Resources["TextControlForeground"] = Brushes.WhiteSmoke; foreach (var text in body.Children.OfType()) text.Foreground = Brushes.WhiteSmoke; ((TextBlock)body.Children[0]).Foreground = accent ?? Brushes.WhiteSmoke; Content = card; PointerPressed += (_, e) => { var source = e.Source as Control; if (source is not Button && source?.FindAncestorOfType