Fixes for pages
This commit is contained in:
@@ -49,6 +49,10 @@ public partial class PageHandler : ViewHandler<Page, SkiaPage>
|
|||||||
protected override void ConnectHandler(SkiaPage platformView)
|
protected override void ConnectHandler(SkiaPage platformView)
|
||||||
{
|
{
|
||||||
base.ConnectHandler(platformView);
|
base.ConnectHandler(platformView);
|
||||||
|
|
||||||
|
// Set MauiPage reference for theme refresh support
|
||||||
|
platformView.MauiPage = VirtualView;
|
||||||
|
|
||||||
platformView.Appearing += OnAppearing;
|
platformView.Appearing += OnAppearing;
|
||||||
platformView.Disappearing += OnDisappearing;
|
platformView.Disappearing += OnDisappearing;
|
||||||
}
|
}
|
||||||
@@ -57,6 +61,7 @@ public partial class PageHandler : ViewHandler<Page, SkiaPage>
|
|||||||
{
|
{
|
||||||
platformView.Appearing -= OnAppearing;
|
platformView.Appearing -= OnAppearing;
|
||||||
platformView.Disappearing -= OnDisappearing;
|
platformView.Disappearing -= OnDisappearing;
|
||||||
|
platformView.MauiPage = null;
|
||||||
base.DisconnectHandler(platformView);
|
base.DisconnectHandler(platformView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,29 +90,19 @@ public class LinuxViewRenderer
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Render the page content
|
// Render the page through the proper handler system
|
||||||
SkiaView? pageContent = null;
|
// This ensures all properties (including BackgroundColor via AppThemeBinding) are mapped
|
||||||
if (page is ContentPage contentPage && contentPage.Content != null)
|
var skiaPage = CurrentRenderer.RenderPage(page);
|
||||||
{
|
|
||||||
pageContent = CurrentRenderer.RenderView(contentPage.Content);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pageContent == null)
|
if (skiaPage == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"[PushPage] Failed to render page content");
|
Console.WriteLine($"[PushPage] Failed to render page through handler");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap in ScrollView if needed
|
|
||||||
if (pageContent is not SkiaScrollView)
|
|
||||||
{
|
|
||||||
var scrollView = new SkiaScrollView { Content = pageContent };
|
|
||||||
pageContent = scrollView;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push onto SkiaShell's navigation stack
|
// Push onto SkiaShell's navigation stack
|
||||||
CurrentSkiaShell.PushAsync(pageContent, page.Title ?? "Detail");
|
CurrentSkiaShell.PushAsync(skiaPage, page.Title ?? "Detail");
|
||||||
Console.WriteLine($"[PushPage] Successfully pushed page");
|
Console.WriteLine($"[PushPage] Successfully pushed page via handler system");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -764,9 +764,25 @@ public class LinuxApplication : IDisposable
|
|||||||
navPage.Invalidate(); // Force redraw of navigation page
|
navPage.Invalidate(); // Force redraw of navigation page
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special handling for ContentPage - it stores content in Content property
|
// Special handling for SkiaPage - refresh via MauiPage handler and process Content
|
||||||
if (view is SkiaPage page)
|
if (view is SkiaPage page)
|
||||||
{
|
{
|
||||||
|
// Refresh page properties via handler if MauiPage is set
|
||||||
|
var pageHandler = page.MauiPage?.Handler;
|
||||||
|
if (pageHandler != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[LinuxApplication] Refreshing page theme: {page.MauiPage?.GetType().Name}");
|
||||||
|
pageHandler.UpdateValue(nameof(IView.Background));
|
||||||
|
pageHandler.UpdateValue("BackgroundColor");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[LinuxApplication] Error refreshing page theme: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
page.Invalidate(); // Force redraw to pick up theme-aware background
|
page.Invalidate(); // Force redraw to pick up theme-aware background
|
||||||
if (page.Content != null)
|
if (page.Content != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ public class SkiaPage : SkiaView
|
|||||||
private float _paddingRight;
|
private float _paddingRight;
|
||||||
private float _paddingBottom;
|
private float _paddingBottom;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reference to the MAUI Page for handler access during theme refresh.
|
||||||
|
/// </summary>
|
||||||
|
public Microsoft.Maui.Controls.Page? MauiPage { get; set; }
|
||||||
|
|
||||||
public SkiaView? Content
|
public SkiaView? Content
|
||||||
{
|
{
|
||||||
get => _content;
|
get => _content;
|
||||||
@@ -141,7 +146,8 @@ public class SkiaPage : SkiaView
|
|||||||
|
|
||||||
protected override void OnDraw(SKCanvas canvas, SKRect bounds)
|
protected override void OnDraw(SKCanvas canvas, SKRect bounds)
|
||||||
{
|
{
|
||||||
// Draw background color - use theme-aware default if not set
|
// Use BackgroundColor if explicitly set (including via AppThemeBinding),
|
||||||
|
// otherwise fall back to theme-aware default
|
||||||
SKColor bgColor;
|
SKColor bgColor;
|
||||||
if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
|
if (BackgroundColor != null && BackgroundColor != Colors.Transparent)
|
||||||
{
|
{
|
||||||
@@ -149,7 +155,7 @@ public class SkiaPage : SkiaView
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Use theme-aware page background when no explicit color is set
|
// No explicit background - use theme-aware default
|
||||||
bgColor = SkiaTheme.CurrentPageBackgroundSK;
|
bgColor = SkiaTheme.CurrentPageBackgroundSK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -500,7 +500,9 @@ public class SkiaShell : SkiaLayoutView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_selectedSectionIndex >= 0 && _selectedSectionIndex < _sections.Count)
|
// Only update current content if there are no pushed pages on the navigation stack
|
||||||
|
// Pushed pages are handled separately by LinuxApplication.RefreshViewTheme
|
||||||
|
if (_navigationStack.Count == 0 && _selectedSectionIndex >= 0 && _selectedSectionIndex < _sections.Count)
|
||||||
{
|
{
|
||||||
var section = _sections[_selectedSectionIndex];
|
var section = _sections[_selectedSectionIndex];
|
||||||
if (_selectedItemIndex >= 0 && _selectedItemIndex < section.Items.Count)
|
if (_selectedItemIndex >= 0 && _selectedItemIndex < section.Items.Count)
|
||||||
|
|||||||
Reference in New Issue
Block a user