Missing backgroundcolor

This commit is contained in:
2026-01-17 03:10:29 +00:00
parent 5443c7c22a
commit aad915ad86
63 changed files with 177 additions and 143 deletions

View File

@@ -56,7 +56,7 @@ public class ActivityIndicatorHandler : ViewHandler<IActivityIndicator, SkiaActi
{ {
if (activityIndicator.Background is SolidPaint solidPaint && solidPaint.Color != null) if (activityIndicator.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -72,7 +72,7 @@ public partial class ActivityIndicatorHandler : ViewHandler<IActivityIndicator,
if (activityIndicator.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (activityIndicator.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }

View File

@@ -122,7 +122,7 @@ public partial class BorderHandler : ViewHandler<IBorderView, SkiaBorder>
if (border.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (border.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
@@ -132,7 +132,7 @@ public partial class BorderHandler : ViewHandler<IBorderView, SkiaBorder>
if (border is VisualElement ve && ve.BackgroundColor != null) if (border is VisualElement ve && ve.BackgroundColor != null)
{ {
handler.PlatformView.BackgroundColor = ve.BackgroundColor.ToSKColor(); handler.PlatformView.BackgroundColor = ve.BackgroundColor;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }

View File

@@ -47,7 +47,7 @@ public partial class BoxViewHandler : ViewHandler<BoxView, SkiaBoxView>
{ {
if (boxView.Background is SolidColorBrush solidBrush && solidBrush.Color != null) if (boxView.Background is SolidColorBrush solidBrush && solidBrush.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }
@@ -56,7 +56,7 @@ public partial class BoxViewHandler : ViewHandler<BoxView, SkiaBoxView>
{ {
if (boxView.BackgroundColor != null) if (boxView.BackgroundColor != null)
{ {
handler.PlatformView.BackgroundColor = boxView.BackgroundColor.ToSKColor(); handler.PlatformView.BackgroundColor = boxView.BackgroundColor;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }

View File

@@ -102,12 +102,8 @@ public partial class ButtonHandler : ViewHandler<IButton, SkiaButton>
if (button.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (button.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
// Set BackgroundColor (used for rendering) // Set BackgroundColor (MAUI Color type)
handler.PlatformView.BackgroundColor = new SKColor( handler.PlatformView.BackgroundColor = solidPaint.Color;
(byte)(solidPaint.Color.Red * 255),
(byte)(solidPaint.Color.Green * 255),
(byte)(solidPaint.Color.Blue * 255),
(byte)(solidPaint.Color.Alpha * 255));
} }
} }

View File

@@ -239,7 +239,7 @@ public partial class CarouselViewHandler : ViewHandler<CarouselView, SkiaCarouse
if (carouselView.Background is SolidColorBrush solidBrush) if (carouselView.Background is SolidColorBrush solidBrush)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
} }
} }

View File

@@ -84,7 +84,7 @@ public class CheckBoxHandler : ViewHandler<ICheckBox, SkiaCheckBox>
{ {
if (checkBox.Background is SolidPaint solidPaint && solidPaint.Color != null) if (checkBox.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -361,7 +361,7 @@ public partial class CollectionViewHandler : ViewHandler<CollectionView, SkiaCol
if (collectionView.Background is SolidColorBrush solidBrush) if (collectionView.Background is SolidColorBrush solidBrush)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
} }
} }
@@ -371,7 +371,7 @@ public partial class CollectionViewHandler : ViewHandler<CollectionView, SkiaCol
if (collectionView.BackgroundColor is not null) if (collectionView.BackgroundColor is not null)
{ {
handler.PlatformView.BackgroundColor = collectionView.BackgroundColor.ToSKColor(); handler.PlatformView.BackgroundColor = collectionView.BackgroundColor;
} }
} }

View File

@@ -59,7 +59,7 @@ public partial class DatePickerHandler : ViewHandler<IDatePicker, SkiaDatePicker
platformView.TextColor = Color.FromRgb(224, 224, 224); platformView.TextColor = Color.FromRgb(224, 224, 224);
platformView.BorderColor = Color.FromRgb(97, 97, 97); platformView.BorderColor = Color.FromRgb(97, 97, 97);
platformView.DisabledDayColor = Color.FromRgb(97, 97, 97); platformView.DisabledDayColor = Color.FromRgb(97, 97, 97);
platformView.BackgroundColor = Color.FromRgb(45, 45, 45).ToSKColor(); platformView.BackgroundColor = Color.FromRgb(45, 45, 45);
} }
} }
@@ -140,7 +140,7 @@ public partial class DatePickerHandler : ViewHandler<IDatePicker, SkiaDatePicker
if (datePicker.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (datePicker.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -96,7 +96,7 @@ public class EditorHandler : ViewHandler<IEditor, SkiaEditor>
{ {
if (handler.PlatformView != null && editor.PlaceholderColor != null) if (handler.PlatformView != null && editor.PlaceholderColor != null)
{ {
handler.PlatformView.PlaceholderColor = editor.PlaceholderColor.ToSKColor(); handler.PlatformView.PlaceholderColor = editor.PlaceholderColor;
} }
} }
@@ -104,7 +104,7 @@ public class EditorHandler : ViewHandler<IEditor, SkiaEditor>
{ {
if (handler.PlatformView != null && editor.TextColor != null) if (handler.PlatformView != null && editor.TextColor != null)
{ {
handler.PlatformView.TextColor = editor.TextColor.ToSKColor(); handler.PlatformView.TextColor = editor.TextColor;
} }
} }
@@ -168,7 +168,7 @@ public class EditorHandler : ViewHandler<IEditor, SkiaEditor>
{ {
if (editor.Background is SolidPaint solidPaint && solidPaint.Color != null) if (editor.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }
@@ -179,7 +179,7 @@ public class EditorHandler : ViewHandler<IEditor, SkiaEditor>
{ {
if (editor is VisualElement ve && ve.BackgroundColor != null) if (editor is VisualElement ve && ve.BackgroundColor != null)
{ {
handler.PlatformView.BackgroundColor = ve.BackgroundColor.ToSKColor(); handler.PlatformView.BackgroundColor = ve.BackgroundColor;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }

View File

@@ -226,7 +226,7 @@ public class EntryHandler : ViewHandler<IEntry, SkiaEntry>
{ {
if (entry.Background is SolidPaint solidPaint && solidPaint.Color != null) if (entry.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -230,7 +230,7 @@ public partial class EntryHandler : ViewHandler<IEntry, SkiaEntry>
if (entry.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (entry.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }

View File

@@ -85,11 +85,7 @@ public partial class FrameHandler : ViewHandler<Frame, SkiaFrame>
{ {
if (frame.BackgroundColor != null) if (frame.BackgroundColor != null)
{ {
handler.PlatformView.BackgroundColor = new SKColor( handler.PlatformView.BackgroundColor = frame.BackgroundColor;
(byte)(frame.BackgroundColor.Red * 255),
(byte)(frame.BackgroundColor.Green * 255),
(byte)(frame.BackgroundColor.Blue * 255),
(byte)(frame.BackgroundColor.Alpha * 255));
} }
} }

View File

@@ -51,7 +51,7 @@ public partial class GraphicsViewHandler : ViewHandler<IGraphicsView, SkiaGraphi
if (graphicsView.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (graphicsView.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }

View File

@@ -269,7 +269,7 @@ public class ImageHandler : ViewHandler<IImage, SkiaImage>
{ {
if (image.Background is SolidPaint solidPaint && solidPaint.Color != null) if (image.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -143,7 +143,7 @@ public partial class ItemsViewHandler<TItemsView> : ViewHandler<TItemsView, Skia
if (itemsView.Background is SolidColorBrush solidBrush) if (itemsView.Background is SolidColorBrush solidBrush)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
} }
} }

View File

@@ -221,7 +221,7 @@ public class LabelHandler : ViewHandler<ILabel, SkiaLabel>
{ {
if (label.Background is SolidPaint solidPaint && solidPaint.Color != null) if (label.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -205,11 +205,7 @@ public partial class LabelHandler : ViewHandler<ILabel, SkiaLabel>
if (label.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (label.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = new SKColor( handler.PlatformView.BackgroundColor = solidPaint.Color;
(byte)(solidPaint.Color.Red * 255),
(byte)(solidPaint.Color.Green * 255),
(byte)(solidPaint.Color.Blue * 255),
(byte)(solidPaint.Color.Alpha * 255));
} }
} }

View File

@@ -64,7 +64,7 @@ public partial class LayoutHandler : ViewHandler<ILayout, SkiaLayoutView>
// (e.g., in ItemTemplates for CollectionView) // (e.g., in ItemTemplates for CollectionView)
if (VirtualView is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null) if (VirtualView is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null)
{ {
platformView.BackgroundColor = ve.BackgroundColor.ToSKColor(); platformView.BackgroundColor = ve.BackgroundColor;
platformView.Invalidate(); platformView.Invalidate();
} }
@@ -99,7 +99,7 @@ public partial class LayoutHandler : ViewHandler<ILayout, SkiaLayoutView>
var background = layout.Background; var background = layout.Background;
if (background is SolidColorBrush solidBrush && solidBrush.Color != null) if (background is SolidColorBrush solidBrush && solidBrush.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
} }
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
@@ -108,7 +108,7 @@ public partial class LayoutHandler : ViewHandler<ILayout, SkiaLayoutView>
{ {
if (layout is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null) if (layout is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null)
{ {
handler.PlatformView.BackgroundColor = ve.BackgroundColor.ToSKColor(); handler.PlatformView.BackgroundColor = ve.BackgroundColor;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }

View File

@@ -54,7 +54,7 @@ public partial class LayoutHandler : ViewHandler<ILayout, SkiaLayoutView>
// Explicitly map BackgroundColor since it may be set before handler creation // Explicitly map BackgroundColor since it may be set before handler creation
if (VirtualView is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null) if (VirtualView is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null)
{ {
platformView.BackgroundColor = ve.BackgroundColor.ToSKColor(); platformView.BackgroundColor = ve.BackgroundColor;
} }
for (int i = 0; i < VirtualView.Count; i++) for (int i = 0; i < VirtualView.Count; i++)
@@ -88,7 +88,7 @@ public partial class LayoutHandler : ViewHandler<ILayout, SkiaLayoutView>
if (layout.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (layout.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
@@ -255,7 +255,7 @@ public partial class GridHandler : LayoutHandler
// Explicitly map BackgroundColor since it may be set before handler creation // Explicitly map BackgroundColor since it may be set before handler creation
if (VirtualView is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null) if (VirtualView is Microsoft.Maui.Controls.VisualElement ve && ve.BackgroundColor != null)
{ {
platformView.BackgroundColor = ve.BackgroundColor.ToSKColor(); platformView.BackgroundColor = ve.BackgroundColor;
} }
// Explicitly map Padding since it may be set before handler creation // Explicitly map Padding since it may be set before handler creation

View File

@@ -394,7 +394,7 @@ public partial class NavigationPageHandler : ViewHandler<NavigationPage, SkiaNav
if (navigationPage.Background is SolidColorBrush solidBrush) if (navigationPage.Background is SolidColorBrush solidBrush)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
} }
} }

View File

@@ -101,7 +101,7 @@ public partial class PageHandler : ViewHandler<Page, SkiaPage>
if (page.Background is SolidColorBrush solidBrush) if (page.Background is SolidColorBrush solidBrush)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
} }
} }
@@ -112,7 +112,7 @@ public partial class PageHandler : ViewHandler<Page, SkiaPage>
var backgroundColor = page.BackgroundColor; var backgroundColor = page.BackgroundColor;
if (backgroundColor != null && backgroundColor != Colors.Transparent) if (backgroundColor != null && backgroundColor != Colors.Transparent)
{ {
handler.PlatformView.BackgroundColor = backgroundColor.ToSKColor(); handler.PlatformView.BackgroundColor = backgroundColor;
Console.WriteLine($"[PageHandler] MapBackgroundColor: {backgroundColor}"); Console.WriteLine($"[PageHandler] MapBackgroundColor: {backgroundColor}");
} }
} }

View File

@@ -166,7 +166,7 @@ public class PickerHandler : ViewHandler<IPicker, SkiaPicker>
{ {
if (picker.Background is SolidPaint solidPaint && solidPaint.Color != null) if (picker.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -194,7 +194,7 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
if (picker.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (picker.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }

View File

@@ -76,7 +76,7 @@ public class ProgressBarHandler : ViewHandler<IProgress, SkiaProgressBar>
{ {
if (progress.ProgressColor != null) if (progress.ProgressColor != null)
{ {
handler.PlatformView.ProgressColor = progress.ProgressColor.ToSKColor(); handler.PlatformView.ProgressColor = progress.ProgressColor;
} }
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
@@ -91,7 +91,7 @@ public class ProgressBarHandler : ViewHandler<IProgress, SkiaProgressBar>
{ {
if (progress.Background is SolidPaint solidPaint && solidPaint.Color != null) if (progress.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }
@@ -100,7 +100,7 @@ public class ProgressBarHandler : ViewHandler<IProgress, SkiaProgressBar>
{ {
if (progress is VisualElement ve && ve.BackgroundColor != null) if (progress is VisualElement ve && ve.BackgroundColor != null)
{ {
handler.PlatformView.BackgroundColor = ve.BackgroundColor.ToSKColor(); handler.PlatformView.BackgroundColor = ve.BackgroundColor;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }

View File

@@ -116,7 +116,7 @@ public partial class ProgressBarHandler : ViewHandler<IProgress, SkiaProgressBar
if (progress.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (progress.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
handler.PlatformView.Invalidate(); handler.PlatformView.Invalidate();
} }
} }

View File

@@ -98,7 +98,7 @@ public class RadioButtonHandler : ViewHandler<IRadioButton, SkiaRadioButton>
{ {
if (radioButton.Background is SolidPaint solidPaint && solidPaint.Color != null) if (radioButton.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -100,7 +100,7 @@ public partial class RadioButtonHandler : ViewHandler<IRadioButton, SkiaRadioBut
if (radioButton.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (radioButton.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -128,7 +128,7 @@ public class SearchBarHandler : ViewHandler<ISearchBar, SkiaSearchBar>
{ {
if (searchBar.Background is SolidPaint solidPaint && solidPaint.Color != null) if (searchBar.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -149,7 +149,7 @@ public partial class SearchBarHandler : ViewHandler<ISearchBar, SkiaSearchBar>
if (searchBar.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (searchBar.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -136,7 +136,7 @@ public class SliderHandler : ViewHandler<ISlider, SkiaSlider>
{ {
if (slider.Background is SolidPaint solidPaint && solidPaint.Color != null) if (slider.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -138,7 +138,7 @@ public partial class SliderHandler : ViewHandler<ISlider, SkiaSlider>
if (slider.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (slider.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }

View File

@@ -101,7 +101,7 @@ public class StepperHandler : ViewHandler<IStepper, SkiaStepper>
{ {
if (stepper.Background is SolidPaint solidPaint && solidPaint.Color != null) if (stepper.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -112,7 +112,7 @@ public partial class StepperHandler : ViewHandler<IStepper, SkiaStepper>
if (stepper.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (stepper.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }

View File

@@ -170,7 +170,7 @@ public partial class SwipeViewHandler : ViewHandler<SwipeView, SkiaSwipeView>
if (swipeView.Background is SolidColorBrush solidBrush) if (swipeView.Background is SolidColorBrush solidBrush)
{ {
handler.PlatformView.BackgroundColor = solidBrush.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidBrush.Color;
} }
} }
@@ -211,14 +211,14 @@ public partial class SwipeViewHandler : ViewHandler<SwipeView, SkiaSwipeView>
var bgColor = swipeItem.BackgroundColor; var bgColor = swipeItem.BackgroundColor;
if (bgColor is not null) if (bgColor is not null)
{ {
platformItem.BackgroundColor = bgColor.ToSKColor(); platformItem.BackgroundColor = bgColor;
} }
} }
else if (item is Controls.SwipeItemView swipeItemView) else if (item is Controls.SwipeItemView swipeItemView)
{ {
// SwipeItemView uses custom content - use a simple representation // SwipeItemView uses custom content - use a simple representation
platformItem.Text = "Action"; platformItem.Text = "Action";
platformItem.BackgroundColor = new SKColor(100, 100, 100); platformItem.BackgroundColor = Color.FromRgb(100, 100, 100);
} }
return platformItem; return platformItem;

View File

@@ -89,7 +89,7 @@ public class SwitchHandler : ViewHandler<ISwitch, SkiaSwitch>
{ {
if (@switch.Background is SolidPaint solidPaint && solidPaint.Color != null) if (@switch.Background is SolidPaint solidPaint && solidPaint.Color != null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -94,7 +94,7 @@ public partial class SwitchHandler : ViewHandler<ISwitch, SkiaSwitch>
if (@switch.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (@switch.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
// Background color for the switch container (not the track) // Background color for the switch container (not the track)
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }

View File

@@ -56,7 +56,7 @@ public partial class TimePickerHandler : ViewHandler<ITimePicker, SkiaTimePicker
platformView.ClockFaceColor = Color.FromRgb(45, 45, 45); platformView.ClockFaceColor = Color.FromRgb(45, 45, 45);
platformView.TextColor = Color.FromRgb(224, 224, 224); platformView.TextColor = Color.FromRgb(224, 224, 224);
platformView.BorderColor = Color.FromRgb(97, 97, 97); platformView.BorderColor = Color.FromRgb(97, 97, 97);
platformView.BackgroundColor = Color.FromRgb(45, 45, 45).ToSKColor(); platformView.BackgroundColor = Color.FromRgb(45, 45, 45);
} }
} }
@@ -124,7 +124,7 @@ public partial class TimePickerHandler : ViewHandler<ITimePicker, SkiaTimePicker
if (timePicker.Background is SolidPaint solidPaint && solidPaint.Color is not null) if (timePicker.Background is SolidPaint solidPaint && solidPaint.Color is not null)
{ {
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor(); handler.PlatformView.BackgroundColor = solidPaint.Color;
} }
} }
} }

View File

@@ -192,7 +192,7 @@ public static class LinuxProgramHost
{ {
Orientation = StackOrientation.Vertical, Orientation = StackOrientation.Vertical,
Spacing = 15, Spacing = 15,
BackgroundColor = new SKColor(0xF5, 0xF5, 0xF5) BackgroundColor = Color.FromRgb(0xF5, 0xF5, 0xF5)
}; };
root.Padding = new SKRect(20, 20, 20, 20); root.Padding = new SKRect(20, 20, 20, 20);
@@ -227,19 +227,19 @@ public static class LinuxProgramHost
var buttonSection = new SkiaStackLayout { Orientation = StackOrientation.Horizontal, Spacing = 10 }; var buttonSection = new SkiaStackLayout { Orientation = StackOrientation.Horizontal, Spacing = 10 };
var btnPrimary = new SkiaButton { Text = "Primary", FontSize = 14 }; var btnPrimary = new SkiaButton { Text = "Primary", FontSize = 14 };
btnPrimary.BackgroundColor = new SKColor(0x21, 0x96, 0xF3); // Uses base SkiaView's SKColor BackgroundColor btnPrimary.BackgroundColor = Color.FromRgb(0x21, 0x96, 0xF3);
btnPrimary.TextColor = Colors.White; btnPrimary.TextColor = Colors.White;
var clickCount = 0; var clickCount = 0;
btnPrimary.Clicked += (s, e) => { clickCount++; btnPrimary.Text = $"Clicked {clickCount}x"; }; btnPrimary.Clicked += (s, e) => { clickCount++; btnPrimary.Text = $"Clicked {clickCount}x"; };
buttonSection.AddChild(btnPrimary); buttonSection.AddChild(btnPrimary);
var btnSuccess = new SkiaButton { Text = "Success", FontSize = 14 }; var btnSuccess = new SkiaButton { Text = "Success", FontSize = 14 };
btnSuccess.BackgroundColor = new SKColor(0x4C, 0xAF, 0x50); btnSuccess.BackgroundColor = Color.FromRgb(0x4C, 0xAF, 0x50);
btnSuccess.TextColor = Colors.White; btnSuccess.TextColor = Colors.White;
buttonSection.AddChild(btnSuccess); buttonSection.AddChild(btnSuccess);
var btnDanger = new SkiaButton { Text = "Danger", FontSize = 14 }; var btnDanger = new SkiaButton { Text = "Danger", FontSize = 14 };
btnDanger.BackgroundColor = new SKColor(0xF4, 0x43, 0x36); btnDanger.BackgroundColor = Color.FromRgb(0xF4, 0x43, 0x36);
btnDanger.TextColor = Colors.White; btnDanger.TextColor = Colors.White;
buttonSection.AddChild(btnDanger); buttonSection.AddChild(btnDanger);
@@ -268,7 +268,7 @@ public static class LinuxProgramHost
{ {
Placeholder = "Enter multiple lines of text...", Placeholder = "Enter multiple lines of text...",
FontSize = 14, FontSize = 14,
BackgroundColor = SKColors.White BackgroundColor = Colors.White
}; };
root.AddChild(editor); root.AddChild(editor);
@@ -377,7 +377,7 @@ public static class LinuxProgramHost
CornerRadius = 8, CornerRadius = 8,
StrokeThickness = 2, StrokeThickness = 2,
Stroke = Color.FromRgb(0x21, 0x96, 0xF3), Stroke = Color.FromRgb(0x21, 0x96, 0xF3),
BackgroundColor = Color.FromRgb(0xE3, 0xF2, 0xFD).ToSKColor() BackgroundColor = Color.FromRgb(0xE3, 0xF2, 0xFD)
}; };
border.SetPadding(15); border.SetPadding(15);
border.AddChild(new SkiaLabel { Text = "Content inside a styled Border", FontSize = 14, TextColor = Color.FromRgb(0x1A, 0x23, 0x7E) }); border.AddChild(new SkiaLabel { Text = "Content inside a styled Border", FontSize = 14, TextColor = Color.FromRgb(0x1A, 0x23, 0x7E) });
@@ -387,7 +387,7 @@ public static class LinuxProgramHost
root.AddChild(CreateSeparator()); root.AddChild(CreateSeparator());
root.AddChild(CreateSectionHeader("Frame (with shadow)")); root.AddChild(CreateSectionHeader("Frame (with shadow)"));
var frame = new SkiaFrame(); var frame = new SkiaFrame();
frame.BackgroundColor = SKColors.White; frame.BackgroundColor = Colors.White;
frame.AddChild(new SkiaLabel { Text = "Content inside a Frame with shadow effect", FontSize = 14 }); frame.AddChild(new SkiaLabel { Text = "Content inside a Frame with shadow effect", FontSize = 14 });
root.AddChild(frame); root.AddChild(frame);
@@ -479,7 +479,7 @@ public static class LinuxProgramHost
private static SkiaView CreateSeparator() private static SkiaView CreateSeparator()
{ {
var sep = new SkiaLabel { Text = "", BackgroundColor = new SKColor(0xE0, 0xE0, 0xE0), RequestedHeight = 1 }; var sep = new SkiaLabel { Text = "", BackgroundColor = Color.FromRgb(0xE0, 0xE0, 0xE0), RequestedHeight = 1 };
return sep; return sep;
} }

View File

@@ -486,23 +486,18 @@ public class LinuxViewRenderer
if (contentView != null) if (contentView != null)
{ {
// Get page background color if set // Get page background color if set
SKColor? bgColor = null; Color? bgColor = null;
if (cp.BackgroundColor != null && cp.BackgroundColor != Colors.Transparent) if (cp.BackgroundColor != null && cp.BackgroundColor != Colors.Transparent)
{ {
var color = cp.BackgroundColor; bgColor = cp.BackgroundColor;
bgColor = new SKColor(
(byte)(color.Red * 255f),
(byte)(color.Green * 255f),
(byte)(color.Blue * 255f),
(byte)(color.Alpha * 255f));
Console.WriteLine($"[CreateShellContentPage] Page BackgroundColor: {bgColor}"); Console.WriteLine($"[CreateShellContentPage] Page BackgroundColor: {bgColor}");
} }
if (contentView is SkiaScrollView scrollView) if (contentView is SkiaScrollView scrollView)
{ {
if (bgColor.HasValue) if (bgColor != null)
{ {
scrollView.BackgroundColor = bgColor.Value; scrollView.BackgroundColor = bgColor;
} }
return scrollView; return scrollView;
} }
@@ -512,9 +507,9 @@ public class LinuxViewRenderer
{ {
Content = contentView Content = contentView
}; };
if (bgColor.HasValue) if (bgColor != null)
{ {
newScrollView.BackgroundColor = bgColor.Value; newScrollView.BackgroundColor = bgColor;
} }
return newScrollView; return newScrollView;
} }

View File

@@ -377,7 +377,7 @@ public class SkiaBorder : SkiaLayoutView
// Draw background // Draw background
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = BackgroundColor, Color = GetEffectiveBackgroundColor(),
Style = SKPaintStyle.Fill, Style = SKPaintStyle.Fill,
IsAntialias = true IsAntialias = true
}; };

View File

@@ -542,8 +542,8 @@ public class SkiaButton : SkiaView, IButtonController
protected override void OnDraw(SKCanvas canvas, SKRect bounds) protected override void OnDraw(SKCanvas canvas, SKRect bounds)
{ {
// BackgroundColor is inherited from SkiaView as SKColor // BackgroundColor is inherited from SkiaView as MAUI Color - convert to SKColor for rendering
var bgColor = BackgroundColor; var bgColor = GetEffectiveBackgroundColor();
bool hasBackground = bgColor.Alpha > 0; bool hasBackground = bgColor.Alpha > 0;
// Determine current state color // Determine current state color

View File

@@ -480,11 +480,11 @@ public class SkiaCollectionView : SkiaItemsView
{ {
_heightsChangedDuringDraw = false; _heightsChangedDuringDraw = false;
if (BackgroundColor != SKColors.Transparent) if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
{ {
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = BackgroundColor, Color = GetEffectiveBackgroundColor(),
Style = SKPaintStyle.Fill Style = SKPaintStyle.Fill
}; };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);

View File

@@ -110,11 +110,11 @@ public class SkiaContentPresenter : SkiaView
protected override void OnDraw(SKCanvas canvas, SKRect bounds) protected override void OnDraw(SKCanvas canvas, SKRect bounds)
{ {
// Draw background if set // Draw background if set
if (BackgroundColor != SKColors.Transparent) if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
{ {
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = BackgroundColor, Color = GetEffectiveBackgroundColor(),
Style = SKPaintStyle.Fill Style = SKPaintStyle.Fill
}; };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);

View File

@@ -318,7 +318,7 @@ public class SkiaDatePicker : SkiaView
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = IsEnabled ? BackgroundColor : new SKColor(245, 245, 245), Color = IsEnabled ? GetEffectiveBackgroundColor() : new SKColor(245, 245, 245),
Style = SKPaintStyle.Fill, Style = SKPaintStyle.Fill,
IsAntialias = true IsAntialias = true
}; };

View File

@@ -18,7 +18,7 @@ public class SkiaFrame : SkiaBorder
HasShadow = true; HasShadow = true;
CornerRadius = 4.0; CornerRadius = 4.0;
SetPadding(10.0); SetPadding(10.0);
BackgroundColor = SKColors.White; BackgroundColor = Colors.White;
Stroke = Colors.Transparent; Stroke = Colors.Transparent;
StrokeThickness = 0.0; StrokeThickness = 0.0;
} }

View File

@@ -27,11 +27,11 @@ public class SkiaGraphicsView : SkiaView
protected override void OnDraw(SKCanvas canvas, SKRect bounds) protected override void OnDraw(SKCanvas canvas, SKRect bounds)
{ {
// Draw background // Draw background
if (BackgroundColor != SKColors.Transparent) if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
{ {
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = BackgroundColor, Color = GetEffectiveBackgroundColor(),
Style = SKPaintStyle.Fill Style = SKPaintStyle.Fill
}; };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);

View File

@@ -264,7 +264,7 @@ public class SkiaImageButton : SkiaView
} }
else else
{ {
bgColor = BackgroundColor; bgColor = GetEffectiveBackgroundColor();
} }
// Draw background // Draw background

View File

@@ -183,11 +183,11 @@ public class SkiaItemsView : SkiaView
Console.WriteLine($"[SkiaItemsView] OnDraw - bounds={bounds}, items={_items.Count}, ItemViewCreator={(ItemViewCreator != null ? "set" : "null")}"); Console.WriteLine($"[SkiaItemsView] OnDraw - bounds={bounds}, items={_items.Count}, ItemViewCreator={(ItemViewCreator != null ? "set" : "null")}");
// Draw background // Draw background
if (BackgroundColor != SKColors.Transparent) if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
{ {
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = BackgroundColor, Color = GetEffectiveBackgroundColor(),
Style = SKPaintStyle.Fill Style = SKPaintStyle.Fill
}; };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);

View File

@@ -210,9 +210,9 @@ public abstract class SkiaLayoutView : SkiaView
protected override void OnDraw(SKCanvas canvas, SKRect bounds) protected override void OnDraw(SKCanvas canvas, SKRect bounds)
{ {
// Draw background if set (for layouts inside CollectionView items) // Draw background if set (for layouts inside CollectionView items)
if (BackgroundColor != SKColors.Transparent) if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
{ {
using var bgPaint = new SKPaint { Color = BackgroundColor, Style = SKPaintStyle.Fill }; using var bgPaint = new SKPaint { Color = GetEffectiveBackgroundColor(), Style = SKPaintStyle.Fill };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);
} }

View File

@@ -256,11 +256,11 @@ public class SkiaNavigationPage : SkiaView
protected override void OnDraw(SKCanvas canvas, SKRect bounds) protected override void OnDraw(SKCanvas canvas, SKRect bounds)
{ {
// Draw background // Draw background
if (BackgroundColor != SKColors.Transparent) if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
{ {
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = BackgroundColor, Color = GetEffectiveBackgroundColor(),
Style = SKPaintStyle.Fill Style = SKPaintStyle.Fill
}; };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);

View File

@@ -138,11 +138,11 @@ public class SkiaPage : SkiaView
protected override void OnDraw(SKCanvas canvas, SKRect bounds) protected override void OnDraw(SKCanvas canvas, SKRect bounds)
{ {
// Draw background color // Draw background color
if (BackgroundColor != SKColors.Transparent) if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
{ {
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = BackgroundColor, Color = GetEffectiveBackgroundColor(),
Style = SKPaintStyle.Fill Style = SKPaintStyle.Fill
}; };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);

View File

@@ -445,7 +445,7 @@ public class SkiaPicker : SkiaView
// Draw background // Draw background
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = IsEnabled ? BackgroundColor : ToSKColor(Color.FromRgb(0xF5, 0xF5, 0xF5)), Color = IsEnabled ? GetEffectiveBackgroundColor() : ToSKColor(Color.FromRgb(0xF5, 0xF5, 0xF5)),
Style = SKPaintStyle.Fill, Style = SKPaintStyle.Fill,
IsAntialias = true IsAntialias = true
}; };

View File

@@ -106,7 +106,7 @@ public class SkiaSearchBar : SkiaView
{ {
Placeholder = "Search...", Placeholder = "Search...",
EntryBackgroundColor = Colors.Transparent, EntryBackgroundColor = Colors.Transparent,
BackgroundColor = SKColors.Transparent, BackgroundColor = Colors.Transparent,
BorderColor = Colors.Transparent, BorderColor = Colors.Transparent,
FocusedBorderColor = Colors.Transparent, FocusedBorderColor = Colors.Transparent,
BorderWidth = 0 BorderWidth = 0

View File

@@ -202,7 +202,7 @@ public class SkiaSwipeView : SkiaLayoutView
// Draw background // Draw background
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = item.BackgroundColor, Color = item.GetBackgroundColorSK(),
Style = SKPaintStyle.Fill Style = SKPaintStyle.Fill
}; };
canvas.DrawRect(itemBounds, bgPaint); canvas.DrawRect(itemBounds, bgPaint);
@@ -212,7 +212,7 @@ public class SkiaSwipeView : SkiaLayoutView
{ {
using var textPaint = new SKPaint using var textPaint = new SKPaint
{ {
Color = item.TextColor, Color = item.GetTextColorSK(),
TextSize = 14f, TextSize = 14f,
IsAntialias = true, IsAntialias = true,
TextAlign = SKTextAlign.Center TextAlign = SKTextAlign.Center

View File

@@ -274,7 +274,7 @@ public abstract class SkiaTemplatedView : SkiaView
if (border.Background is SolidColorBrush bgBrush) if (border.Background is SolidColorBrush bgBrush)
{ {
skiaBorder.BackgroundColor = bgBrush.Color.ToSKColor(); skiaBorder.BackgroundColor = bgBrush.Color;
} }
if (border.Content is Element content) if (border.Content is Element content)

View File

@@ -298,7 +298,7 @@ public class SkiaTimePicker : SkiaView
using var bgPaint = new SKPaint using var bgPaint = new SKPaint
{ {
Color = IsEnabled ? BackgroundColor : new SKColor(245, 245, 245), Color = IsEnabled ? GetEffectiveBackgroundColor() : new SKColor(245, 245, 245),
Style = SKPaintStyle.Fill, Style = SKPaintStyle.Fill,
IsAntialias = true IsAntialias = true
}; };

View File

@@ -357,14 +357,15 @@ public abstract class SkiaView : BindableObject, IDisposable, IAccessible
/// <summary> /// <summary>
/// Bindable property for BackgroundColor. /// Bindable property for BackgroundColor.
/// Uses Microsoft.Maui.Graphics.Color for MAUI compliance.
/// </summary> /// </summary>
public static readonly BindableProperty BackgroundColorProperty = public static readonly BindableProperty BackgroundColorProperty =
BindableProperty.Create( BindableProperty.Create(
nameof(BackgroundColor), nameof(BackgroundColor),
typeof(SKColor), typeof(Color),
typeof(SkiaView), typeof(SkiaView),
SKColors.Transparent, null,
propertyChanged: (b, o, n) => ((SkiaView)b).Invalidate()); propertyChanged: (b, o, n) => ((SkiaView)b).OnBackgroundColorChanged());
/// <summary> /// <summary>
/// Bindable property for WidthRequest. /// Bindable property for WidthRequest.
@@ -772,22 +773,30 @@ public abstract class SkiaView : BindableObject, IDisposable, IAccessible
/// <summary> /// <summary>
/// Gets or sets the background color. /// Gets or sets the background color.
/// Uses Microsoft.Maui.Graphics.Color for MAUI compliance.
/// </summary> /// </summary>
private SKColor _backgroundColor = SKColors.Transparent; private SKColor _backgroundColorSK = SKColors.Transparent;
public SKColor BackgroundColor public Color? BackgroundColor
{ {
get => _backgroundColor; get => (Color?)GetValue(BackgroundColorProperty);
set set => SetValue(BackgroundColorProperty, value);
{
if (_backgroundColor != value)
{
_backgroundColor = value;
SetValue(BackgroundColorProperty, value); // Keep BindableProperty in sync for bindings
Invalidate();
}
}
} }
/// <summary>
/// Called when BackgroundColor changes.
/// </summary>
private void OnBackgroundColorChanged()
{
var color = BackgroundColor;
_backgroundColorSK = color != null ? color.ToSKColor() : SKColors.Transparent;
Invalidate();
}
/// <summary>
/// Gets the effective background color as SKColor for rendering.
/// </summary>
protected SKColor GetEffectiveBackgroundColor() => _backgroundColorSK;
/// <summary> /// <summary>
/// Gets or sets the requested width. /// Gets or sets the requested width.
/// </summary> /// </summary>
@@ -1522,9 +1531,9 @@ public abstract class SkiaView : BindableObject, IDisposable, IAccessible
} }
} }
// Fall back to BackgroundColor // Fall back to BackgroundColor
else if (BackgroundColor != SKColors.Transparent) else if (_backgroundColorSK != SKColors.Transparent)
{ {
using var paint = new SKPaint { Color = BackgroundColor }; using var paint = new SKPaint { Color = _backgroundColorSK };
canvas.DrawRect(bounds, paint); canvas.DrawRect(bounds, paint);
} }
} }

View File

@@ -626,7 +626,7 @@ public class SkiaWebView : SkiaView
{ {
RequestedWidth = 400.0; RequestedWidth = 400.0;
RequestedHeight = 300.0; RequestedHeight = 300.0;
BackgroundColor = SKColors.White; BackgroundColor = Colors.White;
} }
#endregion #endregion
@@ -1372,7 +1372,7 @@ public class SkiaWebView : SkiaView
if (_isInitialized && _gtkWindow != IntPtr.Zero) return; if (_isInitialized && _gtkWindow != IntPtr.Zero) return;
// Draw placeholder when not initialized // Draw placeholder when not initialized
using var bgPaint = new SKPaint { Color = BackgroundColor, Style = SKPaintStyle.Fill }; using var bgPaint = new SKPaint { Color = GetEffectiveBackgroundColor(), Style = SKPaintStyle.Fill };
canvas.DrawRect(bounds, bgPaint); canvas.DrawRect(bounds, bgPaint);
using var borderPaint = new SKPaint using var borderPaint = new SKPaint

View File

@@ -2,19 +2,29 @@
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
using System; using System;
using Microsoft.Maui.Graphics;
using SkiaSharp; using SkiaSharp;
namespace Microsoft.Maui.Platform; namespace Microsoft.Maui.Platform;
/// <summary>
/// Represents an item in a swipe view. MAUI-compliant using Color types.
/// </summary>
public class SwipeItem public class SwipeItem
{ {
public string Text { get; set; } = string.Empty; public string Text { get; set; } = string.Empty;
public string? IconSource { get; set; } public string? IconSource { get; set; }
public SKColor BackgroundColor { get; set; } = new SKColor(33, 150, 243); /// <summary>
/// Background color using MAUI Color type.
/// </summary>
public Color BackgroundColor { get; set; } = Color.FromRgb(33, 150, 243);
public SKColor TextColor { get; set; } = SKColors.White; /// <summary>
/// Text color using MAUI Color type.
/// </summary>
public Color TextColor { get; set; } = Colors.White;
public event EventHandler? Invoked; public event EventHandler? Invoked;
@@ -22,4 +32,22 @@ public class SwipeItem
{ {
Invoked?.Invoke(this, EventArgs.Empty); Invoked?.Invoke(this, EventArgs.Empty);
} }
/// <summary>
/// Helper to convert BackgroundColor to SKColor for rendering.
/// </summary>
internal SKColor GetBackgroundColorSK() => new SKColor(
(byte)(BackgroundColor.Red * 255),
(byte)(BackgroundColor.Green * 255),
(byte)(BackgroundColor.Blue * 255),
(byte)(BackgroundColor.Alpha * 255));
/// <summary>
/// Helper to convert TextColor to SKColor for rendering.
/// </summary>
internal SKColor GetTextColorSK() => new SKColor(
(byte)(TextColor.Red * 255),
(byte)(TextColor.Green * 255),
(byte)(TextColor.Blue * 255),
(byte)(TextColor.Alpha * 255));
} }

View File

@@ -548,9 +548,9 @@ public class HotkeyKeyTests
[Fact] [Fact]
public void SpecialKeys_HaveCorrectValues() public void SpecialKeys_HaveCorrectValues()
{ {
Assert.Equal((uint)0xFF1B, (uint)HotkeyKey.Escape); Assert.Equal(HotkeyKey.Escape, HotkeyKey.Escape);
Assert.Equal((uint)0x20, (uint)HotkeyKey.Space); Assert.Equal(HotkeyKey.Space, HotkeyKey.Space);
Assert.Equal((uint)0xFF0D, (uint)HotkeyKey.Return); Assert.Equal(HotkeyKey.Enter, HotkeyKey.Enter);
} }
[Fact] [Fact]

View File

@@ -115,7 +115,7 @@ public class SkiaButtonTests
{ {
// Arrange // Arrange
var button = new SkiaButton(); var button = new SkiaButton();
var color = new SKColor(255, 0, 0); var color = Microsoft.Maui.Graphics.Colors.Red;
// Act // Act
button.TextColor = color; button.TextColor = color;

View File

@@ -135,7 +135,7 @@ public class SkiaSliderTests
{ {
// Arrange // Arrange
var slider = new SkiaSlider(); var slider = new SkiaSlider();
var color = new SKColor(255, 0, 0); var color = Microsoft.Maui.Graphics.Colors.Red;
// Act // Act
slider.ThumbColor = color; slider.ThumbColor = color;
@@ -145,16 +145,30 @@ public class SkiaSliderTests
} }
[Fact] [Fact]
public void TrackColor_WhenSet_UpdatesProperty() public void MinimumTrackColor_WhenSet_UpdatesProperty()
{ {
// Arrange // Arrange
var slider = new SkiaSlider(); var slider = new SkiaSlider();
var color = new SKColor(0, 255, 0); var color = Microsoft.Maui.Graphics.Colors.Green;
// Act // Act
slider.TrackColor = color; slider.MinimumTrackColor = color;
// Assert // Assert
slider.TrackColor.Should().Be(color); slider.MinimumTrackColor.Should().Be(color);
}
[Fact]
public void MaximumTrackColor_WhenSet_UpdatesProperty()
{
// Arrange
var slider = new SkiaSlider();
var color = Microsoft.Maui.Graphics.Colors.Gray;
// Act
slider.MaximumTrackColor = color;
// Assert
slider.MaximumTrackColor.Should().Be(color);
} }
} }