Core Infrastructure: - Add Dispatching folder with LinuxDispatcher, LinuxDispatcherProvider, LinuxDispatcherTimer - Add Native folder with P/Invoke wrappers (GTK, GLib, GDK, Cairo, WebKit) - Add GTK host window system with GtkHostWindow and GtkSkiaSurfaceWidget - Update LinuxApplication with GTK mode, theme handling, and icon support - Fix duplicate LinuxDispatcher in LinuxMauiContext Handlers: - Add GtkWebViewManager and GtkWebViewPlatformView for GTK WebView - Add FlexLayoutHandler and GestureManager - Update multiple handlers with ToViewHandler fix and missing mappers - Add MauiHandlerExtensions with ToViewHandler extension method Views: - Add SkiaContextMenu with hover, keyboard, and dark theme support - Add LinuxDialogService with context menu management - Add SkiaFlexLayout for flex container support - Update SkiaShell with RefreshTheme, MauiShell, ContentRenderer - Update SkiaWebView with SetMainWindow, ProcessGtkEvents - Update SkiaImage with LoadFromBitmap method Services: - Add AppInfoService, ConnectivityService, DeviceDisplayService, DeviceInfoService - Add GtkHostService, GtkContextMenuService, MauiIconGenerator Window: - Add CursorType enum and GtkHostWindow - Update X11Window with SetIcon, SetCursor methods Build: SUCCESS (0 errors) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
102 lines
2.7 KiB
C#
102 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using SkiaSharp;
|
|
|
|
namespace Microsoft.Maui.Platform;
|
|
|
|
public static class LinuxDialogService
|
|
{
|
|
private static readonly List<SkiaAlertDialog> _activeDialogs = new List<SkiaAlertDialog>();
|
|
|
|
private static Action? _invalidateCallback;
|
|
|
|
private static SkiaContextMenu? _activeContextMenu;
|
|
|
|
private static Action? _showPopupCallback;
|
|
|
|
private static Action? _hidePopupCallback;
|
|
|
|
public static bool HasActiveDialog => _activeDialogs.Count > 0;
|
|
|
|
public static SkiaAlertDialog? TopDialog
|
|
{
|
|
get
|
|
{
|
|
if (_activeDialogs.Count <= 0)
|
|
{
|
|
return null;
|
|
}
|
|
return _activeDialogs[_activeDialogs.Count - 1];
|
|
}
|
|
}
|
|
|
|
public static SkiaContextMenu? ActiveContextMenu => _activeContextMenu;
|
|
|
|
public static bool HasContextMenu => _activeContextMenu != null;
|
|
|
|
public static void SetInvalidateCallback(Action callback)
|
|
{
|
|
_invalidateCallback = callback;
|
|
}
|
|
|
|
public static Task<bool> ShowAlertAsync(string title, string message, string? accept, string? cancel)
|
|
{
|
|
var dialog = new SkiaAlertDialog(title, message, accept, cancel);
|
|
_activeDialogs.Add(dialog);
|
|
_invalidateCallback?.Invoke();
|
|
return dialog.Result;
|
|
}
|
|
|
|
internal static void HideDialog(SkiaAlertDialog dialog)
|
|
{
|
|
_activeDialogs.Remove(dialog);
|
|
_invalidateCallback?.Invoke();
|
|
}
|
|
|
|
public static void DrawDialogs(SKCanvas canvas, SKRect bounds)
|
|
{
|
|
DrawDialogsOnly(canvas, bounds);
|
|
DrawContextMenuOnly(canvas, bounds);
|
|
}
|
|
|
|
public static void DrawDialogsOnly(SKCanvas canvas, SKRect bounds)
|
|
{
|
|
foreach (var dialog in _activeDialogs)
|
|
{
|
|
dialog.Measure(new SKSize(bounds.Width, bounds.Height));
|
|
dialog.Arrange(bounds);
|
|
dialog.Draw(canvas);
|
|
}
|
|
}
|
|
|
|
public static void DrawContextMenuOnly(SKCanvas canvas, SKRect bounds)
|
|
{
|
|
if (_activeContextMenu != null)
|
|
{
|
|
_activeContextMenu.Draw(canvas);
|
|
}
|
|
}
|
|
|
|
public static void SetPopupCallbacks(Action showPopup, Action hidePopup)
|
|
{
|
|
_showPopupCallback = showPopup;
|
|
_hidePopupCallback = hidePopup;
|
|
}
|
|
|
|
public static void ShowContextMenu(SkiaContextMenu menu)
|
|
{
|
|
Console.WriteLine("[LinuxDialogService] ShowContextMenu called");
|
|
_activeContextMenu = menu;
|
|
_showPopupCallback?.Invoke();
|
|
_invalidateCallback?.Invoke();
|
|
}
|
|
|
|
public static void HideContextMenu()
|
|
{
|
|
_activeContextMenu = null;
|
|
_hidePopupCallback?.Invoke();
|
|
_invalidateCallback?.Invoke();
|
|
}
|
|
}
|