2025-12-19 09:30:16 +00:00
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
|
|
|
|
|
using Microsoft.Maui.Handlers;
|
|
|
|
|
using Microsoft.Maui.Graphics;
|
|
|
|
|
using Microsoft.Maui.Controls;
|
|
|
|
|
using Microsoft.Maui.Platform;
|
|
|
|
|
using SkiaSharp;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handler for DatePicker on Linux using Skia rendering.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class DatePickerHandler : ViewHandler<IDatePicker, SkiaDatePicker>
|
|
|
|
|
{
|
|
|
|
|
public static IPropertyMapper<IDatePicker, DatePickerHandler> Mapper =
|
|
|
|
|
new PropertyMapper<IDatePicker, DatePickerHandler>(ViewHandler.ViewMapper)
|
|
|
|
|
{
|
|
|
|
|
[nameof(IDatePicker.Date)] = MapDate,
|
|
|
|
|
[nameof(IDatePicker.MinimumDate)] = MapMinimumDate,
|
|
|
|
|
[nameof(IDatePicker.MaximumDate)] = MapMaximumDate,
|
|
|
|
|
[nameof(IDatePicker.Format)] = MapFormat,
|
|
|
|
|
[nameof(IDatePicker.TextColor)] = MapTextColor,
|
|
|
|
|
[nameof(IDatePicker.CharacterSpacing)] = MapCharacterSpacing,
|
|
|
|
|
[nameof(IView.Background)] = MapBackground,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static CommandMapper<IDatePicker, DatePickerHandler> CommandMapper =
|
|
|
|
|
new(ViewHandler.ViewCommandMapper)
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public DatePickerHandler() : base(Mapper, CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DatePickerHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
|
|
|
|
|
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override SkiaDatePicker CreatePlatformView()
|
|
|
|
|
{
|
|
|
|
|
return new SkiaDatePicker();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ConnectHandler(SkiaDatePicker platformView)
|
|
|
|
|
{
|
|
|
|
|
base.ConnectHandler(platformView);
|
|
|
|
|
platformView.DateSelected += OnDateSelected;
|
Major production merge: GTK support, context menus, and dispatcher fixes
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>
2026-01-01 11:19:58 -05:00
|
|
|
|
|
|
|
|
// Apply dark theme colors if dark mode is active
|
|
|
|
|
var current = Application.Current;
|
|
|
|
|
if (current != null && (int)current.UserAppTheme == 2) // Dark theme
|
|
|
|
|
{
|
2026-01-16 05:14:04 +00:00
|
|
|
platformView.CalendarBackgroundColor = Color.FromRgb(30, 30, 30);
|
|
|
|
|
platformView.TextColor = Color.FromRgb(224, 224, 224);
|
|
|
|
|
platformView.BorderColor = Color.FromRgb(97, 97, 97);
|
|
|
|
|
platformView.DisabledDayColor = Color.FromRgb(97, 97, 97);
|
|
|
|
|
platformView.BackgroundColor = Color.FromRgb(45, 45, 45).ToSKColor();
|
Major production merge: GTK support, context menus, and dispatcher fixes
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>
2026-01-01 11:19:58 -05:00
|
|
|
}
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void DisconnectHandler(SkiaDatePicker platformView)
|
|
|
|
|
{
|
|
|
|
|
platformView.DateSelected -= OnDateSelected;
|
|
|
|
|
base.DisconnectHandler(platformView);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 05:14:04 +00:00
|
|
|
private void OnDateSelected(object? sender, DateChangedEventArgs e)
|
2025-12-19 09:30:16 +00:00
|
|
|
{
|
|
|
|
|
if (VirtualView is null || PlatformView is null) return;
|
|
|
|
|
|
2026-01-16 05:14:04 +00:00
|
|
|
VirtualView.Date = e.NewDate;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapDate(DatePickerHandler handler, IDatePicker datePicker)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.Date = datePicker.Date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapMinimumDate(DatePickerHandler handler, IDatePicker datePicker)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.MinimumDate = datePicker.MinimumDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapMaximumDate(DatePickerHandler handler, IDatePicker datePicker)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.MaximumDate = datePicker.MaximumDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapFormat(DatePickerHandler handler, IDatePicker datePicker)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.Format = datePicker.Format ?? "d";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapTextColor(DatePickerHandler handler, IDatePicker datePicker)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
if (datePicker.TextColor is not null)
|
|
|
|
|
{
|
2026-01-16 05:14:04 +00:00
|
|
|
handler.PlatformView.TextColor = datePicker.TextColor;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapCharacterSpacing(DatePickerHandler handler, IDatePicker datePicker)
|
|
|
|
|
{
|
|
|
|
|
// Character spacing would require custom text rendering
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapBackground(DatePickerHandler handler, IDatePicker datePicker)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (datePicker.Background is SolidPaint solidPaint && solidPaint.Color is not null)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|